From 3f82161bae0e26127a025ffd1f578aff880d464f Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Thu, 13 Mar 2025 23:51:47 +0800 Subject: [PATCH] feat: effectively finish nvf as ide #10 --- systems/modules/fonts/terminess.nix | 15 ++- users/modules/programs/nvf.nix | 60 ++------- users/modules/programs/nvf/debugger.nix | 32 +++++ users/modules/programs/nvf/filetree.nix | 17 +++ users/modules/programs/nvf/git.nix | 2 + users/modules/programs/nvf/input.nix | 44 +++++++ users/modules/programs/nvf/keymaps.nix | 10 ++ users/modules/programs/nvf/languages.nix | 13 ++ users/modules/programs/nvf/languages/nix.nix | 13 +- users/modules/programs/nvf/lsp.nix | 119 +++++++++++++++++ users/modules/programs/nvf/notes.nix | 11 ++ users/modules/programs/nvf/options.nix | 31 +++++ users/modules/programs/nvf/search.nix | 29 +++++ users/modules/programs/nvf/utilities.nix | 89 +++++++++++++ users/modules/programs/nvf/visual.nix | 130 +++++++++++++++++++ users/modules/utils.nix | 2 + 16 files changed, 564 insertions(+), 53 deletions(-) create mode 100644 users/modules/programs/nvf/debugger.nix create mode 100644 users/modules/programs/nvf/filetree.nix create mode 100644 users/modules/programs/nvf/git.nix create mode 100644 users/modules/programs/nvf/input.nix create mode 100644 users/modules/programs/nvf/keymaps.nix create mode 100644 users/modules/programs/nvf/languages.nix create mode 100644 users/modules/programs/nvf/lsp.nix create mode 100644 users/modules/programs/nvf/notes.nix create mode 100644 users/modules/programs/nvf/options.nix create mode 100644 users/modules/programs/nvf/search.nix create mode 100644 users/modules/programs/nvf/utilities.nix create mode 100644 users/modules/programs/nvf/visual.nix diff --git a/systems/modules/fonts/terminess.nix b/systems/modules/fonts/terminess.nix index 078395b..46b6bc0 100644 --- a/systems/modules/fonts/terminess.nix +++ b/systems/modules/fonts/terminess.nix @@ -7,9 +7,18 @@ nerd-fonts.terminess-ttf ]; stylix.fonts = { - serif = config.stylix.fonts.monospace; - sansSerif = config.stylix.fonts.monospace; - emoji = config.stylix.fonts.monospace; + serif = { + package = pkgs.nerd-fonts.terminess-ttf; + name = "Terminess Nerd Font"; + }; + sansSerif = { + package = pkgs.nerd-fonts.terminess-ttf; + name = "Terminess Nerd Font"; + }; + emoji = { + package = pkgs.nerd-fonts.terminess-ttf; + name = "Terminess Nerd Font"; + }; monospace = { package = pkgs.nerd-fonts.terminess-ttf; name = "Terminess Nerd Font Mono"; diff --git a/users/modules/programs/nvf.nix b/users/modules/programs/nvf.nix index a5a44a2..e40147c 100644 --- a/users/modules/programs/nvf.nix +++ b/users/modules/programs/nvf.nix @@ -1,58 +1,26 @@ {inputs, ...}: { imports = [ inputs.nvf.homeManagerModules.default - ./nvf/blink-cmp.nix - ./nvf/conform-nvim.nix - ./nvf/languages/nix.nix - ./nvf/lualine.nix - ./nvf/noice.nix + ./nvf/options.nix + ./nvf/keymaps.nix + ./nvf/lsp.nix + ./nvf/debugger.nix + ./nvf/languages.nix + ./nvf/visual.nix + ./nvf/input.nix + ./nvf/filetree.nix + ./nvf/search.nix + ./nvf/utilities.nix + ./nvf/notes.nix ]; home.sessionVariables.EDITOR = "nvim"; programs.nvf = { enable = true; enableManpages = true; - settings.vim = { - options = { - # Indentation - autoindent = true; - smartindent = true; - expandtab = true; - smarttab = true; - wrap = false; - shiftwidth = 2; - tabstop = 2; - foldlevel = 1000; # Open all folds by default - - # Search - hlsearch = true; - ignorecase = true; - incsearch = true; - smartcase = true; # case-sensitive if search contains uppercase - - # Visual - number = true; - relativenumber = true; - cursorline = true; - visualbell = true; - termguicolors = true; - - # Input - backspace = "indent,eol,start"; - }; - keymaps = [ - { - key = "gf"; - mode = "n"; - action = ":cd %:p:h:e "; - silent = true; - } - ]; - languages = { - enableFormat = true; - enableLSP = true; - enableTreesitter = true; - }; + viAlias = true; + vimAlias = true; + spellcheck.enable = true; }; }; } diff --git a/users/modules/programs/nvf/debugger.nix b/users/modules/programs/nvf/debugger.nix new file mode 100644 index 0000000..2408f21 --- /dev/null +++ b/users/modules/programs/nvf/debugger.nix @@ -0,0 +1,32 @@ +{ + programs.nvf.settings.vim.debugger.nvim-dap = { + # nvim-dap enables debugging + # you can set breakpoints and step through code or use a REPL + enable = true; + mappings = { + # default mappings: + # - Continue:dc + # - Go down stacktrace:dvi + # - Go up stacktrace:dvo + # - Hover:dh + # - Restart:dR + # - Re-run Last Debug Session:d. + # - Continue to the current cursor:dgc + # - Step back:dgk + # - Step into function:dgi + # - Step out of function:dgo + # - Next step:dgj + # - Terminate:dq + # - Toggle breakpoint:db + # - Toggle DAP-UI:du + # - Toggle Repl:dr + }; + # list of debuggers to install + sources = {}; + # install nvim-dap-ui which provides a debugging ui + ui = { + enable = true; + setupOpts = {}; + }; + }; +} diff --git a/users/modules/programs/nvf/filetree.nix b/users/modules/programs/nvf/filetree.nix new file mode 100644 index 0000000..fc916f1 --- /dev/null +++ b/users/modules/programs/nvf/filetree.nix @@ -0,0 +1,17 @@ +{ + programs.nvf.settings.vim.filetree = { + # press ? in the tree view for a list of keybindings + # < and > to switch sources + # backspace to go up one level + neo-tree = { + enable = true; + setupOpts = { + enable_cursor_hijack = true; # keep the cursor on the first char + }; + }; + # TODO: add keymap for :NeoTree action=show position=right toggle=true reveal=true + # action=show is to not focus the window + # toggle will toggle the window + # reveal will find and focus the current file + }; +} diff --git a/users/modules/programs/nvf/git.nix b/users/modules/programs/nvf/git.nix new file mode 100644 index 0000000..2c63c08 --- /dev/null +++ b/users/modules/programs/nvf/git.nix @@ -0,0 +1,2 @@ +{ +} diff --git a/users/modules/programs/nvf/input.nix b/users/modules/programs/nvf/input.nix new file mode 100644 index 0000000..f8f14a6 --- /dev/null +++ b/users/modules/programs/nvf/input.nix @@ -0,0 +1,44 @@ +{ + programs.nvf.settings.vim = { + autopairs = { + nvim-autopairs.enable = true; + }; + autocomplete = { + enableSharedCmpSources = true; + blink-cmp = { + enable = true; + friendly-snippets.enable = true; + mappings = { + # default mappings: + # - Close [blink.cmp]: + # - Complete [blink.cmp]: + # - Confirm [blink.cmp]: + # - Next item [blink.cmp]: + # - Previous item [blink.cmp]: + # - Scroll docs down [blink.cmp]: + # - Scroll docs up [blink.cmp]: + }; + setupOpts = { + cmdline.sources = null; # use default source list + completion.documentation.auto_show_delay_ms = 0; + signature.enabled = true; + }; + }; + nvim-cmp = {}; + }; + # enable code snippets using luasnip + # loads from vscode by default using friendly-snippets + snippets.luasnip = { + enable = true; + setupOpts = { + enable_autosnippets = true; + }; + }; + binds = { + # cheatsheet.nvim provides cheatsheets with fuzzy finding with ? + cheatsheet.enable = true; + # whichkey provides a popup window with hotkeys + whichKey.enable = true; + }; + }; +} diff --git a/users/modules/programs/nvf/keymaps.nix b/users/modules/programs/nvf/keymaps.nix new file mode 100644 index 0000000..1fa331e --- /dev/null +++ b/users/modules/programs/nvf/keymaps.nix @@ -0,0 +1,10 @@ +{ + programs.nvf.settings.vim.keymaps = [ + { + key = "gf"; + mode = "n"; + action = ":cd %:p:h:e "; + silent = true; + } + ]; +} diff --git a/users/modules/programs/nvf/languages.nix b/users/modules/programs/nvf/languages.nix new file mode 100644 index 0000000..77bac3f --- /dev/null +++ b/users/modules/programs/nvf/languages.nix @@ -0,0 +1,13 @@ +{ + programs.nvf.settings.vim.languages = { + # The below settings enable defaults for all languages + enableDAP = true; + enableExtraDiagnostics = true; + enableFormat = true; + enableLSP = true; + enableTreesitter = true; + + # Enable specific languages + nix.enable = true; + }; +} diff --git a/users/modules/programs/nvf/languages/nix.nix b/users/modules/programs/nvf/languages/nix.nix index 587f38a..373b2f5 100644 --- a/users/modules/programs/nvf/languages/nix.nix +++ b/users/modules/programs/nvf/languages/nix.nix @@ -1,8 +1,13 @@ -{ +{pkgs, ...}: { + home.packages = [pkgs.nixd]; programs.nvf.settings.vim.languages.nix = { enable = true; - lsp = { - server = "nixd"; - }; + # lsp = { + # server = "nixd"; + # options = { + # nixpkgs.expr = ''(builtins.getFlake ("git+file://" + toString ./.)).inputs.nixpkgs''; + # options.nixos.expr = ''(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.${builtins.getEnv "HOSTNAME"}.options''; + # }; + # }; }; } diff --git a/users/modules/programs/nvf/lsp.nix b/users/modules/programs/nvf/lsp.nix new file mode 100644 index 0000000..d35b0d8 --- /dev/null +++ b/users/modules/programs/nvf/lsp.nix @@ -0,0 +1,119 @@ +{ + programs.nvf.settings.vim.lsp = { + # enable is automatically set by null-ls and lspconfig options + # enable = true; + formatOnSave = true; + # lightbulb shows a lightbulb when code actions are available + # TODO: Look into code actions and how to enable them with telescope + lightbulb = { + enable = true; + setupOpts = {}; + }; + # ls-signature shows a small signature for functions etc + # TODO: Look into configuring this + # does not work with blink cmp + lspSignature = { + enable = false; + setupOpts = {}; + }; + # lspconfig should be enabled and configured automatically + lspconfig = { + enable = true; + sources = {}; # strings for snippet sources? + }; + # lspkind provides vs code like icons for signatures + lspkind = { + enable = true; + setupOpts = { + # call before lspkind modifications are applied + before = null; # takes luainline + # defines orders of symbols shown, e.g. text_symbol or symbol + mode = "symbol_text"; + }; + }; + # lsplines moves diagnostics to virtual lines after the actual line + lsplines.enable = true; # TODO: add a keymap to toggle this + # lspsaga provides many features: + # - breadcrumbs: provides trace to current symbol at top + # - callhierarchy: provides a list of the call hierarchy + # - code actions: shows a list of available code actions + # - definition: peek or go to definitions + # - diagnostic: jump around the diagnostics in the file and see the diagnostic in a floating window + # - finder: search for references etc + # - float terminal: open a floating terminal + # - hover: opens a floating docs window + # - implement: see interfaces + # - lightbulb: same as lightbulb + # - outline: see entire file outline + # - rename: change all occurrences + # - ui beacon: highlight the cursor + # default keybinds: + # - codeAction "ca" + # - lspFinder "lf" + # - nextDiagnostic "ln" + # - previewDefinition "ld" + # - previousDiagnostic "lp" + # - rename "lr" + # - renderHoveredDoc "lh" + # - showCursorDiagnostics "lc" + # - showLineDiagnostics "ll" + # - signatureHelp "ls" + # - smartScrollDown "" + # - smartScrollUp "" + lspsaga.enable = false; + # null-ls exposes nvim as a language server, also used automatically + null-ls = { + enable = true; + sources = {}; + }; + # nvim-docs-view provides documentation in the side panel + nvim-docs-view = { + enable = true; + # default mappings: + # - viewToggle "lvt" + # - viewUpdate "lvu" + mappings = {}; + setupOpts = {}; + }; + # otter-nvim allows embedding code in other documents + otter-nvim = { + enable = true; + mappings.toggle = "lo"; # default + setupOpts = {}; + }; + # trouble.nvim shows diagnostics and search results + trouble = { + enable = true; + # default mappings: + # - documentDiagnostics "ld" + # - locList "xl" + # - lspReferences "lr" + # - quickfix "xq" + # - symbols "xs" + # - workspaceDiagnostics "lwd" + mappings = {}; + setupOpts = {}; + }; + # default mappings for lsp: + # - addWorkspaceFolder "lwa" + # - codeAction "la" + # - documentHighlight "lH" + # - format "lf" + # - goToDeclaration "lgD" + # - goToDefinition "lgd" + # - goToType "lgt" + # - hover "lh" + # - listDocumentSymbols "lS" + # - listImplementations "lgi" + # - listReferences "lgr" + # - listWorkspaceFolders "lwl" + # - listWorkspaceSymbols "lws" + # - nextDiagnostic "lgn" + # - openDiagnosticFloat "le" + # - previousDiagnostic "lgp" + # - removeWorkspaceFolder "lwr" + # - renameSymbol "ln" + # - signatureHelp "ls" + # - toggleFormatOnSave "ltf" + }; +} diff --git a/users/modules/programs/nvf/notes.nix b/users/modules/programs/nvf/notes.nix new file mode 100644 index 0000000..bf3a0f9 --- /dev/null +++ b/users/modules/programs/nvf/notes.nix @@ -0,0 +1,11 @@ +{ + programs.nvf.settings.vim.notes = { + # TODO: look into mind nvim + # todo-comments provides quick search for keywords like TODO + # default mappings + # - Open Todo-s in a quickfix list:tdq + # - Open Todo-s in telescope:tds + # - Open Todo-s in Trouble:tdt + todo-comments.enable = true; + }; +} diff --git a/users/modules/programs/nvf/options.nix b/users/modules/programs/nvf/options.nix new file mode 100644 index 0000000..d7e3e0a --- /dev/null +++ b/users/modules/programs/nvf/options.nix @@ -0,0 +1,31 @@ +{ + programs.nvf.settings.vim = { + options = { + # Indentation + autoindent = true; + smartindent = true; + expandtab = true; + smarttab = true; + wrap = false; + shiftwidth = 2; + tabstop = 2; + foldlevel = 1000; # Open all folds by default + + # Search + hlsearch = true; + ignorecase = true; + incsearch = true; + smartcase = true; # case-sensitive if search contains uppercase + + # Visual + number = true; + relativenumber = true; + cursorline = true; + visualbell = true; + termguicolors = true; + + # Input + backspace = "indent,eol,start"; + }; + }; +} diff --git a/users/modules/programs/nvf/search.nix b/users/modules/programs/nvf/search.nix new file mode 100644 index 0000000..36e0062 --- /dev/null +++ b/users/modules/programs/nvf/search.nix @@ -0,0 +1,29 @@ +{ + programs.nvf.settings.vim.telescope = { + enable = true; + mappings = { + # default mappings + # - Buffers [Telescope]:fb + # - Diagnostics [Telescope]:fld + # - Find files [Telescope]:ff + # - Find projects [Telescope]:fp + # - Git branches [Telescope]:fvb + # - Git buffer commits [Telescope]:fvcb + # - Git commits [Telescope]:fvcw + # - Git stash [Telescope]:fvx + # - Git status [Telescope]:fvs + # - Help tags [Telescope]:fh + # - Live grep [Telescope]:fg + # - LSP Definitions [Telescope]:flD + # - LSP Document Symbols [Telescope]:flsb + # - LSP Implementations [Telescope]:fli + # - LSP References [Telescope]:flr + # - LSP Type Definitions [Telescope]:flt + # - LSP Workspace Symbols [Telescope]:flsw + # - Open [Telescope]:ft + # - Resume (previous search) [Telescope]:fr + # - Treesitter [Telescope]:fs + }; + setupOpts = {}; + }; +} diff --git a/users/modules/programs/nvf/utilities.nix b/users/modules/programs/nvf/utilities.nix new file mode 100644 index 0000000..861abd5 --- /dev/null +++ b/users/modules/programs/nvf/utilities.nix @@ -0,0 +1,89 @@ +{ + programs.nvf.settings.vim = { + projects.project-nvim.enable = true; + utility = { + # ccc is a colour picker + ccc.enable = true; + # diffview-nvim lets you easily go through diffs for a given rev + diffview-nvim.enable = true; + # direnv.vim syncs the nvim shell environment with direnv + direnv.enable = true; + # icon-picker gives you a way to pick icons from nerd fonts + # TODO: find out keybinds + icon-picker.enable = true; + # image rendering + # TODO: look into image-magick and if it is needed + images.image-nvim.enable = true; + # leetcode + leetcode-nvim = { + enable = true; + setupOpts = { + image_support = true; # requires image.nvim + lang = "rust"; + }; + }; + # mkdir.nvim creates directory when the path doesnt exist + mkdir.enable = true; + motion = { + hop.enable = true; # h + leap.enable = true; + leap.mappings = { + # default mappings + # - Leap backward till:sX + # - Leap backward to:sS + # - Leap forward till:sx + # - Leap forward to:ss + # - Leap from window:gs + }; + # precognition.nvim shows hints for motions + precognition = { + enable = true; + setupOpts = { + # TODO: may want to fix dashboard + }; + }; + }; + # multicursors.nvim enables vscode like multicursors + multicursors.enable = true; + # new-file-template.nvim automatically inserts templates in new files + new-file-template = { + enable = true; + # add a directory containing lua/tempaltes/*.lua to vim.additionalRuntimePaths + # TODO: add for nix + }; + # allows usage of nix commands in nvim + nix-develop.enable = true; + # aerial.nvim shows a preview of your entire code file + outline.aerial-nvim.enable = true; # "g0" + # glow.nvim displays a floating window with a markdown preview + preview.glow.enable = true; # "p" + # nvim-surround allows you to easily surround and delete words or phrases + surround.enable = true; + # vim-wakatime allows sending statistics to wakatime or a compatible backend vim-wakatime.enable = true; + # yanky allows cycling through yank history when putting text + yanky-nvim.enable = true; + # yazi-nvim gives integration with yazi + # default mappings: + # - Open yazi at the current file [yazi.nvim]:- + # - Open the file manager in nvim’s working directory [yazi.nvim]:cw + # - Resume the last yazi session [yazi.nvim]: + yazi-nvim.enable = true; + yazi-nvim.setupOpts.open_for_directories = true; # FIXME: does this work with neotree? + }; + # TODO: look into terminal integration + terminal.toggleterm.enable = true; + terminal.toggleterm.lazygit.enable = true; + # nvim session manager manages sessions like folders in vscode + session.nvim-session-manager = { + enable = true; + mappings = { + # default mappings: + # - Delete session:sd + # - Load last session:slt + # - Load session:sl + # - Save current session:sc + }; + }; + comments.comment-nvim.enable = true; + }; +} diff --git a/users/modules/programs/nvf/visual.nix b/users/modules/programs/nvf/visual.nix new file mode 100644 index 0000000..f927197 --- /dev/null +++ b/users/modules/programs/nvf/visual.nix @@ -0,0 +1,130 @@ +{ + programs.nvf.settings.vim = { + visuals = { + # fidget.nvim shows messages in the bottom right + fidget-nvim = { + enable = true; + setupOpts = {}; + }; + # highlight-undo.nvim highlights what text was changed when performing an action that modifies the buffer while not in insert mode + highlight-undo = { + enable = true; + setupOpts = { + duration = 100; # in ms + }; + }; + # indent-blankline.nvim adds indentation guides + indent-blankline = { + enable = true; + setupOpts = {}; + }; + # nvim-cursorline provides cursor word and line highlighting + nvim-cursorline = { + enable = true; + setupOpts = { + cursorword.enable = true; + cursorline.enable = false; + }; + }; + nvim-scrollbar.enable = true; + rainbow-delimiters.enable = true; + nvim-web-devicons.enable = true; + tiny-devicons-auto-colors.enable = true; + }; + statusline.lualine = { + enable = true; + }; + tabline.nvimBufferline = { + enable = true; + mappings = { + # default mappings: + # - Close buffer:null + # - Next buffer:bn + # - Previous buffer:bp + # - Move next buffer:bmn + # - Move previous buffer:bmp + # - Pick buffer:bc + # - Sort buffers by directory:bsd + # - Sort buffers by extension:bse + # - Sort buffers by ID:bsi + closeCurrent = ""; + # TODO: check these mappigns + # cycleNext = ""; + # cyclePrevious = ""; + }; + setupOpts = {}; + }; + # treesitter handles syntax highlighting + treesitter = { + enable = true; + autotagHtml = true; + fold = true; + # provide context for current scope + context = { + enable = true; + setupOpts = { + mode = "topline"; + }; + }; + mappings.incrementalSelection = { + # - Decrement selection by node [treesitter]:grm + # - Increment selection by node [treesitter]:grn + # - Increment selection by scope [treesitter]:grc + # - Init selection [treesitter]:gnn + }; + }; + git = { + enable = true; + # gitsigns indicates added, changed, deleted lines among other things + gitsigns.mappings = { + # - Blame line [Gitsigns]:hb + # - Diff project [Gitsigns]:hD + # - Diff this [Gitsigns]:hd + # - Next hunk [Gitsigns]:]c + # - Preview hunk [Gitsigns]:hP + # - Previous hunk [Gitsigns]:[c + # - Reset buffer [Gitsigns]:hR + # - Reset hunk [Gitsigns]:hr + # - Stage buffer [Gitsigns]:hS + # - Stage hunk [Gitsigns]:hs + # - Toggle blame [Gitsigns]:tb + # - Toggle deleted [Gitsigns]:td + # - Undo stage hunk [Gitsigns]:hu + }; + # git-conflict visualises git conflicts and resolves + git-conflict.mappings = { + # Default mappings: + # - Choose Both [Git-Conflict]:cb + # - Go to the next Conflict [Git-Conflict]:[x + # - Choose None [Git-Conflict]:c0 + # - Choose Ours [Git-Conflict]:co + # - Go to the previous Conflict [Git-Conflict]:]x + # - Choose Theirs [Git-Conflict]:ct + }; + # vim-fugitive provides git cmds + }; + dashboard.alpha.enable = true; + notify.nvim-notify.enable = true; + ui = { + borders.enable = true; # TODO: enable plugin specific + breadcrumbs.enable = true; + breadcrumbs.navbuddy.enable = true; # nvim-navic + # nvim-colorizer highlights color codes + colorizer.enable = true; # TODO: check if it works + # fastaction.nvim overrides vim.ui.select with fast action + # TODO: look into this + fastaction.enable = true; + # vim-illuminate highlights all occurrences + illuminate.enable = true; # TOOD: check if neotree is covered + # modes-nvim colors the whole line + modes-nvim.enable = true; + # noice displays the command window in a floating window and disables the cmd line + # TODO: look at the options + noice.enable = true; + # nvim-ufo makes folds look nicer + nvim-ufo.enable = true; + # smartcolumn enables line length indicators + smartcolumn.enable = true; + }; + }; +} diff --git a/users/modules/utils.nix b/users/modules/utils.nix index 89877ac..937cc56 100644 --- a/users/modules/utils.nix +++ b/users/modules/utils.nix @@ -3,6 +3,8 @@ fastfetch # system info wl-clipboard # provides cli copy and paste commands aichat # duh + ripgrep + ueberzugpp # image rendering backend for the terminal ]; services = {