diff --git a/neovim/configs/default.nix b/neovim/configs/default.nix new file mode 100644 index 0000000..67e4457 --- /dev/null +++ b/neovim/configs/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./language-server.nix + ./line-limiter.nix + ]; +} diff --git a/neovim/configs/language-server.nix b/neovim/configs/language-server.nix new file mode 100644 index 0000000..fff32a4 --- /dev/null +++ b/neovim/configs/language-server.nix @@ -0,0 +1,56 @@ +{ config, lib, ... }: + +let inherit (lib.nix2lua) call; in +{ + fn.lspconfig-eslint-on-attach = { + args = [ "client" "bufnr" ]; + content = { bufnr, ... }: { + vim.augroup.eslint-fix = { + event = "BufWritePre"; + buffer = bufnr; + command = "silent! EslintFixAll"; + }; + }; + }; + + plugins.language-server.lspconfig.serverSettings = { + nil_ls = { }; + rust_analyzer = { + settings.rust-analyzer = { + "server.path" = "rust-analyzer"; + "updates.prompt" = false; + "updates.checkOnStartup" = false; + "checkOnSave.enable" = true; + "checkOnSave.command" = "clippy"; + "cargo.autoreload" = true; + }; + }; + tsserver = rec { + filetypes = [ "javascript" "javascriptreact" "typescript" "typescriptreact" "vue" ]; + init_options.plugins = [ + { + name = "@vue/typescript-plugin"; + location = "./node_modules/@vue/typescript-plugin"; + languages = filetypes; + } + ]; + }; + eslint = { + on_attach = config.fn.lspconfig-eslint-on-attach.lambda; + }; + volar = { + init_options = { + typescript.tsdk = "./node_modules/typescript/lib"; + }; + }; + ltex = { + language = "en-US"; + languageToolHttpServerUri = "http://localhost:8081"; + }; + pylsp = { }; + denols = { + root_dir = call "${config.plugin.nvim-lspconfig.varName}.util.root_pattern" [ "deno.json" "deno.jsonc" ]; + }; + jdtls = { cmd = [ "jdtls" ]; }; + }; +} diff --git a/neovim/configs/line-limiter.nix b/neovim/configs/line-limiter.nix new file mode 100644 index 0000000..86fccca --- /dev/null +++ b/neovim/configs/line-limiter.nix @@ -0,0 +1,48 @@ +{ lib, ... }: + +let + mkLineLimiterOpts = limit: { + colorcolumn = toString (limit + 1); + textwidth = limit; + }; + + mkLineLimiterGroup = { limit, pattern }: + lib.nameValuePair + "line-limiter-${toString limit}" + { + inherit pattern; + opt = mkLineLimiterOpts limit; + }; +in +{ + buffer.filetype = lib.listToAttrs [ + (mkLineLimiterGroup { + limit = 100; + pattern = [ + "nix" + "javascript,javascriptreact" + "typescript,typescriptreact" + "vue" + "rust" + "haskell" + ]; + }) + (mkLineLimiterGroup { + limit = 90; + pattern = [ + "python" + ]; + }) + (mkLineLimiterGroup { + limit = 80; + pattern = [ + "json" + "yaml" + "markdown" + "html,htmldjango" + "css,scss,less" + "sql,psql" + ]; + }) + ]; +} diff --git a/neovim/dev.nix b/neovim/dev.nix index f48dbdb..3a08885 100644 --- a/neovim/dev.nix +++ b/neovim/dev.nix @@ -1,26 +1,16 @@ -{ config, modulesPath, lib, pkgs, ... }: +{ modulesPath, lib, pkgs, ... }: let inherit (lib.mod) ctrl; - inherit (lib.nix2lua) pipe1 require call call0 nf var; + inherit (lib.nix2lua) pipe1 require call0 nf var; - mkLineLimiterOpts = limit: { - colorcolumn = toString (limit + 1); - textwidth = limit; - }; - - mkLineLimiterGroup = { limit, pattern }: - lib.nameValuePair - "line-limiter-${toString limit}" - { - inherit pattern; - opt = mkLineLimiterOpts limit; - }; in { imports = [ "${modulesPath}/profiles/recommended.nix" ./snippets.nix + ./configs + ./plugins ]; vim.opt = { @@ -33,36 +23,7 @@ in pattern = [ "txt" "markdown" "mail" "man" ]; opt = { formatoptions = "tcroqwanjp"; }; }; - } // lib.listToAttrs [ - (mkLineLimiterGroup { - limit = 100; - pattern = [ - "nix" - "javascript,javascriptreact" - "typescript,typescriptreact" - "vue" - "rust" - "haskell" - ]; - }) - (mkLineLimiterGroup { - limit = 90; - pattern = [ - "python" - ]; - }) - (mkLineLimiterGroup { - limit = 80; - pattern = [ - "json" - "yaml" - "markdown" - "html,htmldjango" - "css,scss,less" - "sql,psql" - ]; - }) - ]; + }; filetype.detect = { d2 = "*.d2"; @@ -73,18 +34,6 @@ in # Enable fast navigation between windows vim.keymap.set = map (k: { mode = "n"; lhs = ctrl k; rhs = "${ctrl "w"}${k}"; }) [ "h" "l" "j" "k" ]; - plugin.ollama-nvim = { - enable = true; - name = "ollama"; - setupSettings = { }; - }; - - plugin.nlsp-settings-nvim = { - enable = true; - name = "nlspsettings"; - setupSettings = { }; - }; - plugins.style.nvim-treesitter.extraGrammars = { tree-sitter-d2 = rec { language = "d2"; @@ -128,58 +77,6 @@ in }; }; - fn.lspconfig-eslint-on-attach = { - args = [ "client" "bufnr" ]; - content = { bufnr, ... }: { - vim.augroup.eslint-fix = { - event = "BufWritePre"; - buffer = bufnr; - command = "silent! EslintFixAll"; - }; - }; - }; - - plugins.language-server.lspconfig.serverSettings = { - nil_ls = { }; - rust_analyzer = { - settings.rust-analyzer = { - "server.path" = "rust-analyzer"; - "updates.prompt" = false; - "updates.checkOnStartup" = false; - "checkOnSave.enable" = true; - "checkOnSave.command" = "clippy"; - "cargo.autoreload" = true; - }; - }; - tsserver = rec { - filetypes = [ "javascript" "typescript" "vue" ]; - init_options.plugins = [ - { - name = "@vue/typescript-plugin"; - location = "./node_modules/@vue/typescript-plugin"; - languages = filetypes; - } - ]; - }; - eslint = { - on_attach = config.fn.lspconfig-eslint-on-attach.lambda; - }; - volar = { - init_options = { - typescript.tsdk = "./node_modules/typescript/lib"; - }; - }; - ltex = { - language = "en-US"; - languageToolHttpServerUri = "http://localhost:8081"; - }; - pylsp = { }; - denols = { - root_dir = call "${config.plugin.nvim-lspconfig.varName}.util.root_pattern" [ "deno.json" "deno.jsonc" ]; - }; - jdtls = { cmd = [ "jdtls" ]; }; - }; - plugins.snippet.luasnip.settings = { ext_opts = [ (nf (var "luasnip_types.choiceNode") { diff --git a/neovim/plugins/default.nix b/neovim/plugins/default.nix new file mode 100644 index 0000000..d1f6226 --- /dev/null +++ b/neovim/plugins/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./ollama.nix + ./nlsp-settings.nix + ]; +} diff --git a/neovim/plugins/nlsp-settings.nix b/neovim/plugins/nlsp-settings.nix new file mode 100644 index 0000000..c721f27 --- /dev/null +++ b/neovim/plugins/nlsp-settings.nix @@ -0,0 +1,7 @@ +{ + plugin.nlsp-settings-nvim = { + enable = true; + name = "nlspsettings"; + setupSettings = { }; + }; +} diff --git a/neovim/plugins/ollama.nix b/neovim/plugins/ollama.nix new file mode 100644 index 0000000..d4adc80 --- /dev/null +++ b/neovim/plugins/ollama.nix @@ -0,0 +1,7 @@ +{ + plugin.ollama-nvim = { + enable = true; + name = "ollama"; + setupSettings = { }; + }; +}