diff --git a/home/christoph/default.nix b/home/christoph/default.nix index 34f8f5d6..929b5b16 100644 --- a/home/christoph/default.nix +++ b/home/christoph/default.nix @@ -468,12 +468,8 @@ rec { # p.matplotlib # p.pillow # for ranger # p.pygments # for emacs - - # For nvim CHADtree - pyyaml - std2 - pynvim - pynvim-pp + # flake8 # Linter + # black ])) jetbrains.clion jetbrains.rust-rover diff --git a/home/modules/neovim/default.nix b/home/modules/neovim/default.nix index 6252c330..f6db7d04 100644 --- a/home/modules/neovim/default.nix +++ b/home/modules/neovim/default.nix @@ -25,51 +25,74 @@ in { [ (pkgs.ripgrep.override {withPCRE2 = true;}) + # Dependencies + lua51Packages.lua-curl # For rest + lua51Packages.xml2lua # For rest + lua51Packages.mimetypes # For rest + lua51Packages.jsregexp # For tree-sitter + + # Language servers + clang-tools_18 + clojure-lsp + cmake-language-server + haskell-language-server + lua-language-server + nil + pyright + rust-analyzer + texlab + # Linters - clippy # rust checkstyle # java + clippy # rust clj-kondo # clojure eslint_d # javascript - python312Packages.flake8 + python311Packages.flake8 + lua51Packages.luacheck vale # text statix # nix # Formatters alejandra # nix + python311Packages.black google-java-format html-tidy jq # json prettierd # html/css/js - # rustfmt - # clang-tools + rustfmt + stylua ] ]; - # NOTE: Use nixvim.extraConfigLua configuration - # home.file.".config/neovide/config.toml".text = '' - # [font] - # normal = ["JetBrainsMono Nerd Font Mono"] # Will use the bundled Fira Code Nerd Font by default - # size = 13.0 - # - # fork = true - # frame = "full" # full, buttonless, none - # idle = true - # maximized = false - # # neovim-bin = "/usr/bin/nvim" # in reality found dynamically on $PATH if unset - # no-multigrid = false - # srgb = false - # tabs = true - # theme = "light" - # title-hidden = true - # vsync = true - # wsl = false - # ''; + home.file.".config/neovide/config.toml".text = '' + fork = true # Start neovide detached + frame = "none" # full, buttonless, none + idle = true # Don't render frames without changes + # maximized = true + title-hidden = true + # vsync = true + ''; + + home.file.".config/vale/.vale.ini".text = '' + # Core settings appear at the top + # (the "global" section). + + [formats] + # Format associations appear under + # the optional "formats" section. + + [*] + # Format-specific settings appear + # under a user-provided "glob" + # pattern. + ''; programs.nixvim = { enable = true; defaultEditor = true; enableMan = true; - # colorschemes.catppuccin.enable = true; # NOTE: Managed using Lazy + luaLoader.enable = true; # NOTE: Experimental + # colorschemes.catppuccin.enable = true; # Managed using Lazy viAlias = cfg.alias; vimAlias = cfg.alias; @@ -139,58 +162,11 @@ in { splitright = true; }; - extraConfigLuaPost = '' - local opt = vim.opt - local g = vim.g - local o = vim.o + extraConfigLuaPost = builtins.readFile ./extraConfigLuaPost.lua; - -- Neovide - if g.neovide then - -- require("notify").notify("Running in NeoVide") + extraConfigLua = builtins.readFile ./extraConfigLua.lua; - g.neovide_cursor_animate_command_line = true - g.neovide_cursor_animate_in_insert_mode = true - g.neovide_fullscreen = false - g.neovide_hide_mouse_when_typing = false - g.neovide_padding_top = 0 - g.neovide_padding_bottom = 0 - g.neovide_padding_right = 0 - g.neovide_padding_left = 0 - g.neovide_refresh_rate = 144 - g.neovide_theme = 'light' - - -- Neovide Fonts - o.guifont = "JetBrainsMono Nerd Font:h13:Medium" - else - -- require("notify").notify("Not running in NeoVide") - end - ''; - - extraConfigLua = '' - -- Hide inline diagnostics and show border - vim.diagnostic.config({ - virtual_text = false, - float = { border = "rounded" } - }) - - -- Allow navigating popupmenu completion with Up/Down - vim.api.nvim_set_keymap('c', '', 'v:lua.get_wildmenu_key("", "")', { expr = true }) - vim.api.nvim_set_keymap('c', '', 'v:lua.get_wildmenu_key("", "")', { expr = true }) - - function _G.get_wildmenu_key(key_wildmenu, key_regular) - return vim.fn.wildmenumode() ~= 0 and key_wildmenu or key_regular - end - ''; - - extraLuaPackages = with pkgs.lua51Packages; [ - # TODO: Doesn't work - # For rest - # lua-curl - # xml2lua - # mimetypes - - jsregexp # For tree-sitter - ]; + extraLuaPackages = with pkgs.lua51Packages; []; extraPython3Packages = p: [ # For CHADtree @@ -205,6 +181,10 @@ in { # pattern = "*"; callback = {__raw = "function() require('lint').try_lint() end";}; } + { + event = ["BufWritePre"]; + callback = {__raw = "function() require('conform').format() end";}; + } ]; # TODO: Toggle wrapping @@ -212,886 +192,500 @@ in { # TODO: Toggle format on paste keymaps = import ./keybinds.nix {inherit lib mylib;}; - ################################################################################################################################## - # Lazy Plugins # - ################################################################################################################################## plugins.lazy = { enable = true; - # TODO: Would be nicer if large dependencies could be referenced by name - plugins = [ - # - # Not available in NixVim - # + plugins = builtins.concatLists [ + (import ./interface.nix {inherit lib mylib pkgs;}) + (import ./languages.nix {inherit lib mylib pkgs;}) + [ + # + # Theme + # - { - name = "catppuccin"; - pkg = pkgs.vimPlugins.catppuccin-nvim; - lazy = false; - priority = 1000; - config = '' - function(_, opts) - require("catppuccin").setup(opts) + { + name = "catppuccin"; + pkg = pkgs.vimPlugins.catppuccin-nvim; + lazy = false; + priority = 1000; + config = '' + function(_, opts) + require("catppuccin").setup(opts) - vim.cmd([[ - let $BAT_THEME = "catppuccin" - colorscheme catppuccin - ]]) - end - ''; - opts = { - flavour = "mocha"; # latte, frappe, macchiato, mocha - background = { - light = "latte"; - dark = "mocha"; + vim.cmd([[ + let $BAT_THEME = "catppuccin" + colorscheme catppuccin + ]]) + end + ''; + opts = { + flavour = "mocha"; # latte, frappe, macchiato, mocha + background = { + light = "latte"; + dark = "mocha"; + }; }; - }; - } + } - { - name = "lspconfig"; - pkg = pkgs.vimPlugins.nvim-lspconfig; - dependencies = [ - { - name = "cmp"; - pkg = pkgs.vimPlugins.nvim-cmp; - dependencies = [ - { - name = "cmp-async-path"; - pkg = pkgs.vimPlugins.cmp-async-path; - } - { - name = "cmp-buffer"; - pkg = pkgs.vimPlugins.cmp-buffer; - enabled = false; - } - { - name = "cmp-cmdline"; - pkg = pkgs.vimPlugins.cmp-cmdline; - enabled = false; - } - { - name = "cmp-emoji"; - pkg = pkgs.vimPlugins.cmp-emoji; - } - { - name = "cmp-nvim-lsp"; - pkg = pkgs.vimPlugins.cmp-nvim-lsp; - } - { - name = "cmp-nvim-lsp-signature-help"; - pkg = pkgs.vimPlugins.cmp-nvim-lsp-signature-help; - } - { - name = "cmp-luasnip"; - pkg = pkgs.vimPlugins.cmp_luasnip; - } + { + name = "web-devicons"; + pkg = pkgs.vimPlugins.nvim-web-devicons; + lazy = false; + config = '' + function(_, opts) + require("nvim-web-devicons").setup(opts) + end + ''; + } + + # + # Plugins + # + + { + name = "better-escape"; + pkg = pkgs.vimPlugins.better-escape-nvim; + lazy = false; + config = '' + function(_, opts) + require("better_escape").setup(opts) + end + ''; + opts = { + mapping = ["jk"]; + timeout = 200; # In ms + }; + } + + { + name = "chadtree"; + pkg = pkgs.vimPlugins.chadtree; + config = '' + function(_, opts) + vim.api.nvim_set_var("chadtree_settings", opts) + end + ''; + opts = { + theme.text_colour_set = "nerdtree_syntax_dark"; + xdg = true; + }; + } + + { + name = "cmp"; + pkg = pkgs.vimPlugins.nvim-cmp; + dependencies = [ + { + name = "cmp-async-path"; + pkg = pkgs.vimPlugins.cmp-async-path; + } + { + name = "cmp-buffer"; + pkg = pkgs.vimPlugins.cmp-buffer; + enabled = false; + } + { + name = "cmp-cmdline"; + pkg = pkgs.vimPlugins.cmp-cmdline; + enabled = false; + } + { + name = "cmp-emoji"; + pkg = pkgs.vimPlugins.cmp-emoji; + } + { + name = "cmp-nvim-lsp"; + pkg = pkgs.vimPlugins.cmp-nvim-lsp; + } + { + name = "cmp-nvim-lsp-signature-help"; + pkg = pkgs.vimPlugins.cmp-nvim-lsp-signature-help; + } + { + name = "cmp-luasnip"; + pkg = pkgs.vimPlugins.cmp_luasnip; + } + ]; + lazy = false; + config = '' + function(_, opts) + require("cmp").setup(opts) + end + ''; + opts = let + sources = mylib.generators.toLuaObject [ + {name = "async_path";} + # {name = "buffer";} + # {name = "cmdline";} + {name = "emoji";} + {name = "nvim_lsp";} + {name = "nvim_lsp_signature_help";} + {name = "luasnip";} ]; - lazy = false; - config = '' - function(_, opts) - require("cmp").setup(opts) - end - ''; - opts = let - sources = mylib.generators.toLuaObject [ - {name = "async_path";} - # {name = "buffer";} - # {name = "cmdline";} - {name = "emoji";} - {name = "nvim_lsp";} - {name = "nvim_lsp_signature_help";} - {name = "luasnip";} - ]; - in { - __raw = '' - function() - local cmp = require("cmp") - local luasnip = require("luasnip") + in { + __raw = '' + function() + local cmp = require("cmp") + local luasnip = require("luasnip") - local has_words_before = function() - unpack = unpack or table.unpack - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil - end - - return { - sources = cmp.config.sources(${sources}), - - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - -- completion.border = "rounded", - -- documentation.border = "rounded", - }, - - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), - [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), - [""] = cmp.mapping.abort(); - [""] = cmp.mapping.abort(); - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete({}), - - [""] = cmp.mapping.confirm({ select = true }), - - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif require("luasnip").expand_or_jumpable() then - require("luasnip").expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }), - } + local has_words_before = function() + unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil end - ''; - }; - } - { - name = "illuminate"; - pkg = pkgs.vimPlugins.vim-illuminate; - lazy = false; - config = '' - function(_, opts) - require("illuminate").configure(opts) - end - ''; - opts = { - filetypesDenylist = [ - "DressingSelect" - "Outline" - "TelescopePrompt" - "alpha" - "harpoon" - "toggleterm" - "neo-tree" - "Spectre" - "reason" - ]; - }; - } - # { - # name = "inc-rename"; - # pkg = pkgs.vimPlugins.inc-rename-nvim; - # config = '' - # function(_, opts) - # require("inc_rename").setup(opts) - # end - # ''; - # } - ]; - lazy = false; - config = let - servers = mylib.generators.toLuaObject [ - {name = "cmake";} - {name = "clojure_lsp";} - {name = "clangd";} - {name = "texlab";} - {name = "rust_analyzer";} - {name = "pyright";} - {name = "nil_ls";} - { - name = "hls"; - cmd = [ - "haskell-language-server-wrapper" - "--lsp" - ]; - } - ]; - in '' - function(_, opts) - local __lspOnAttach = function(client, bufnr) end + return { + sources = cmp.config.sources(${sources}), - local __lspCapabilities = function() - capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) - return capabilities - end + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, - local __setup = { - on_attach = __lspOnAttach, - capabilities = __lspCapabilities(), - } + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + -- completion.border = "rounded", + -- documentation.border = "rounded", + }, - for i, server in ipairs(${servers}) do - if type(server) == "string" then - require("lspconfig")[server].setup(__setup) - else - local options = server.extraOptions + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), + [""] = cmp.mapping.abort(); + [""] = cmp.mapping.abort(); + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete({}), - if options == nil then - options = __setup - else - options = vim.tbl_extend("keep", options, __setup) + [""] = cmp.mapping.confirm({ select = true }), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + require("luasnip").expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + } end - - require("lspconfig")[server.name].setup(options) - end - end - end - ''; - } - - { - name = "web-devicons"; - pkg = pkgs.vimPlugins.nvim-web-devicons; - lazy = false; - config = '' - function(_, opts) - require("nvim-web-devicons").setup(opts) - end - ''; - } - - # - # Also available in NixVim - # - - { - name = "better-escape"; - pkg = pkgs.vimPlugins.better-escape-nvim; - lazy = false; - config = '' - function(_, opts) - require("better_escape").setup(opts) - end - ''; - opts = { - mapping = ["jk"]; - timeout = 200; # In ms - }; - } - - { - name = "chadtree"; - pkg = pkgs.vimPlugins.chadtree; - config = '' - function(_, opts) - vim.api.nvim_set_var("chadtree_settings", opts) - end - ''; - opts = { - theme.text_colour_set = "nerdtree_syntax_dark"; - xdg = true; - }; - } - - { - name = "comment"; - pkg = pkgs.vimPlugins.comment-nvim; - dependencies = [ - { - name = "ts-context-commentstring"; - pkg = pkgs.vimPlugins.nvim-ts-context-commentstring; - lazy = false; - config = '' - function(_, opts) - vim.g.skip_ts_context_commentstring_module = true -- Skip compatibility checks - - require("ts_context_commentstring").setup(opts); - end ''; - } - ]; - config = '' - function(_, opts) - require("Comment").setup(opts) - end - ''; - opts = { - pre_hook = {__raw = "function() require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook() end";}; - - mappings.basic = true; # Apparently required for opleader/toggler config - mappings.extra = false; - opleader.line = ""; - toggler.line = ""; - opleader.block = ""; - toggler.block = ""; - }; - } - - { - name = "conform"; - pkg = pkgs.vimPlugins.conform-nvim; - config = '' - function(_, opts) - require("conform").setup(opts) - end - ''; - opts = { - formatters_by_ft = { - c = ["clang-format"]; - h = ["clang-format"]; - cpp = ["clang-format"]; - hpp = ["clang-format"]; - css = [["prettierd" "prettier"]]; - html = [["prettierd" "prettier"]]; - java = ["google-java-format"]; - javascript = [["prettierd" "prettier"]]; - markdown = [["prettierd" "prettier"]]; - nix = ["alejandra"]; - python = ["black"]; - rust = ["rustfmt"]; }; - }; - } + } - # TODO: Config - { - name = "flash"; - pkg = pkgs.vimPlugins.flash-nvim; - config = '' - function(_, opts) - require("flash").setup(opts) - end - ''; - } - - { - name = "gitmessenger"; - pkg = pkgs.vimPlugins.git-messenger-vim; - config = '' - function(_, opts) - for k, v in pairs(opts) do - vim.g[k] = v - end - end - ''; - opts = { - git_messenger_no_default_mappings = true; - git_messenger_floating_win_opts = { - border = "rounded"; - }; - }; - } - - { - name = "gitsigns"; - pkg = pkgs.vimPlugins.gitsigns-nvim; - lazy = false; - config = '' - function(_, opts) - require("gitsigns").setup(opts) - end - ''; - opts = { - current_line_blame = false; - }; - } - - { - name = "headlines"; - pkg = pkgs.vimPlugins.headlines-nvim; - config = '' - function(_, opts) - require("headlines").setup(opts) - end - ''; - } - - { - name = "intellitab"; - pkg = pkgs.vimPlugins.intellitab-nvim; - lazy = false; - } - - { - name = "lastplace"; - pkg = pkgs.vimPlugins.nvim-lastplace; - lazy = false; - config = '' - function(_, opts) - require("nvim-lastplace").setup(opts) - end - ''; - } - - { - name = "lazygit"; - pkg = pkgs.vimPlugins.lazygit-nvim; - } - - { - name = "lint"; - pkg = pkgs.vimPlugins.nvim-lint; - lazy = false; - config = '' - function(_, opts) - local lint = require("lint") - - for k, v in pairs(opts) do - lint[k] = v - end - end - ''; - opts = { - linters_by_ft = { - c = ["clang-tidy"]; - h = ["clang-tidy"]; - cpp = ["clang-tidy"]; - hpp = ["clang-tidy"]; - clojure = ["clj-kondo"]; - java = ["checkstyle"]; - javascript = ["eslint_d"]; - markdown = ["vale"]; - nix = ["statix"]; - python = ["flake8"]; - rust = ["clippy"]; - text = ["vale"]; - }; - }; - } - - { - name = "lualine"; - pkg = pkgs.vimPlugins.lualine-nvim; - lazy = false; - config = '' - function(_, opts) - require("lualine").setup(opts) - end - ''; - opts = { - extensions = ["fzf" "chadtree" "neo-tree" "toggleterm" "trouble"]; - - options = { - always_divide_middle = true; - globalstatus = true; - ignore_focus = ["neo-tree" "chadtree"]; - section_separators = { - left = ""; - right = ""; - # left = ""; - # right = ""; - }; - - component_separators = { - left = ""; - right = ""; - # left = ""; - # right = ""; - }; - }; - - sections = { - lualine_a = [ - { - name = "mode"; - # extraConfig = { - # separator = { - # left = ""; - # }; - # right_padding = "2"; - # }; - } - ]; - lualine_b = ["branch" "diff" "diagnostics"]; - lualine_c = [ - { - name = "filename"; - extraConfig = { - path = 1; - }; - } - ]; - - lualine_x = ["filetype" "encoding" "fileformat"]; - lualine_y = ["progress" "searchcount" "selectioncount"]; - lualine_z = [ - { - name = "location"; - # extraConfig = { - # separator = { - # right = ""; - # }; - # left_padding = "2"; - # }; - } - ]; - }; - - tabline = { - lualine_a = ["buffers"]; - lualine_z = ["tabs"]; - }; - }; - } - - # TODO: Snippet configs - { - name = "luasnip"; - pkg = pkgs.vimPlugins.luasnip; - config = '' - function(_, opts) - require("luasnip").config.set_config(opts) - end - ''; - } - - { - name = "navbuddy"; - pkg = pkgs.vimPlugins.nvim-navbuddy; - config = '' - function(_, opts) - local actions = require("nvim-navbuddy.actions") -- ? - require("nvim-navbuddy").setup(opts) - end - ''; - opts = { - lsp.auto_attach = true; - window.border = "rounded"; - }; - } - - # TODO: Doesn't show up - { - name = "navic"; - pkg = pkgs.vimPlugins.nvim-navic; - config = '' - function(_, opts) - require("nvim-navic").setup(opts) - end - ''; - opts = { - lsp.auto_attach = true; - click = true; - highlight = true; - }; - } - - { - name = "noice"; - pkg = pkgs.vimPlugins.noice-nvim; - dependencies = [ - { - name = "nui"; # For noice - pkg = pkgs.vimPlugins.nui-nvim; - lazy = false; - } - ]; - lazy = false; - config = '' - function(_, opts) - require("noice").setup(opts) - end - ''; - opts = { - presets = { - bottom_search = false; - command_palette = true; - long_message_to_split = true; - inc_rename = true; - lsp_doc_border = true; - }; - - lsp = { - documentation = { - opts = { - lang = "markdown"; - replace = true; - render = "plain"; - border = "rounded"; # single or rounded - format = ["{message}"]; - win_options = { - concealcursor = "n"; - conceallevel = 3; - }; - }; - view = "hover"; - }; - - override = { - "vim.lsp.util.convert_input_to_markdown_lines" = true; - "vim.lsp.util.stylize_markdown" = true; - "cmp.entry.get_documentation" = true; - }; - }; - - notify = { - enabled = true; - }; - - popupmenu = { - enabled = true; - backend = "nui"; # cmp completion is broken - }; - - # cmdline.enabled = false; - # messages.enabled = false; - - routes = [ - # Hide inline search count info + { + name = "comment"; + pkg = pkgs.vimPlugins.comment-nvim; + dependencies = [ { - filter = { - event = "msg_show"; - kind = "search_count"; - }; - opts = {skip = true;}; + name = "ts-context-commentstring"; + pkg = pkgs.vimPlugins.nvim-ts-context-commentstring; + lazy = false; + config = '' + function(_, opts) + vim.g.skip_ts_context_commentstring_module = true -- Skip compatibility checks + + require("ts_context_commentstring").setup(opts); + end + ''; } ]; - }; - } - - { - name = "notify"; - pkg = pkgs.vimPlugins.nvim-notify; - lazy = false; - config = '' - function(_, opts) - vim.notify = require("notify") - require("notify").setup(opts) - end - ''; - } - - { - name = "autopairs"; - pkg = pkgs.vimPlugins.nvim-autopairs; - lazy = false; - config = '' - function(_, opts) - require("nvim-autopairs").setup(opts) - end - ''; - } - - { - name = "colorizer"; - pkg = pkgs.vimPlugins.nvim-colorizer-lua; - lazy = false; - config = '' - function(_, opts) - require("colorizer").setup(opts) - end - ''; - opts = { - filtetypes = null; - user_default_options = null; - buftypes = null; - }; - } - - { - name = "ufo"; - pkg = pkgs.vimPlugins.nvim-ufo; - dependencies = [ - { - name = "promise"; - pkg = pkgs.vimPlugins.promise-async; - } - ]; - config = '' - function(_, opts) - require("ufo").setup(opts) - end - ''; - } - - { - name = "rainbow-delimiters"; - pkg = pkgs.vimPlugins.rainbow-delimiters-nvim; - lazy = false; - } - - { - name = "sandwich"; - pkg = pkgs.vimPlugins.vim-sandwich; - lazy = false; - } - - { - name = "sleuth"; - pkg = pkgs.vimPlugins.vim-sleuth; - lazy = false; - } - - { - name = "telescope"; - pkg = pkgs.vimPlugins.telescope-nvim; - dependencies = [ - { - name = "plenary"; # For telescope - pkg = pkgs.vimPlugins.plenary-nvim; - } - { - name = "telescope-undo"; - pkg = pkgs.vimPlugins.telescope-undo-nvim; - } - { - name = "telescope-ui-select"; - pkg = pkgs.vimPlugins.telescope-ui-select-nvim; - } - { - name = "telescope-fzf-native"; - pkg = pkgs.vimPlugins.telescope-fzf-native-nvim; - } - ]; - lazy = false; - config = let - extensions = mylib.generators.toLuaObject [ - "undo" - "ui-select" - "fzf" - ]; - in '' - function(_, opts) - local telescope = require("telescope") - telescope.setup(opts) - - for i, extension in ipairs(${extensions}) do - telescope.load_extension(extension) + config = '' + function(_, opts) + require("Comment").setup(opts) end - end - ''; - opts = { - defaults = { - mappings = { - i = { - "" = {__raw = ''function(...) return require("telescope.actions").close(...) end'';}; - }; + ''; + opts = { + pre_hook = {__raw = "function() require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook() end";}; + + mappings.basic = true; # Apparently required for opleader/toggler config + mappings.extra = false; + opleader.line = ""; + toggler.line = ""; + opleader.block = ""; + toggler.block = ""; + }; + } + + # TODO: Config + { + name = "flash"; + pkg = pkgs.vimPlugins.flash-nvim; + config = '' + function(_, opts) + require("flash").setup(opts) + end + ''; + } + + { + name = "gitmessenger"; + pkg = pkgs.vimPlugins.git-messenger-vim; + config = '' + function(_, opts) + for k, v in pairs(opts) do + vim.g[k] = v + end + end + ''; + opts = { + git_messenger_no_default_mappings = true; + git_messenger_floating_win_opts = { + border = "rounded"; }; }; - }; - } + } - { - name = "toggleterm"; - pkg = pkgs.vimPlugins.toggleterm-nvim; - lazy = false; - config = '' - function(_, opts) - require("toggleterm").setup(opts) - end - ''; - opts = { - open_mapping = { __raw = "[[]]"; }; - hide_numbers = true; - shade_terminals = true; - start_in_insert = true; - terminal_mappings = true; - persist_mode = true; - insert_mappings = true; - close_on_exit = true; - shell = "fish"; - direction = "horizontal"; # 'vertical' | 'horizontal' | 'window' | 'float' - auto_scroll = true; - float_opts = { - border = "curved"; # 'single' | 'double' | 'shadow' | 'curved' - width = 80; - height = 20; - winblend = 0; + { + name = "gitsigns"; + pkg = pkgs.vimPlugins.gitsigns-nvim; + lazy = false; + config = '' + function(_, opts) + require("gitsigns").setup(opts) + end + ''; + opts = { + current_line_blame = false; }; - }; - } + } - { - name = "treesitter"; - pkg = pkgs.vimPlugins.nvim-treesitter.withAllGrammars; - lazy = false; - config = '' - function(_, opts) - require("nvim-treesitter.configs").setup(opts) - end - ''; - opts = { - highlight.enable = true; - indent.enable = true; + { + name = "illuminate"; + pkg = pkgs.vimPlugins.vim-illuminate; + lazy = false; + config = '' + function(_, opts) + require("illuminate").configure(opts) + end + ''; + opts = { + filetypesDenylist = [ + "DressingSelect" + "Outline" + "TelescopePrompt" + "alpha" + "harpoon" + "toggleterm" + "neo-tree" + "Spectre" + "reason" + ]; + }; + } - # TODO: Doesn't work - incremental_selection = { - enable = true; - keymaps = { - "init_selection" = "gnn"; - "node_decremental" = "grm"; - "node_incremental" = "grn"; - "scope_incremental" = "grc"; + { + name = "intellitab"; + pkg = pkgs.vimPlugins.intellitab-nvim; + lazy = false; + } + + { + name = "lastplace"; + pkg = pkgs.vimPlugins.nvim-lastplace; + lazy = false; + config = '' + function(_, opts) + require("nvim-lastplace").setup(opts) + end + ''; + } + + { + name = "lazygit"; + pkg = pkgs.vimPlugins.lazygit-nvim; + } + + # TODO: Snippet configs + { + name = "luasnip"; + pkg = pkgs.vimPlugins.luasnip; + config = '' + function(_, opts) + require("luasnip").config.set_config(opts) + end + ''; + } + + { + name = "navbuddy"; + pkg = pkgs.vimPlugins.nvim-navbuddy; + config = '' + function(_, opts) + local actions = require("nvim-navbuddy.actions") -- ? + require("nvim-navbuddy").setup(opts) + end + ''; + opts = { + lsp.auto_attach = true; + window.border = "rounded"; + }; + } + + # TODO: Doesn't show up + { + name = "navic"; + pkg = pkgs.vimPlugins.nvim-navic; + config = '' + function(_, opts) + require("nvim-navic").setup(opts) + end + ''; + opts = { + lsp.auto_attach = true; + click = true; + highlight = true; + }; + } + + { + name = "autopairs"; + pkg = pkgs.vimPlugins.nvim-autopairs; + lazy = false; + config = '' + function(_, opts) + require("nvim-autopairs").setup(opts) + end + ''; + } + + { + name = "colorizer"; + pkg = pkgs.vimPlugins.nvim-colorizer-lua; + lazy = false; + config = '' + function(_, opts) + require("colorizer").setup(opts) + end + ''; + opts = { + filtetypes = null; + user_default_options = null; + buftypes = null; + }; + } + + { + name = "ufo"; + pkg = pkgs.vimPlugins.nvim-ufo; + dependencies = [ + { + name = "promise"; + pkg = pkgs.vimPlugins.promise-async; + } + ]; + config = '' + function(_, opts) + require("ufo").setup(opts) + end + ''; + } + + { + name = "rainbow-delimiters"; + pkg = pkgs.vimPlugins.rainbow-delimiters-nvim; + lazy = false; + } + + { + name = "sandwich"; + pkg = pkgs.vimPlugins.vim-sandwich; + lazy = false; + } + + { + name = "sleuth"; + pkg = pkgs.vimPlugins.vim-sleuth; + lazy = false; + } + + { + name = "toggleterm"; + pkg = pkgs.vimPlugins.toggleterm-nvim; + lazy = false; + config = '' + function(_, opts) + require("toggleterm").setup(opts) + end + ''; + opts = { + open_mapping = {__raw = "[[]]";}; + hide_numbers = true; + shade_terminals = true; + start_in_insert = true; + terminal_mappings = true; + persist_mode = true; + insert_mappings = true; + close_on_exit = true; + shell = "fish"; + direction = "horizontal"; # 'vertical' | 'horizontal' | 'window' | 'float' + auto_scroll = true; + float_opts = { + border = "curved"; # 'single' | 'double' | 'shadow' | 'curved' + width = 80; + height = 20; + winblend = 0; }; }; - }; - } + } - { - name = "trim"; - pkg = pkgs.vimPlugins.trim-nvim; - lazy = false; - config = '' - function(_, opts) - require("trim").setup(opts) - end - ''; - } + { + name = "trim"; + pkg = pkgs.vimPlugins.trim-nvim; + lazy = false; + config = '' + function(_, opts) + require("trim").setup(opts) + end + ''; + } - { - name = "trouble"; - pkg = pkgs.vimPlugins.trouble-nvim; - config = '' - function(_, opts) - require("trouble").setup(opts) - end - ''; - } + { + name = "trouble"; + pkg = pkgs.vimPlugins.trouble-nvim; + config = '' + function(_, opts) + require("trouble").setup(opts) + end + ''; + } - { - name = "bbye"; - pkg = pkgs.vimPlugins.vim-bbye; - } + { + name = "bbye"; + pkg = pkgs.vimPlugins.vim-bbye; + } - { - name = "which-key"; - pkg = pkgs.vimPlugins.which-key-nvim; - lazy = false; - priority = 100; - config = '' - function(_, opts) - require("which-key").setup(opts) - end - ''; - } - - { - name = "yanky"; # TODO: Bindings - pkg = pkgs.vimPlugins.yanky-nvim; - lazy = false; - config = '' - function(_, opts) - require("yanky").setup(opts) - end - ''; - } + { + name = "yanky"; # TODO: Bindings + pkg = pkgs.vimPlugins.yanky-nvim; + lazy = false; + config = '' + function(_, opts) + require("yanky").setup(opts) + end + ''; + } + ] ]; }; - ################################################################################################################################## - # NixVim Plugins # - ################################################################################################################################## - - # TODO - # clangd-extensions = { - # enable = true; - # }; + # NixVim plugins # TODO: Figure out how debugging from nvim works... # Debug-Adapter-Protocol diff --git a/home/modules/neovim/extraConfigLua.lua b/home/modules/neovim/extraConfigLua.lua index d03e2446..a61cc098 100644 --- a/home/modules/neovim/extraConfigLua.lua +++ b/home/modules/neovim/extraConfigLua.lua @@ -1,13 +1,13 @@ -- Hide inline diagnostics and show border vim.diagnostic.config({ - virtual_text = false, - float = { border = "rounded" } + virtual_text = false, + float = { border = "rounded" }, }) -- Allow navigating popupmenu completion with Up/Down -vim.api.nvim_set_keymap('c', '', 'v:lua.get_wildmenu_key("", "")', { expr = true }) -vim.api.nvim_set_keymap('c', '', 'v:lua.get_wildmenu_key("", "")', { expr = true }) +vim.api.nvim_set_keymap("c", "", 'v:lua.get_wildmenu_key("", "")', { expr = true }) +vim.api.nvim_set_keymap("c", "", 'v:lua.get_wildmenu_key("", "")', { expr = true }) function _G.get_wildmenu_key(key_wildmenu, key_regular) - return vim.fn.wildmenumode() ~= 0 and key_wildmenu or key_regular + return vim.fn.wildmenumode() ~= 0 and key_wildmenu or key_regular end diff --git a/home/modules/neovim/extraConfigLuaPost.lua b/home/modules/neovim/extraConfigLuaPost.lua index d4784b5b..e3a3a695 100644 --- a/home/modules/neovim/extraConfigLuaPost.lua +++ b/home/modules/neovim/extraConfigLuaPost.lua @@ -4,21 +4,21 @@ local o = vim.o -- Neovide if g.neovide then - -- require("notify").notify("Running in NeoVide") + -- require("notify").notify("Running in NeoVide") - g.neovide_cursor_animate_command_line = true - g.neovide_cursor_animate_in_insert_mode = true - g.neovide_fullscreen = false - g.neovide_hide_mouse_when_typing = false - g.neovide_padding_top = 0 - g.neovide_padding_bottom = 0 - g.neovide_padding_right = 0 - g.neovide_padding_left = 0 - g.neovide_refresh_rate = 144 - g.neovide_theme = 'light' + g.neovide_cursor_animate_command_line = true + g.neovide_cursor_animate_in_insert_mode = true + -- g.neovide_fullscreen = false + g.neovide_hide_mouse_when_typing = true + g.neovide_padding_top = 0 + g.neovide_padding_bottom = 0 + g.neovide_padding_right = 0 + g.neovide_padding_left = 0 + g.neovide_refresh_rate = 144 + -- g.neovide_theme = "light" - -- Neovide Fonts - o.guifont = "JetBrainsMono Nerd Font:h13:Medium" + -- Neovide Fonts + o.guifont = "JetBrainsMono Nerd Font:h13:Medium" else - -- require("notify").notify("Not running in NeoVide") + -- require("notify").notify("Not running in NeoVide") end diff --git a/home/modules/neovim/keybinds.nix b/home/modules/neovim/keybinds.nix index 17e10705..c2f1ef14 100644 --- a/home/modules/neovim/keybinds.nix +++ b/home/modules/neovim/keybinds.nix @@ -3,486 +3,491 @@ mylib, ... }: [ - [ - # No Leader - { - mode = "n"; - key = ""; - action = "w"; - options.desc = "Save current buffer"; - } - { - mode = "n"; - key = ""; - action = "wa"; - options.desc = "Save all buffers"; - } - { - mode = "v"; - key = "<"; - action = " - { - mode = "n"; - key = "qq"; - action = "quitall"; - options.desc = "Quit"; - } - { - mode = "n"; - key = "q!"; - action = "quitall!"; - options.desc = "Forceful quit"; - } - { - mode = "n"; - key = "L"; - action = "Lazy"; - options.desc = "Show Lazy"; - } - { - mode = "n"; - key = ""; - action = "Telescope buffers"; - options.desc = "Show open buffers"; - } - { - mode = "n"; - key = "S"; - action = "wa"; - options.desc = "Save all buffers"; - } - { - mode = "n"; - key = "f"; - action = "Telescope find_files"; - options.desc = "Find file"; - } - { - mode = "n"; - key = "o"; - action = "Telescope vim_options"; - options.desc = "Show Vim options"; - } - { - mode = "n"; - key = "u"; - action = "Telescope undo"; - options.desc = "Show undo history"; - } - { - mode = "n"; - key = "/"; - action = "Telescope current_buffer_fuzzy_find"; - options.desc = "Find in current buffer"; - } - { - mode = "n"; - key = "n"; - action = "Telescope notify"; - options.desc = "Show notify history"; - } - { - mode = "n"; - key = "s"; - action = "Telescope live_grep"; - options.desc = "Find in working directory"; - } - { - mode = "n"; - key = "r"; - action = "Telescope resume"; - options.desc = "Show last telescope picker"; - } - { - mode = "n"; - key = "?"; - action = "Telescope keymaps"; - options.desc = "Show keymaps"; - } - { - mode = "n"; - key = ":"; - action = "Telescope commands"; - options.desc = "Execute command"; - } - { - mode = "n"; - key = "M"; - action = "Telescope marks"; - options.desc = "Show marks"; - } - { - mode = "n"; - key = "J"; - action = "Telescope jumplist"; - options.desc = "Show jumplist"; - } - { - mode = "n"; - key = "m"; - action = "Telescope man_pages"; - options.desc = "Show manpages"; - } - { - mode = "n"; - key = "h"; - action = "Telescope help_tags"; - options.desc = "Show help tags"; - } + # General + { + mode = "n"; + key = "qq"; + action = "quitall"; + options.desc = "Quit"; + } + { + mode = "n"; + key = "q!"; + action = "quitall!"; + options.desc = "Forceful quit"; + } + { + mode = "n"; + key = "L"; + action = "Lazy"; + options.desc = "Show Lazy"; + } + { + mode = "n"; + key = ""; + action = "Telescope buffers"; + options.desc = "Show open buffers"; + } + { + mode = "n"; + key = "S"; + action = "wa"; + options.desc = "Save all buffers"; + } + { + mode = "n"; + key = "f"; + action = "Telescope find_files"; + options.desc = "Find file"; + } + { + mode = "n"; + key = "o"; + action = "Telescope vim_options"; + options.desc = "Show Vim options"; + } + { + mode = "n"; + key = "u"; + action = "Telescope undo"; + options.desc = "Show undo history"; + } + { + mode = "n"; + key = "/"; + action = "Telescope current_buffer_fuzzy_find"; + options.desc = "Find in current buffer"; + } + { + mode = "n"; + key = "n"; + action = "Telescope notify"; + options.desc = "Show notify history"; + } + { + mode = "n"; + key = "s"; + action = "Telescope live_grep"; + options.desc = "Find in working directory"; + } + { + mode = "n"; + key = "r"; + action = "Telescope resume"; + options.desc = "Show last telescope picker"; + } + { + mode = "n"; + key = "?"; + action = "Telescope keymaps"; + options.desc = "Show keymaps"; + } + { + mode = "n"; + key = ":"; + action = "Telescope commands"; + options.desc = "Execute command"; + } + { + mode = "n"; + key = "M"; + action = "Telescope marks"; + options.desc = "Show marks"; + } + { + mode = "n"; + key = "J"; + action = "Telescope jumplist"; + options.desc = "Show jumplist"; + } + { + mode = "n"; + key = "m"; + action = "Telescope man_pages"; + options.desc = "Show manpages"; + } + { + mode = "n"; + key = "h"; + action = "Telescope help_tags"; + options.desc = "Show help tags"; + } - # Buffers b - { - mode = "n"; - key = "b"; - action = "+buffers"; - } - { - mode = "n"; - key = "bb"; - action = "Telescope buffers"; - options.desc = "Show open buffers"; - } - { - mode = "n"; - key = "bn"; - action = "bnext"; - options.desc = "Goto next buffer"; - } - { - mode = "n"; - key = "bp"; - action = "bprevious"; - options.desc = "Goto previous buffer"; - } - { - mode = "n"; - key = "bd"; - action = "Bdelete"; - options.desc = "Close current buffer"; - } + # Quit q + { + mode = "n"; + key = "q"; + action = "+quit"; + } - # Windows w - { - mode = "n"; - key = "w"; - action = "+windows"; - } - { - mode = "n"; - key = "ws"; - action = "s"; - options.desc = "Split window horizontally"; - } - { - mode = "n"; - key = "wv"; - action = "v"; - options.desc = "Split window vertically"; - } - { - mode = "n"; - key = "wd"; - action = "c"; - options.desc = "Close current window"; - } - # { - # mode = "n"; - # key = "wh"; - # action = "s"; - # options.desc = "Split window horizontally"; - # } - { - mode = "n"; - key = "wh"; - action = "h"; - options.desc = "Goto left window"; - } - { - mode = "n"; - key = "wl"; - action = "l"; - options.desc = "Goto right window"; - } - { - mode = "n"; - key = "wj"; - action = "j"; - options.desc = "Goto bottom window"; - } - { - mode = "n"; - key = "wk"; - action = "k"; - options.desc = "Goto top window"; - } - { - mode = "n"; - key = "ww"; - action = "p"; - options.desc = "Goto other window"; - } + # Buffers b + { + mode = "n"; + key = "b"; + action = "+buffers"; + } + { + mode = "n"; + key = "bb"; + action = "Telescope buffers"; + options.desc = "Show open buffers"; + } + { + mode = "n"; + key = "bn"; + action = "bnext"; + options.desc = "Goto next buffer"; + } + { + mode = "n"; + key = "bp"; + action = "bprevious"; + options.desc = "Goto previous buffer"; + } + { + mode = "n"; + key = "bd"; + action = "Bdelete"; + options.desc = "Close current buffer"; + } - # Toggles t - { - mode = "n"; - key = "t"; - action = "+toggle"; - } - # { - # mode = "n"; - # key = "tt"; - # action = "Neotree action=show toggle=true"; - # options.desc = "Toggle NeoTree"; - # } - { - mode = "n"; - key = "tt"; - action = "CHADopen --nofocus"; - options.desc = "Toggle CHADtree"; - } - { - mode = "n"; - key = "tn"; - action = "Navbuddy"; - options.desc = "Toggle NavBuddy"; - } - { - mode = "n"; - key = "td"; - action = "TroubleToggle focus=false"; - options.desc = "Toggle Trouble"; - } - # { - # mode = "n"; - # key = "tg"; - # action = "LazyGit"; - # } - # { - # mode = "n"; - # key = "tp"; - # action = "TroubleToggle"; - # } + # Windows w + { + mode = "n"; + key = "w"; + action = "+windows"; + } + { + mode = "n"; + key = "ws"; + action = "s"; + options.desc = "Split window horizontally"; + } + { + mode = "n"; + key = "wv"; + action = "v"; + options.desc = "Split window vertically"; + } + { + mode = "n"; + key = "wd"; + action = "c"; + options.desc = "Close current window"; + } + # { + # mode = "n"; + # key = "wh"; + # action = "s"; + # options.desc = "Split window horizontally"; + # } + { + mode = "n"; + key = "wh"; + action = "h"; + options.desc = "Goto left window"; + } + { + mode = "n"; + key = "wl"; + action = "l"; + options.desc = "Goto right window"; + } + { + mode = "n"; + key = "wj"; + action = "j"; + options.desc = "Goto bottom window"; + } + { + mode = "n"; + key = "wk"; + action = "k"; + options.desc = "Goto top window"; + } + { + mode = "n"; + key = "ww"; + action = "p"; + options.desc = "Goto other window"; + } - # Git g - { - mode = "n"; - key = "g"; - action = "+git"; - } - { - mode = "n"; - key = "gg"; - action = "LazyGit"; - options.desc = "Show LazyGit"; - } - { - mode = "n"; - key = "gm"; - action = "GitMessenger"; - options.desc = "Show GitMessenger"; - } - # { - # mode = "n"; - # key = "gs"; - # action = "Git status"; - # } - { - mode = "n"; - key = "gs"; - action = "Telescope git_status"; - options.desc = "Show Git status"; - } - { - mode = "n"; - key = "gc"; - action = "Telescope git_commits"; - options.desc = "Show Git log"; - } - { - mode = "n"; - key = "gb"; - action = "Telescope git_branches"; - options.desc = "Show Git branches"; - } - { - mode = "n"; - key = "gf"; - action = "Telescope git_bcommits"; - options.desc = "Show Git log for current file"; - } + # Toggles t + { + mode = "n"; + key = "t"; + action = "+toggle"; + } + # { + # mode = "n"; + # key = "tt"; + # action = "Neotree action=show toggle=true"; + # options.desc = "Toggle NeoTree"; + # } + { + mode = "n"; + key = "tt"; + action = "CHADopen --nofocus"; + options.desc = "Toggle CHADtree"; + } + { + mode = "n"; + key = "tn"; + action = "Navbuddy"; + options.desc = "Toggle NavBuddy"; + } + { + mode = "n"; + key = "td"; + action = "TroubleToggle focus=false"; + options.desc = "Toggle Trouble"; + } + # { + # mode = "n"; + # key = "tg"; + # action = "LazyGit"; + # } + # { + # mode = "n"; + # key = "tp"; + # action = "TroubleToggle"; + # } - # LSP l - { - mode = "n"; - key = "l"; - action = "+lsp"; - } - { - mode = "n"; - key = "lr"; - action = "Telescope lsp_references"; - options.desc = "Goto references"; - } - { - mode = "n"; - key = "ld"; - action = "Telescope lsp_definitions"; - options.desc = "Goto definition"; - } - { - mode = "n"; - key = "li"; - action = "Telescope lsp_implementations"; - options.desc = "Goto implementation"; - } - { - mode = "n"; - key = "lt"; - action = "Telescope lsp_type_definitions"; - options.desc = "Goto type definition"; - } - { - mode = "n"; - key = "lI"; - action = "Telescope lsp_incoming_calls"; - options.desc = "Show incoming calls"; - } - { - mode = "n"; - key = "lO"; - action = "Telescope lsp_outgoing_calls"; - options.desc = "Show outgoing calls"; - } + # Git g + { + mode = "n"; + key = "g"; + action = "+git"; + } + { + mode = "n"; + key = "gg"; + action = "LazyGit"; + options.desc = "Show LazyGit"; + } + { + mode = "n"; + key = "gm"; + action = "GitMessenger"; + options.desc = "Show GitMessenger"; + } + # { + # mode = "n"; + # key = "gs"; + # action = "Git status"; + # } + { + mode = "n"; + key = "gs"; + action = "Telescope git_status"; + options.desc = "Show Git status"; + } + { + mode = "n"; + key = "gc"; + action = "Telescope git_commits"; + options.desc = "Show Git log"; + } + { + mode = "n"; + key = "gb"; + action = "Telescope git_branches"; + options.desc = "Show Git branches"; + } + { + mode = "n"; + key = "gf"; + action = "Telescope git_bcommits"; + options.desc = "Show Git log for current file"; + } - # Code c - { - mode = "n"; - key = "c"; - action = "+code"; - } - { - mode = "n"; - key = "cf"; - action = "lua require('conform').format()"; - options.desc = "Format current buffer"; - } - { - mode = "n"; - key = "cd"; - action = "Telescope diagnostics"; - options.desc = "Show diagnostics"; - } - { - mode = "n"; - key = "cr"; - action = "lua vim.lsp.buf.rename()"; - options.desc = "Rename LSP symbol"; - } - { - mode = "n"; - key = "ca"; - action = "lua vim.lsp.buf.code_action()"; - options.desc = "Show LSP code actions"; - } - { - mode = "n"; - key = "cD"; - action = "lua vim.diagnostic.open_float()"; - options.desc = "Show LSP line diagnostics"; - } - ] + # LSP l + { + mode = "n"; + key = "l"; + action = "+lsp"; + } + { + mode = "n"; + key = "lr"; + action = "Telescope lsp_references"; + options.desc = "Goto references"; + } + { + mode = "n"; + key = "ld"; + action = "Telescope lsp_definitions"; + options.desc = "Goto definition"; + } + { + mode = "n"; + key = "li"; + action = "Telescope lsp_implementations"; + options.desc = "Goto implementation"; + } + { + mode = "n"; + key = "lt"; + action = "Telescope lsp_type_definitions"; + options.desc = "Goto type definition"; + } + { + mode = "n"; + key = "lI"; + action = "Telescope lsp_incoming_calls"; + options.desc = "Show incoming calls"; + } + { + mode = "n"; + key = "lO"; + action = "Telescope lsp_outgoing_calls"; + options.desc = "Show outgoing calls"; + } + + # Code c + { + mode = "n"; + key = "c"; + action = "+code"; + } + { + mode = "n"; + key = "cf"; + action = "lua require('conform').format()"; + options.desc = "Format current buffer"; + } + { + mode = "n"; + key = "cd"; + action = "Telescope diagnostics"; + options.desc = "Show diagnostics"; + } + { + mode = "n"; + key = "cr"; + action = "lua vim.lsp.buf.rename()"; + options.desc = "Rename LSP symbol"; + } + { + mode = "n"; + key = "ca"; + action = "lua vim.lsp.buf.code_action()"; + options.desc = "Show LSP code actions"; + } + { + mode = "n"; + key = "cD"; + action = "lua vim.diagnostic.open_float()"; + options.desc = "Show LSP line diagnostics"; + } ] diff --git a/home/modules/neovim/languages.nix b/home/modules/neovim/languages.nix index 72cf57d3..8bf1a6c0 100644 --- a/home/modules/neovim/languages.nix +++ b/home/modules/neovim/languages.nix @@ -4,6 +4,16 @@ pkgs, ... }: [ + { + name = "clangd-extensions"; + pkg = pkgs.vimPlugins.clangd_extensions-nvim; + config = '' + function(_, opts) + require("clangd_extensions").setup(opts) + end + ''; + } + { name = "conform"; pkg = pkgs.vimPlugins.conform-nvim; @@ -31,6 +41,12 @@ }; } + { + name = "haskell-tools"; + pkg = pkgs.vimPlugins.haskell-tools-nvim; + # Don't call setup! + } + { name = "lint"; pkg = pkgs.vimPlugins.nvim-lint; @@ -66,25 +82,29 @@ { name = "lspconfig"; pkg = pkgs.vimPlugins.nvim-lspconfig; + dependencies = [ + { + name = "neodev"; + pkg = pkgs.vimPlugins.neodev-nvim; + config = '' + function(_, opts) + require("neodev").setup(opts) + end + ''; + } + ]; lazy = false; config = let servers = mylib.generators.toLuaObject [ {name = "clangd";} {name = "clojure_lsp";} {name = "cmake";} - {name = "lua-ls";} + {name = "lua_ls";} {name = "nil_ls";} {name = "pyright";} - {name = "rust_analyzer";} + # {name = "rust_analyzer";} # Don't set up when using rustaceanvim {name = "texlab";} - - { - name = "hls"; - cmd = [ - "haskell-language-server-wrapper" - "--lsp" - ]; - } + # {name = "hls";} # Don't set up when using haskell-tools ]; in '' function(_, opts) @@ -121,17 +141,94 @@ } { + name = "rustaceanvim"; + pkg = pkgs.vimPlugins.rustaceanvim; + # Don't call setup! + } + + (let + nvim-plugintree = pkgs.vimPlugins.nvim-treesitter.withPlugins ( + p: + with p; [ + bash + bibtex + c + clojure + cmake + cpp + csv + disassembly + dockerfile + dot + doxygen + fish + gitignore + haskell + haskell_persistent + html + ini + java + javascript + json + julia + kotlin + lua + make + markdown + markdown_inline + nasm + nix + objdump + org + passwd + perl + printf + python + r + regex + requirements + ruby + rust + scala + scss + sql + toml + typescript + verilog + xml + yaml + ] + ); + treesitter-parsers = pkgs.symlinkJoin { + name = "treesitter-parsers"; + paths = nvim-plugintree.dependencies; + }; + in { name = "treesitter"; - pkg = pkgs.vimPlugins.nvim-treesitter.withAllGrammars; + pkg = pkgs.vimPlugins.nvim-treesitter; lazy = false; config = '' function(_, opts) + vim.opt.runtimepath:append("${nvim-plugintree}") + vim.opt.runtimepath:append("${treesitter-parsers}") + require("nvim-treesitter.configs").setup(opts) end ''; opts = { - highlight.enable = true; - indent.enable = true; + auto_install = false; + ensure_installed = []; + parser_install_dir = "${treesitter-parsers}"; + + indent = { + enable = true; + # disable = ["python" "yaml"]; + }; + highlight = { + enable = true; + # disable = ["yaml"]; + additional_vim_regex_highlighting = false; + }; # TODO: Doesn't work incremental_selection = { @@ -144,5 +241,5 @@ }; }; }; - } + }) ]