From b1ad0b623aca45226f943b8712ff60052d77319e Mon Sep 17 00:00:00 2001 From: derped Date: Sun, 1 Dec 2024 16:54:44 +0100 Subject: [PATCH] Add nvim-lazy submodule and add plugin configuration. --- flake.nix | 4 + machines/Lilim/options.nix | 29 +++++++ pkgsets/nvim.nix | 40 +++++++++ pkgsets/nvim/cmp.nix | 55 ++++++++++++ pkgsets/nvim/fugitive.nix | 54 ++++++++++++ pkgsets/nvim/gen.nix | 18 ++++ pkgsets/nvim/go.nix | 147 ++++++++++++++++++++++++++++++++ pkgsets/nvim/harpoon.nix | 88 +++++++++++++++++++ pkgsets/nvim/hurl.nix | 91 ++++++++++++++++++++ pkgsets/nvim/kanagawa-nvim.nix | 23 +++++ pkgsets/nvim/lsp.nix | 128 +++++++++++++++++++++++++++ pkgsets/nvim/lsp/bash.nix | 14 +++ pkgsets/nvim/lsp/emmet.nix | 13 +++ pkgsets/nvim/lsp/go.nix | 13 +++ pkgsets/nvim/lsp/harper.nix | 13 +++ pkgsets/nvim/lsp/html.nix | 16 ++++ pkgsets/nvim/lsp/ltex.nix | 24 ++++++ pkgsets/nvim/lsp/lua.nix | 26 ++++++ pkgsets/nvim/lsp/nix-nil.nix | 26 ++++++ pkgsets/nvim/lsp/nix-nixd.nix | 42 +++++++++ pkgsets/nvim/lsp/php.nix | 19 +++++ pkgsets/nvim/lsp/python.nix | 44 ++++++++++ pkgsets/nvim/lsp/rust.nix | 13 +++ pkgsets/nvim/lsp/typescript.nix | 13 +++ pkgsets/nvim/lsp/yaml.nix | 24 ++++++ pkgsets/nvim/lualine.nix | 72 ++++++++++++++++ pkgsets/nvim/model.nix | 77 +++++++++++++++++ pkgsets/nvim/noice.nix | 50 +++++++++++ pkgsets/nvim/nvim-highlight.nix | 27 ++++++ pkgsets/nvim/oil-nvim.nix | 18 ++++ pkgsets/nvim/orgmode.nix | 40 +++++++++ pkgsets/nvim/otter.nix | 16 ++++ pkgsets/nvim/sniprun.nix | 53 ++++++++++++ pkgsets/nvim/telescope.nix | 79 +++++++++++++++++ pkgsets/nvim/tmux-navigate.nix | 46 ++++++++++ pkgsets/nvim/treesitter.nix | 69 +++++++++++++++ pkgsets/nvim/trim.nix | 16 ++++ pkgsets/nvim/undotree.nix | 23 +++++ pkgsets/nvim/which-key.nix | 36 ++++++++ 39 files changed, 1599 insertions(+) create mode 100644 pkgsets/nvim.nix create mode 100644 pkgsets/nvim/cmp.nix create mode 100644 pkgsets/nvim/fugitive.nix create mode 100644 pkgsets/nvim/gen.nix create mode 100644 pkgsets/nvim/go.nix create mode 100644 pkgsets/nvim/harpoon.nix create mode 100644 pkgsets/nvim/hurl.nix create mode 100644 pkgsets/nvim/kanagawa-nvim.nix create mode 100644 pkgsets/nvim/lsp.nix create mode 100644 pkgsets/nvim/lsp/bash.nix create mode 100644 pkgsets/nvim/lsp/emmet.nix create mode 100644 pkgsets/nvim/lsp/go.nix create mode 100644 pkgsets/nvim/lsp/harper.nix create mode 100644 pkgsets/nvim/lsp/html.nix create mode 100644 pkgsets/nvim/lsp/ltex.nix create mode 100644 pkgsets/nvim/lsp/lua.nix create mode 100644 pkgsets/nvim/lsp/nix-nil.nix create mode 100644 pkgsets/nvim/lsp/nix-nixd.nix create mode 100644 pkgsets/nvim/lsp/php.nix create mode 100644 pkgsets/nvim/lsp/python.nix create mode 100644 pkgsets/nvim/lsp/rust.nix create mode 100644 pkgsets/nvim/lsp/typescript.nix create mode 100644 pkgsets/nvim/lsp/yaml.nix create mode 100644 pkgsets/nvim/lualine.nix create mode 100644 pkgsets/nvim/model.nix create mode 100644 pkgsets/nvim/noice.nix create mode 100644 pkgsets/nvim/nvim-highlight.nix create mode 100644 pkgsets/nvim/oil-nvim.nix create mode 100644 pkgsets/nvim/orgmode.nix create mode 100644 pkgsets/nvim/otter.nix create mode 100644 pkgsets/nvim/sniprun.nix create mode 100644 pkgsets/nvim/telescope.nix create mode 100644 pkgsets/nvim/tmux-navigate.nix create mode 100644 pkgsets/nvim/treesitter.nix create mode 100644 pkgsets/nvim/trim.nix create mode 100644 pkgsets/nvim/undotree.nix create mode 100644 pkgsets/nvim/which-key.nix diff --git a/flake.nix b/flake.nix index e248f83..b9853a2 100644 --- a/flake.nix +++ b/flake.nix @@ -17,6 +17,10 @@ url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; + nvim-lazy = { + url = "git+https://git.ophanim.de/derped/lazy.nvim.nix.git"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { diff --git a/machines/Lilim/options.nix b/machines/Lilim/options.nix index 8880edc..4b90552 100644 --- a/machines/Lilim/options.nix +++ b/machines/Lilim/options.nix @@ -36,6 +36,35 @@ with lib; "latex" "mail_utils" "nodejs" + "nvim" + "nvim::cmp" + "nvim::fugitive" + "nvim::go" + "nvim::harpoon" + "nvim::hurl" + "nvim::kanagawa-nvim" + "nvim::lsp" + "nvim::lsp::bash" + "nvim::lsp::emmet" + "nvim::lsp::go" + "nvim::lsp::harper" + "nvim::lsp::ltex" + "nvim::lsp::lua" + "nvim::lsp::nix-nil" + "nvim::lsp::python" + "nvim::lsp::typescript" + "nvim::lsp::yaml" + "nvim::lualine" + "nvim::nvim-highlight" + "nvim::oil-nvim" + "nvim::orgmode" + "nvim::sniprun" + "nvim::telescope" + "nvim::tmux-navigate" + "nvim::treesitter" + "nvim::trim" + "nvim::undotree" + "nvim::which-key" "python3" "xpkgs" ]; diff --git a/pkgsets/nvim.nix b/pkgsets/nvim.nix new file mode 100644 index 0000000..bc92bd2 --- /dev/null +++ b/pkgsets/nvim.nix @@ -0,0 +1,40 @@ +{ + lib, + config, + fn, + nvim-lazy, + ... +}: + +with lib; +{ + imports = + [ + nvim-lazy.nixosModules.nvim-lazy + ] + ++ (fn.lst { + path = (toString ./nvim); + fullPath = true; + }); + + programs.nvim-lazy = mkIf (elem "nvim" config.machine.pkgs) { + enable = true; + luaRcContent = # lua + '' + vim.g.mapleader = " " + vim.opt.tabstop = 2 + vim.opt.shiftwidth = 2 + vim.opt.expandtab = true + vim.opt.ignorecase = true + vim.opt.smartcase = true + -- TODO: fix option name + -- vim.opt.nformats = alpha + vim.bo.softtabstop = 2 + + vim.wo.number = true + vim.wo.relativenumber = true + + vim.opt.scrolloff = 10 + ''; + }; +} diff --git a/pkgsets/nvim/cmp.nix b/pkgsets/nvim/cmp.nix new file mode 100644 index 0000000..d79f8d4 --- /dev/null +++ b/pkgsets/nvim/cmp.nix @@ -0,0 +1,55 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::cmp" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + # Autocompletion + { + dir = vPlug: vPlug.nvim-cmp; + event = [ "InsertEnter" ]; + dependencies = ( + vPlug: with vPlug; [ + luasnip + ] + ); + config = # lua + '' + function() + ${ + lib.optionalString (lib.elem "nvim::lsp" config.machine.pkgs) # lua + '' + local lsp_zero = require('lsp-zero') + lsp_zero.extend_cmp() + '' + } + + local cmp = require('cmp') + local cmp_action = lsp_zero.cmp_action() + + cmp.setup({ + ${ + lib.optionalString (lib.elem "nvim::lsp" config.machine.pkgs) # lua + ''formatting = lsp_zero.cmp_format(),'' + } + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp_action.luasnip_jump_forward(), + [''] = cmp_action.luasnip_jump_backward(), + }) + }) + end + ''; + } + + { + dir = vPlug: vPlug.luasnip; + lazy = true; + } + ]; +} diff --git a/pkgsets/nvim/fugitive.nix b/pkgsets/nvim/fugitive.nix new file mode 100644 index 0000000..190e56c --- /dev/null +++ b/pkgsets/nvim/fugitive.nix @@ -0,0 +1,54 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::fugitive" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + # short = "NeogitOrg/neogit"; + lazy = true; + dir = vPlug: vPlug.neogit; + dependencies = ( + vPlug: with vPlug; [ + # plenary-nvim + "nvim-lua/plenary.nvim" + diffview-nvim + telescope-nvim + ] + ); + cmd = [ "Neogit" ]; + keys = [ + { + bind = "gm"; + cmd = "Neogit"; + opts = { + desc = "Open Neogit."; + }; + } + ]; + config = true; + } + { + lazy = true; + dir = vPlug: vPlug.diffview-nvim; + } + { + enabled = true; + lazy = true; + dir = vPlug: vPlug.fugitive; + cmd = [ "Git" ]; + keys = [ + { + bind = "gs"; + cmd = "Git"; + opts = { + desc = "Open fugitive (git status)"; + }; + } + # { bind = "ga"; cmd = "Git"; opts = { desc = "Open fugitive (git status)"; }; } + ]; + } + ]; +} diff --git a/pkgsets/nvim/gen.nix b/pkgsets/nvim/gen.nix new file mode 100644 index 0000000..be8e8f0 --- /dev/null +++ b/pkgsets/nvim/gen.nix @@ -0,0 +1,18 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::gen" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + lazy = true; + short = "David-Kunz/gen.nvim"; + cmd = [ "Gen" ]; + opts = { + model = "deepseek-coder:1.3b-base-q4_0"; + }; + } + ]; +} diff --git a/pkgsets/nvim/go.nix b/pkgsets/nvim/go.nix new file mode 100644 index 0000000..f401c96 --- /dev/null +++ b/pkgsets/nvim/go.nix @@ -0,0 +1,147 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::go" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + lazy = true; + dir = (vPlug: vPlug.go-nvim); + dependencies = ( + vPlug: with vPlug; [ + nvim-treesitter.withAllGrammars + nvim-lspconfig + ] + ); + ft = [ + "go" + "gomod" + "ray-x/guihua.lua" + ]; + config = # lua + '' + function() + require('go').setup({ + disable_defaults = false, -- true|false when true set false to all boolean settings and replace all table + -- settings with {} + go='go', -- go command, can be go[default] or go1.18beta1 + goimports ='gopls', -- goimports command, can be gopls[default] or either goimports or golines if need to split long lines + gofmt = 'gopls', -- gofmt through gopls: alternative is gofumpt, goimports, golines, gofmt, etc + fillstruct = 'gopls', -- set to fillstruct if gopls fails to fill struct + max_line_len = 0, -- max line length in golines format, Target maximum line length for golines + tag_transform = false, -- can be transform option("snakecase", "camelcase", etc) check gomodifytags for details and more options + tag_options = 'json=omitempty', -- sets options sent to gomodifytags, i.e., json=omitempty + gotests_template = "", -- sets gotests -template parameter (check gotests for details) + gotests_template_dir = "", -- sets gotests -template_dir parameter (check gotests for details) + comment_placeholder = "" , -- comment_placeholder your cool placeholder e.g. 󰟓     + icons = {breakpoint = '🧘', currentpos = '🏃'}, -- setup to `false` to disable icons setup + verbose = false, -- output loginf in messages + lsp_cfg = true, -- true: use non-default gopls setup specified in go/lsp.lua + -- false: do nothing + -- if lsp_cfg is a table, merge table with with non-default gopls setup in go/lsp.lua, e.g. + -- lsp_cfg = {settings={gopls={matcher='CaseInsensitive', ['local'] = 'your_local_module_path', gofumpt = true }}} + lsp_gofumpt = true, -- true: set default gofmt in gopls format to gofumpt + -- false: do not set default gofmt in gopls format to gofumpt + lsp_on_attach = nil, -- nil: use on_attach function defined in go/lsp.lua, + -- when lsp_cfg is true + -- if lsp_on_attach is a function: use this function as on_attach function for gopls + lsp_keymaps = false, -- set to false to disable gopls/lsp keymap + lsp_codelens = true, -- set to false to disable codelens, true by default, you can use a function + -- function(bufnr) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "F", "lua vim.lsp.buf.formatting()", {noremap=true, silent=true}) + -- end + -- to setup a table of codelens + diagnostic = { -- set diagnostic to false to disable vim.diagnostic setup + hdlr = false, -- hook lsp diag handler and send diag to quickfix + underline = true, + -- virtual text setup + virtual_text = { spacing = 0, prefix = '■' }, + signs = true, + update_in_insert = false, + }, + -- if you need to setup your ui for input and select, you can do it here + -- go_input = require('guihua.input').input -- set to vim.ui.input to disable guihua input + -- go_select = require('guihua.select').select -- vim.ui.select to disable guihua select + lsp_document_formatting = true, + -- set to true: use gopls to format + -- false if you want to use other formatter tool(e.g. efm, nulls) + lsp_inlay_hints = { + enable = true, + -- hint style, set to 'eol' for end-of-line hints, 'inlay' for inline hints + -- inlay only avalible for 0.10.x + style = 'inlay', + -- Note: following setup only works for style = 'eol', you do not need to set it for 'inlay' + -- Only show inlay hints for the current line + only_current_line = false, + -- Event which triggers a refersh of the inlay hints. + -- You can make this "CursorMoved" or "CursorMoved,CursorMovedI" but + -- not that this may cause higher CPU usage. + -- This option is only respected when only_current_line and + -- autoSetHints both are true. + only_current_line_autocmd = "CursorHold", + -- whether to show variable name before type hints with the inlay hints or not + -- default: false + show_variable_name = true, + -- prefix for parameter hints + parameter_hints_prefix = "󰊕 ", + show_parameter_hints = true, + -- prefix for all the other hints (type, chaining) + other_hints_prefix = "=> ", + -- whether to align to the lenght of the longest line in the file + max_len_align = false, + -- padding from the left if max_len_align is true + max_len_align_padding = 1, + -- whether to align to the extreme right or not + right_align = false, + -- padding from the right if right_align is true + right_align_padding = 6, + -- The color of the hints + highlight = "Comment", + }, + gopls_cmd = nil, -- if you need to specify gopls path and cmd, e.g {"/home/user/lsp/gopls", "-logfile","/var/log/gopls.log" } + gopls_remote_auto = true, -- add -remote=auto to gopls + gocoverage_sign = "█", + sign_priority = 5, -- change to a higher number to override other signs + dap_debug = true, -- set to false to disable dap + dap_debug_keymap = true, -- true: use keymap for debugger defined in go/dap.lua + -- false: do not use keymap in go/dap.lua. you must define your own. + -- Windows: Use Visual Studio keymap + dap_debug_gui = {}, -- bool|table put your dap-ui setup here set to false to disable + dap_debug_vt = { enabled_commands = true, all_frames = true }, -- bool|table put your dap-virtual-text setup here set to false to disable + + dap_port = 38697, -- can be set to a number, if set to -1 go.nvim will pick up a random port + dap_timeout = 15, -- see dap option initialize_timeout_sec = 15, + dap_retries = 20, -- see dap option max_retries + build_tags = "tag1,tag2", -- set default build tags + textobjects = true, -- enable default text objects through treesittter-text-objects + test_runner = 'go', -- one of {`go`, `dlv`, `ginkgo`, `gotestsum`} + verbose_tests = true, -- set to add verbose flag to tests deprecated, see '-v' option + run_in_floaterm = false, -- set to true to run in a float window. :GoTermClose closes the floatterm + -- float term recommend if you use gotestsum ginkgo with terminal color + + floaterm = { -- position + posititon = 'auto', -- one of {`top`, `bottom`, `left`, `right`, `center`, `auto`} + width = 0.45, -- width of float window if not auto + height = 0.98, -- height of float window if not auto + title_colors = 'nord', -- default to nord, one of {'nord', 'tokyo', 'dracula', 'rainbow', 'solarized ', 'monokai'} + -- can also set to a list of colors to define colors to choose from + -- e.g {'#D8DEE9', '#5E81AC', '#88C0D0', '#EBCB8B', '#A3BE8C', '#B48EAD'} + }, + trouble = false, -- true: use trouble to open quickfix + test_efm = false, -- errorfomat for quickfix, default mix mode, set to true will be efm only + luasnip = false, -- enable included luasnip snippets. you can also disable while add lua/snips folder to luasnip load + -- Do not enable this if you already added the path, that will duplicate the entries + on_jobstart = function(cmd) _=cmd end, -- callback for stdout + on_stdout = function(err, data) _, _ = err, data end, -- callback when job started + on_stderr = function(err, data) _, _ = err, data end, -- callback for stderr + on_exit = function(code, signal, output) _, _, _ = code, signal, output end, -- callback for jobexit, output : string + iferr_vertical_shift = 4 -- defines where the cursor will end up vertically from the begining of if err statement + }) + end + ''; + } + "ray-x/guihua.lua" + ]; +} diff --git a/pkgsets/nvim/harpoon.nix b/pkgsets/nvim/harpoon.nix new file mode 100644 index 0000000..291a6a8 --- /dev/null +++ b/pkgsets/nvim/harpoon.nix @@ -0,0 +1,88 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::harpoon" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + dir = vPlug: vPlug.harpoon2; + lazy = true; + keys = + [ + { + bind = "ha"; + cmdIsFunction = true; + cmd = # lua + '' + function() + require("harpoon"):list():add() + end + ''; + } + { + bind = "he"; + cmdIsFunction = true; + cmd = # lua + '' + function() + local harpoon = require("harpoon") + harpoon.ui:toggle_quick_menu(harpoon:list()) + end + ''; + } + { + bind = ""; + cmdIsFunction = true; + cmd = # lua + '' + function() + require("harpoon"):list():select(1) + end + ''; + } + { + bind = ""; + cmdIsFunction = true; + cmd = # lua + '' + function() + require("harpoon"):list():select(2) + end + ''; + } + { + bind = ""; + cmdIsFunction = true; + cmd = # lua + '' + function() + require("harpoon"):list():select(3) + end + ''; + } + { + bind = ""; + cmdIsFunction = true; + cmd = # lua + '' + function() + require("harpoon"):list():select(4) + end + ''; + } + ] + ++ (map (num: { + bind = "h${toString (lib.mod num 10)}"; + cmdIsFunction = true; + cmd = # lua + '' + function() + require("harpoon"):list():select(${toString num}) + end + ''; + }) (lib.range 1 10)); + } + ]; +} diff --git a/pkgsets/nvim/hurl.nix b/pkgsets/nvim/hurl.nix new file mode 100644 index 0000000..6c48caa --- /dev/null +++ b/pkgsets/nvim/hurl.nix @@ -0,0 +1,91 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.mkIf (lib.elem "nvim::hurl" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + lazy = true; + dir = vPlug: vPlug.nui-nvim; + } + { + lazy = true; + ft = [ "hurl" ]; + short = "jellydn/hurl.nvim"; + dependencies = (vPlug: with vPlug; [ nui-nvim ]); + opts = { + debug = false; + show_notification = false; + # Show response in popup or split + mode = "popup"; + formatters = { + json = [ "${pkgs.jq}/bin/jq" ]; + html = [ + "${pkgs.nodePackages.prettier}/bin/prettier" + "--parser" + "html" + ]; + }; + }; + keys = [ + { + bind = "A"; + cmd = "HurlRunner"; + opts = { + ft = "hurl"; + desc = "Run All requests"; + }; + } + { + bind = "a"; + cmd = "HurlRunnerAt"; + opts = { + ft = "hurl"; + desc = "Run Api request"; + }; + } + { + bind = "te"; + cmd = "HurlRunnerToEntry"; + opts = { + ft = "hurl"; + desc = "Run Api request to entry"; + }; + } + { + bind = "tm"; + cmd = "HurlToggleMode"; + opts = { + ft = "hurl"; + desc = "Hurl Toggle Mode"; + }; + } + { + bind = "tv"; + cmd = "HurlVerbose"; + opts = { + ft = "hurl"; + desc = "Run Api in verbose mode"; + }; + } + { + bind = "h"; + cmd = ":HurlRunner"; + opts = { + ft = "hurl"; + desc = "Hurl Runner"; + mode = "v"; + }; + } + ]; + } + { + lazy = true; + ft = [ "hurl" ]; + dir = vPlug: vPlug.hurl; + } + ]; +} diff --git a/pkgsets/nvim/kanagawa-nvim.nix b/pkgsets/nvim/kanagawa-nvim.nix new file mode 100644 index 0000000..be7ac39 --- /dev/null +++ b/pkgsets/nvim/kanagawa-nvim.nix @@ -0,0 +1,23 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::kanagawa-nvim" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + dir = vPlug: vPlug.kanagawa-nvim; + priority = 1000; + config = # lua + '' + function() + require('kanagawa').setup({ + transparent = true, + }) + vim.cmd([[colorscheme kanagawa-wave]]) + end + ''; + } + ]; +} diff --git a/pkgsets/nvim/lsp.nix b/pkgsets/nvim/lsp.nix new file mode 100644 index 0000000..b5b6bb8 --- /dev/null +++ b/pkgsets/nvim/lsp.nix @@ -0,0 +1,128 @@ +{ + lib, + config, + pkgs, + fn, + ... +}@inputs: + +lib.mkIf (lib.elem "nvim::lsp" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = + let + lspServers = lib.concatStrings ( + map (path: import "${path}" (inputs // { inherit pkgs; })) ( + fn.lst { + path = ((toString ./.) + "/lsp"); + fullPath = true; + } + ) + ); + in + [ + # Yaml schema store for yamlls + { + lazy = true; + dir = vPlug: vPlug.SchemaStore-nvim; + } + + { + dir = vPlug: vPlug.lsp-zero-nvim; + lazy = true; + # TODO: This is a bit of a workaround... + config = "false"; + init = # lua + '' + function() + -- Disable automatic setup, we are doing it manually + vim.g.lsp_zero_extend_cmp = 0 + vim.g.lsp_zero_extend_lspconfig = 0 + end + ''; + } + + { + dir = vPlug: vPlug.cmp-nvim-lsp; + lazy = true; + } + + { + dir = vPlug: vPlug.nvim-lspconfig; + cmd = [ "LspInfo" ]; + event = [ + "BufReadPre" + "BufNewFile" + ]; + dependencies = ( + vPlug: with vPlug; [ + cmp-nvim-lsp + SchemaStore-nvim + # coq_nvim + ] + ); + init = # lua + '' + function() + ---Force a specific language for ltex-ls + ---@param lang string + function SetLtexLang(lang) + local clients = vim.lsp.get_clients({ buffer = 0 }) + + for _, client in ipairs(clients) do + if client.name == "ltex" then + vim.api.nvim_notify("Set ltex-ls lang to " .. lang, vim.log.levels.INFO, { title = "LTex Language", timeout = 2000, }) + client.config.settings.ltex.language = lang + vim.lsp.buf_notify(0, "workspace/didChangeConfiguration", { settings = client.config.settings }) + return + end + end + end + end + ''; + config = # lua + '' + function() + -- This is where all the LSP shenanigans will live + local lsp_zero = require('lsp-zero') + lsp_zero.extend_lspconfig() + + lsp_zero.on_attach(function(client, bufnr) + -- see :help lsp-zero-keybindings + -- to learn the available actions + lsp_zero.default_keymaps({buffer = bufnr}) + end) + + -- (Optional) Configure lua language server for neovim + local lspconfig = require('lspconfig') + ${lspServers} + end + ''; + opts = { + inlay_hints = { + enabled = true; + }; + }; + } + # { + # dir = vPlug: vPlug.lspsaga-nvim; + # config = /* lua */ '' + # function() + # require('lspsaga').setup({ + # ui = { + # code_action = "󰌵", + # }, + # lightbulb = { + # enable = true, + # enable_in_insert = false, + # virtual_text = false, + # }, + # }) + # end + # ''; + # dependencies = [ "nvim-treesitter" "nvim-web-devicons" ]; + # } + # { + # lazy = true; + # dir = vPlug: vPlug.nvim-web-devicons; + # } + ]; +} diff --git a/pkgsets/nvim/lsp/bash.nix b/pkgsets/nvim/lsp/bash.nix new file mode 100644 index 0000000..eb53549 --- /dev/null +++ b/pkgsets/nvim/lsp/bash.nix @@ -0,0 +1,14 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.optionalString (lib.elem "nvim::lsp::bash" config.machine.pkgs) # lua + '' + lspconfig.bashls.setup({ + cmd = {"${pkgs.nodePackages.bash-language-server}/bin/bash-language-server", "start"}, + filetypes = {"sh"}, + }) + '' diff --git a/pkgsets/nvim/lsp/emmet.nix b/pkgsets/nvim/lsp/emmet.nix new file mode 100644 index 0000000..9fa4af1 --- /dev/null +++ b/pkgsets/nvim/lsp/emmet.nix @@ -0,0 +1,13 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.optionalString (lib.elem "nvim::lsp::emmet" config.machine.pkgs) # lua + '' + lspconfig.emmet_language_server.setup({ + cmd = {"${pkgs.emmet-language-server}/bin/emmet-language-server", "--stdio"} + }) + '' diff --git a/pkgsets/nvim/lsp/go.nix b/pkgsets/nvim/lsp/go.nix new file mode 100644 index 0000000..397a815 --- /dev/null +++ b/pkgsets/nvim/lsp/go.nix @@ -0,0 +1,13 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.optionalString (lib.elem "nvim::lsp::go" config.machine.pkgs) # lua + '' + lspconfig.gopls.setup({ + cmd = {"${pkgs.gopls}/bin/gopls"} + }) + '' diff --git a/pkgsets/nvim/lsp/harper.nix b/pkgsets/nvim/lsp/harper.nix new file mode 100644 index 0000000..95897f1 --- /dev/null +++ b/pkgsets/nvim/lsp/harper.nix @@ -0,0 +1,13 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.optionalString (lib.elem "nvim::lsp::harper" config.machine.pkgs) # lua + '' + lspconfig.harper_ls.setup({ + cmd = { "${pkgs.harper}/bin/harper-ls", "--stdio" }, + }) + '' diff --git a/pkgsets/nvim/lsp/html.nix b/pkgsets/nvim/lsp/html.nix new file mode 100644 index 0000000..1b5878b --- /dev/null +++ b/pkgsets/nvim/lsp/html.nix @@ -0,0 +1,16 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.optionalString (lib.elem "nvim::lsp::html" config.machine.pkgs) # lua + '' + local html_capabilities = vim.lsp.protocol.make_client_capabilities() + html_capabilities.textDocument.completion.completionItem.snippetSupport = true + lspconfig.html.setup({ + capabilities = html_capabilities, + cmd = {"${pkgs.vscode-langservers-extracted}/bin/vscode-html-language-server"} + }) + '' diff --git a/pkgsets/nvim/lsp/ltex.nix b/pkgsets/nvim/lsp/ltex.nix new file mode 100644 index 0000000..f56f6fa --- /dev/null +++ b/pkgsets/nvim/lsp/ltex.nix @@ -0,0 +1,24 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.optionalString (lib.elem "nvim::lsp::ltex" config.machine.pkgs) # lua + '' + lspconfig.ltex.setup({ + cmd = { "${pkgs.ltex-ls}/bin/ltex-ls" }, + settings = { + ltex = { + language = "de-DE", + }, + }, + }) + + vim.api.nvim_create_user_command( + "LtexLang", + "lua SetLtexLang()", + { nargs = 1, desc = "Set ltex-ls language" } + ) + '' diff --git a/pkgsets/nvim/lsp/lua.nix b/pkgsets/nvim/lsp/lua.nix new file mode 100644 index 0000000..1dc9eab --- /dev/null +++ b/pkgsets/nvim/lsp/lua.nix @@ -0,0 +1,26 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.optionalString (lib.elem "nvim::lsp::lua" config.machine.pkgs) # lua + '' + lspconfig.lua_ls.setup({ + cmd = {"${pkgs.lua-language-server}/bin/lua-language-server"}, + settings = { + Lua = { + runtime = { + version = 'LuaJIT' + }, + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME + } + } + } + } + }) + '' diff --git a/pkgsets/nvim/lsp/nix-nil.nix b/pkgsets/nvim/lsp/nix-nil.nix new file mode 100644 index 0000000..0109c7f --- /dev/null +++ b/pkgsets/nvim/lsp/nix-nil.nix @@ -0,0 +1,26 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.optionalString (lib.elem "nvim::lsp::nix-nil" config.machine.pkgs) # lua + '' + lspconfig.nil_ls.setup({ + cmd = {"${pkgs.nil}/bin/nil"}, + settings = { + ['nil'] = { + formatting = { + command = { "${pkgs.nixfmt-rfc-style}/bin/nixfmt" } + }, + maxMemoryMB = 4069, + -- nix = { + -- flake = { + -- autoEvalInputs = true + -- } + -- } + } + } + }) + '' diff --git a/pkgsets/nvim/lsp/nix-nixd.nix b/pkgsets/nvim/lsp/nix-nixd.nix new file mode 100644 index 0000000..00f527a --- /dev/null +++ b/pkgsets/nvim/lsp/nix-nixd.nix @@ -0,0 +1,42 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.optionalString (lib.elem "nvim::lsp::nix-nixd" config.machine.pkgs) # lua + '' + lspconfig.nixd.setup({ + cmd = { "${pkgs.nixd}/bin/nixd" }, + settings = { + nixd = { + -- on_init = function(client) + -- local path = client.workspace_folders[1].name + + -- if path == '/path/to/project1' then + -- client.config.settings["rust-analyzer"].checkOnSave.overrideCommand = { "cargo", "check" } + -- client.notify("workspace/didChangeConfiguration", { settings = client.config.settings }) + -- end + + -- return true + -- end, + nixpkgs = { + expr = 'import (builtins.getFlake ("git+file:///etc/nixos")).inputs.nixpkgs {}', + }, + formatting = { + command = { "${pkgs.nixfmt-rfc-style}/bin/nixfmt" }, + }, + options = { + nixos = { + expr = '(builtins.getFlake ("git+file:///etc/nixos")).outputs.nixosConfigurations.Lilim.options', + }, + -- TODO: Find a good general expression for this. + -- home_manager = { + -- expr = '(builtins.getFlake ("git+file://" + toString ./.)).homeConfigurations."ruixi@k-on".options', + -- }, + }, + }, + }, + }) + '' diff --git a/pkgsets/nvim/lsp/php.nix b/pkgsets/nvim/lsp/php.nix new file mode 100644 index 0000000..c9b2d81 --- /dev/null +++ b/pkgsets/nvim/lsp/php.nix @@ -0,0 +1,19 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.optionalString (lib.elem "nvim::lsp::php" config.machine.pkgs) # lua + '' + lspconfig.phpactor.setup({ + cmd = {"${pkgs.phpactor}/bin/phpactor", "language-server"}, + init_options = { + ["symfony.enabled"] = true, + ["language_server_phpstan.enabled"] = true, + ["language_server_phpstan.bin"] = "${pkgs.phpPackages.phpstan}/bin/phpstan", + ["language_server_phpstan.level"] = 5, + }, + }) + '' diff --git a/pkgsets/nvim/lsp/python.nix b/pkgsets/nvim/lsp/python.nix new file mode 100644 index 0000000..5a12dbb --- /dev/null +++ b/pkgsets/nvim/lsp/python.nix @@ -0,0 +1,44 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.optionalString (lib.elem "nvim::lsp::python" config.machine.pkgs) # lua + '' + lspconfig.pyright.setup({ + cmd = {"${pkgs.pyright}/bin/pyright-langserver", "--stdio"}, + settings = { + pyright = { + disableOrganizeImports = true, + }, + python = { + -- analysis = { + -- ignore = { '*' }, + -- }, + }, + }, + }) + lspconfig.ruff.setup({ + cmd = {"${pkgs.ruff}/bin/ruff", "server", "--preview"}, + init_options = { + settings = { + -- Modification to any of these settings has no effect. + enable = true, + ignoreStandardLibrary = true, + organizeImports = true, + fixAll = true, + lint = { + enable = true, + run = 'onType', + }, + }, + }, + on_attach = function(client, bufnr) + if client.name == 'ruff' then + client.server_capabilities.hoverProvider = false; + end + end, + }) + '' diff --git a/pkgsets/nvim/lsp/rust.nix b/pkgsets/nvim/lsp/rust.nix new file mode 100644 index 0000000..52db3c0 --- /dev/null +++ b/pkgsets/nvim/lsp/rust.nix @@ -0,0 +1,13 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.optionalString (lib.elem "nvim::lsp::rust" config.machine.pkgs) # lua + '' + lspconfig.rust_analyzer.setup({ + cmd = {"${pkgs.rustup}/bin/rustup", "run", "nightly", "rust-analyzer"} + }) + '' diff --git a/pkgsets/nvim/lsp/typescript.nix b/pkgsets/nvim/lsp/typescript.nix new file mode 100644 index 0000000..6c0cc14 --- /dev/null +++ b/pkgsets/nvim/lsp/typescript.nix @@ -0,0 +1,13 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.optionalString (lib.elem "nvim::lsp::typescript" config.machine.pkgs) # lua + '' + lspconfig.ts_ls.setup({ + cmd = {"${pkgs.nodePackages.typescript-language-server}/bin/typescript-language-server", "--stdio"} + }) + '' diff --git a/pkgsets/nvim/lsp/yaml.nix b/pkgsets/nvim/lsp/yaml.nix new file mode 100644 index 0000000..9ffe633 --- /dev/null +++ b/pkgsets/nvim/lsp/yaml.nix @@ -0,0 +1,24 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.optionalString (lib.elem "nvim::lsp::yaml" config.machine.pkgs) # lua + '' + lspconfig.yamlls.setup({ + cmd = { "${pkgs.yaml-language-server}/bin/yaml-language-server", "--stdio" }, + settings = { + yaml = { + schemaStore = { + -- Disable to use Store from SchemaStore-nvim plugin + enable = false, + -- Avoid TypeError: Cannot read properties of undefined (reading 'length') + url = "", + }, + schemas = require('schemastore').yaml.schemas(), + }, + }, + }) + '' diff --git a/pkgsets/nvim/lualine.nix b/pkgsets/nvim/lualine.nix new file mode 100644 index 0000000..82152b2 --- /dev/null +++ b/pkgsets/nvim/lualine.nix @@ -0,0 +1,72 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::lualine" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + dir = vPlug: vPlug.lualine-nvim; + dependencies = [ "nvim-web-devicons" ]; + opts = { + options = { + icons_enabled = true; + theme = "auto"; + component_separators = { + left = ""; + right = ""; + }; + section_separators = { + left = ""; + right = ""; + }; + disabled_filetypes = { + statusline = { }; + winbar = { }; + }; + ignore_focus = { }; + always_divide_middle = true; + globalstatus = false; + refresh = { + statusline = 1000; + tabline = 1000; + winbar = 1000; + }; + }; + sections = { + lualine_a = [ "mode" ]; + lualine_b = [ + "branch" + "diff" + "diagnostics" + ]; + lualine_c = [ "filename" ]; + lualine_x = [ + "encoding" + "fileformat" + "filetype" + ]; + lualine_y = [ "progress" ]; + lualine_z = [ "location" ]; + }; + inactive_sections = { + lualine_a = [ ]; + lualine_b = [ ]; + lualine_c = [ "filename" ]; + lualine_x = [ "location" ]; + lualine_y = [ ]; + lualine_z = [ ]; + }; + tabline = { }; + winbar = { }; + inactive_winbar = { }; + extensions = { }; + }; + } + { + lazy = true; + dir = vPlug: vPlug.nvim-web-devicons; + } + ]; +} diff --git a/pkgsets/nvim/model.nix b/pkgsets/nvim/model.nix new file mode 100644 index 0000000..75aae0e --- /dev/null +++ b/pkgsets/nvim/model.nix @@ -0,0 +1,77 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::model" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + short = "gsuuon/model.nvim"; + cmd = [ + "M" + "Model" + "Mchat" + ]; + init = '' + function() + vim.filetype.add({ + extension = { + mchat = 'mchat', + } + }) + end + ''; + ft = [ "mchat" ]; + + keys = [ + { + bind = "d"; + cmd = ":Mdelete"; + opts = { + mode = "n"; + }; + } + { + bind = "s"; + cmd = ":Mselect"; + opts = { + mode = "n"; + }; + } + { + bind = ""; + cmd = ":Mchat"; + opts = { + mode = "n"; + }; + } + ]; + + config = '' + function() + require('model.providers.llamacpp').setup({ + binary = '/home/derped/.nix-profile/bin/llama-server', + models = '/home/derped/llama/models' + }) + + require('model').setup({ + prompts = { + tower = { + provider = llamacpp, + options = { + model = 's', + args = { + '--keep', -1, + '-c', 8192, + '-ngl', 35 + } + } + } + } + }) + end + ''; + } + ]; +} diff --git a/pkgsets/nvim/noice.nix b/pkgsets/nvim/noice.nix new file mode 100644 index 0000000..7fe7426 --- /dev/null +++ b/pkgsets/nvim/noice.nix @@ -0,0 +1,50 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::noice" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + dir = vPlug: vPlug.noice-nvim; + event = [ "VeryLazy" ]; + dependencies = + vPlug: with vPlug; [ + nui-nvim + nvim-notify + ]; + config = # lua + '' + function() + require("noice").setup({ + lsp = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp + }, + }, + -- you can enable a preset for easier configuration + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + -- command_palette = true, -- position the cmdline and popupmenu together + -- long_message_to_split = true, -- long messages will be sent to a split + -- inc_rename = false, -- enables an input dialog for inc-rename.nvim + -- lsp_doc_border = false, -- add a border to hover docs and signature help + }, + }) + end + ''; + } + { + lazy = true; + dir = vPlug: vPlug.nvim-notify; + } + { + dir = vPlug: vPlug.dressing-nvim; + opts = { }; + } + ]; +} diff --git a/pkgsets/nvim/nvim-highlight.nix b/pkgsets/nvim/nvim-highlight.nix new file mode 100644 index 0000000..a1bbc2a --- /dev/null +++ b/pkgsets/nvim/nvim-highlight.nix @@ -0,0 +1,27 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::nvim-highlight" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + lazy = true; + dir = vPlug: vPlug.nvim-highlight-colors; + ft = [ + "css" + "html" + "js" + "jsx" + "ts" + "tsx" + ]; + cmd = [ "HighlighColors" ]; + opts = { + render = "virtual"; + enable_tailwind = true; + }; + } + ]; +} diff --git a/pkgsets/nvim/oil-nvim.nix b/pkgsets/nvim/oil-nvim.nix new file mode 100644 index 0000000..69ec69f --- /dev/null +++ b/pkgsets/nvim/oil-nvim.nix @@ -0,0 +1,18 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::oil-nvim" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + lazy = false; + dir = vPlug: vPlug.oil-nvim; + opts = { + default_file_explorer = true; + delete_to_trash = true; + }; + } + ]; +} diff --git a/pkgsets/nvim/orgmode.nix b/pkgsets/nvim/orgmode.nix new file mode 100644 index 0000000..dca52c6 --- /dev/null +++ b/pkgsets/nvim/orgmode.nix @@ -0,0 +1,40 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::orgmode" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + lazy = true; + dir = vPlug: vPlug.orgmode; + event = [ "VeryLazy" ]; + ft = [ "org" ]; + dependencies = ( + vPlug: with vPlug; [ + vim-table-mode + "akinsho/org-bullets.nvim" + ] + ); + opts = { + org_hide_leading_stars = true; + org_log_done = true; + org_startup_folded = "showeverything"; + org_startup_indented = true; + org_adapt_indentation = false; + org_agenda_files = "~/org/**/*"; + org_default_notes_file = "~/org/refile.org"; + }; + } + { + lazy = true; + short = "akinsho/org-bullets.nvim"; + opts = { }; + } + { + lazy = true; + dir = vPlug: vPlug.vim-table-mode; + } + ]; +} diff --git a/pkgsets/nvim/otter.nix b/pkgsets/nvim/otter.nix new file mode 100644 index 0000000..1ab4832 --- /dev/null +++ b/pkgsets/nvim/otter.nix @@ -0,0 +1,16 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::otter" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + lazy = true; + ft = [ ]; + dir = vPlug: vPlug.otter-nvim; + opts = { }; + } + ]; +} diff --git a/pkgsets/nvim/sniprun.nix b/pkgsets/nvim/sniprun.nix new file mode 100644 index 0000000..5530fbd --- /dev/null +++ b/pkgsets/nvim/sniprun.nix @@ -0,0 +1,53 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::sniprun" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + lazy = true; + dir = vPlug: vPlug.sniprun; + ft = [ + "md" + "adoc" + "org" + "go" + "py" + ]; + cmd = [ "SnipRun" ]; + opts = { + live_mode_toggle = "enable"; + # TODO: This does not work, maybe open an issue + # selected_interpreters = [ "Python3_fifo" ]; + repl_enable = [ "Python3_original" ]; + display = [ "TerminalWithCode" ]; + }; + keys = [ + { + bind = "sr"; + cmd = "SnipRun"; + opts = { + desc = "Run snippet."; + mode = [ + "n" + "v" + ]; + }; + } + { + bind = "sq"; + cmd = "SnipClose"; + opts = { + desc = "Stop running interpreters."; + mode = [ + "n" + "v" + ]; + }; + } + ]; + } + ]; +} diff --git a/pkgsets/nvim/telescope.nix b/pkgsets/nvim/telescope.nix new file mode 100644 index 0000000..50c8f13 --- /dev/null +++ b/pkgsets/nvim/telescope.nix @@ -0,0 +1,79 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::telescope" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + lazy = true; + dir = vPlug: vPlug.telescope-nvim; + dependencies = ( + vPlug: with vPlug; [ + plenary-nvim + "ghassan0/telescope-glyph.nvim" + "xiyaowong/telescope-emoji.nvim" + ] + ); + keys = [ + { + bind = "ff"; + cmd = "Telescope find_files"; + opts = { + desc = "Telescope Find Files"; + }; + } + { + bind = "fg"; + cmd = "Telescope git_files"; + opts = { + desc = "Telescope Git Files"; + }; + } + { + bind = "fw"; + cmd = "Telescope grep_string"; + opts = { + desc = "Telescope Grep Cursor Word"; + }; + } + { + bind = "fr"; + cmd = "Telescope live_grep"; + opts = { + desc = "Telescope Grep Files"; + }; + } + { + bind = "fc"; + cmd = "Telescope glyph"; + opts = { + desc = "Telescope find glyphs"; + }; + } + { + bind = "fe"; + cmd = "Telescope emoji"; + opts = { + desc = "Telescope find emoju"; + }; + } + ]; + } + { + lazy = true; + short = "ghassan0/telescope-glyph.nvim"; + } + { + lazy = true; + short = "xiyaowong/telescope-emoji.nvim"; + } + { + short = "nvim-lua/plenary.nvim"; + # 2d9b06177a975543726ce5c73fca176cedbffe9d + # dir = vPlug: vPlug.plenary-nvim; + lazy = true; + } + ]; +} diff --git a/pkgsets/nvim/tmux-navigate.nix b/pkgsets/nvim/tmux-navigate.nix new file mode 100644 index 0000000..4fca782 --- /dev/null +++ b/pkgsets/nvim/tmux-navigate.nix @@ -0,0 +1,46 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::tmux-navigate" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + dir = vPlug: vPlug.vim-tmux-navigator; + cmd = [ + "TmuxNavigateLeft" + "TmuxNavigateDown" + "TmuxNavigateUp" + "TmuxNavigateRight" + "TmuxNavigatePrevious" + ]; + keys = [ + { + bind = ""; + cmd = "TmuxNavigateLeft"; + } + { + bind = ""; + cmd = "TmuxNavigateDown"; + } + { + bind = ""; + cmd = "TmuxNavigateUp"; + } + { + bind = ""; + cmd = "TmuxNavigateRight"; + } + { + bind = ""; + cmd = "TmuxNavigateNext"; + } + { + bind = ""; + cmd = "TmuxNavigatePrevious"; + } + ]; + } + ]; +} diff --git a/pkgsets/nvim/treesitter.nix b/pkgsets/nvim/treesitter.nix new file mode 100644 index 0000000..102a630 --- /dev/null +++ b/pkgsets/nvim/treesitter.nix @@ -0,0 +1,69 @@ +{ + lib, + config, + pkgs, + ... +}: + +lib.mkIf (lib.elem "nvim::treesitter" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = + let + org-grammar = pkgs.tree-sitter.buildGrammar { + language = "org"; + version = "1.0"; + src = pkgs.fetchFromGitHub { + owner = "nvim-orgmode"; + repo = "tree-sitter-org"; + rev = "436c2dec440e6ad40be98f3b712537bbb08bef0b"; + hash = "sha256-k/i+7/K6puXg554BWSLHIDlOXElUovOwOEe5i1Q95L8="; + }; + }; + # all grammars except replace org-mode + treesitter = pkgs.vimPlugins.nvim-treesitter.withPlugins ( + _: + (lib.filter (grammar: grammar.pname != "org-grammar") pkgs.vimPlugins.nvim-treesitter.allGrammars) + ++ [ org-grammar ] + ); + #treesitter = pkgs.vimPlugins.nvim-treesitter.withAllGrammars; + grammars = pkgs.symlinkJoin { + name = "treesitter-parsers"; + paths = treesitter.dependencies; + }; + in + [ + { + lazy = false; + dir = treesitter; + event = [ + "BufReadPost" + "BufWritePost" + "BufNewFile" + "VeryLazy" + ]; + config = # lua + '' + function() + vim.opt.rtp:prepend("${grammars}") + require("nvim-treesitter.configs").setup({ + auto_install = false, + highlight = { + enable = true, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", -- set to `false` to disable one of the mappings + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, + indent = { + enable = true + } + }) + end + ''; + } + ]; +} diff --git a/pkgsets/nvim/trim.nix b/pkgsets/nvim/trim.nix new file mode 100644 index 0000000..9c7b693 --- /dev/null +++ b/pkgsets/nvim/trim.nix @@ -0,0 +1,16 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::trim" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + lazy = true; + event = [ "BufWritePre" ]; + dir = vPlug: vPlug.trim-nvim; + config = true; + } + ]; +} diff --git a/pkgsets/nvim/undotree.nix b/pkgsets/nvim/undotree.nix new file mode 100644 index 0000000..f04a1ab --- /dev/null +++ b/pkgsets/nvim/undotree.nix @@ -0,0 +1,23 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::undotree" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + lazy = true; + dir = vPlug: vPlug.undotree; + keys = [ + { + bind = "u"; + cmd = "UndotreeToggle"; + opts = { + desc = "Toggle Undotree"; + }; + } + ]; + } + ]; +} diff --git a/pkgsets/nvim/which-key.nix b/pkgsets/nvim/which-key.nix new file mode 100644 index 0000000..19a042f --- /dev/null +++ b/pkgsets/nvim/which-key.nix @@ -0,0 +1,36 @@ +{ + lib, + config, + ... +}: + +lib.mkIf (lib.elem "nvim::which-key" config.machine.pkgs) { + programs.nvim-lazy.lazyPlugins = [ + { + dir = vPlug: vPlug.which-key-nvim; + event = [ "VeryLazy" ]; + keys = [ + { + bind = "?"; + cmdIsFunction = true; + cmd = # lua + '' + function() + require("which-key").show({ global = false }) + end + ''; + opts = { + desc = "Buffer Local Keymaps (which-key)"; + }; + } + ]; + init = # lua + '' + function() + vim.o.timeout = off + vim.o.ttimeout = off + end + ''; + } + ]; +}