From 7540d37422a02555771c769af92b0369222ea361 Mon Sep 17 00:00:00 2001 From: js0ny Date: Wed, 29 Oct 2025 02:24:13 +0000 Subject: [PATCH] nvim: config upgrade and add verilog support --- home/dot_config/nvim/lsp/svls.lua | 9 +++ .../nvim/lua/config/diagnostics.lua | 3 +- .../dot_config/nvim/lua/plugins/lang/init.lua | 11 +--- .../nvim/lua/plugins/lang/verilog.lua | 8 +++ nixcfgs/modules/home/dev/verilog.nix | 2 + nixcfgs/users/js0ny/programs/fzf.nix | 55 +++++++++++++++++++ 6 files changed, 77 insertions(+), 11 deletions(-) create mode 100644 home/dot_config/nvim/lsp/svls.lua create mode 100644 home/dot_config/nvim/lua/plugins/lang/verilog.lua create mode 100644 nixcfgs/users/js0ny/programs/fzf.nix diff --git a/home/dot_config/nvim/lsp/svls.lua b/home/dot_config/nvim/lsp/svls.lua new file mode 100644 index 0000000..b558f4c --- /dev/null +++ b/home/dot_config/nvim/lsp/svls.lua @@ -0,0 +1,9 @@ +-- SystemVerilog +--[[ Installation +cargo install svls +--]] +return { + cmd = { "svls" }, + filetypes = { "systemverilog", "verilog" }, + root_markers = { ".svls.toml" } +} diff --git a/home/dot_config/nvim/lua/config/diagnostics.lua b/home/dot_config/nvim/lua/config/diagnostics.lua index 98e9e99..b9a149b 100644 --- a/home/dot_config/nvim/lua/config/diagnostics.lua +++ b/home/dot_config/nvim/lua/config/diagnostics.lua @@ -3,5 +3,6 @@ local signs = require("config.icons").diagnostics -- This provides the diagnostics signs near the line numbers for type, icon in pairs(signs) do local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) + -- vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) + vim.diagnostic.config(hl, { text = icon, texthl = hl, numhl = "" }) end diff --git a/home/dot_config/nvim/lua/plugins/lang/init.lua b/home/dot_config/nvim/lua/plugins/lang/init.lua index d65cdca..56bdfa4 100644 --- a/home/dot_config/nvim/lua/plugins/lang/init.lua +++ b/home/dot_config/nvim/lua/plugins/lang/init.lua @@ -6,17 +6,8 @@ return { { import = "plugins.lang.beancount" }, { import = "plugins.lang.tex" }, { import = "plugins.lang.lua" }, + { import = "plugins.lang.verilog" }, { import = "plugins.lang.treesitter" }, { import = "plugins.mod.trouble-nvim" }, - -- Remove mason and use system package manager - -- { - -- "williamboman/mason.nvim", - -- cmd = "Mason", - -- build = ":MasonUpdate", - -- -- opts_extend = { "ensure_installed" }, - -- opts = { - -- -- ensure_installed = require("config.servers").servers, - -- }, - -- }, { import = "plugins.mod.conform-nvim" }, } diff --git a/home/dot_config/nvim/lua/plugins/lang/verilog.lua b/home/dot_config/nvim/lua/plugins/lang/verilog.lua new file mode 100644 index 0000000..17371b1 --- /dev/null +++ b/home/dot_config/nvim/lua/plugins/lang/verilog.lua @@ -0,0 +1,8 @@ +vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { + pattern = "*.v", + callback = function() + vim.bo.filetype = "verilog" + end, +}) + +return {} diff --git a/nixcfgs/modules/home/dev/verilog.nix b/nixcfgs/modules/home/dev/verilog.nix index f566c82..c70060d 100644 --- a/nixcfgs/modules/home/dev/verilog.nix +++ b/nixcfgs/modules/home/dev/verilog.nix @@ -4,6 +4,8 @@ iverilog # Simulator: Icarus Verilog gtkwave # Waveform Viewer picocom + verible # LSP + svls # LSP ]; programs.zed-editor.extensions = ["verilog"]; diff --git a/nixcfgs/users/js0ny/programs/fzf.nix b/nixcfgs/users/js0ny/programs/fzf.nix new file mode 100644 index 0000000..3efdccf --- /dev/null +++ b/nixcfgs/users/js0ny/programs/fzf.nix @@ -0,0 +1,55 @@ +{...}: let + editFzfPosix = '' + edit-fzf() { + # 1. Declare a variable that is local to the function. + local _file + + if command -v fd >/dev/null 2>&1; then + _file=$(fd --type f | fzf --height 40% --reverse) + else + # Fallback to 'find' + _file=$(find . -type f | fzf --height 40% --reverse) + fi + + # In POSIX shell, if fzf is cancelled (Esc/Ctrl-C), + # the command substitution simply returns an empty string. + # So, we check if the variable '_file' is non-empty ('-n'). + if [ -n "$_file" ]; then + "$EDITOR" "$_file" + else + echo "No file selected." + fi + } + alias ef="edit-fzf" + ''; +in { + programs.fzf = { + enable = true; + enableBashIntegration = true; + enableZshIntegration = true; + enableFishIntegration = true; + }; + programs.fish.interactiveShellInit = '' + function edit-fzf --description "Find and edit a file using fzf and $EDITOR" + set -l file + + if command -q fd + set file (fd --type f | fzf --height 40% --reverse) + else + set file (find . -type f | fzf --height 40% --reverse) + end + + set -l fzf_status $status + + if test $fzf_status -eq 0; and test -n "$file" + $EDITOR $file + else + echo "No file selected." + end + end + abbr --add ef edit-fzf + ''; + # TODO: Add integraiton for bash, zsh + programs.bash.bashrcExtra = editFzfPosix; + programs.zsh.initContent = editFzfPosix; +}