From 13fda9ebf6e7f84925cb7909b41adc4e8fab8e43 Mon Sep 17 00:00:00 2001 From: 4o1x5 <4o1x5@4o1x5.dev> Date: Thu, 12 Dec 2024 20:52:04 +0100 Subject: [PATCH] Split the lsp into a new directory and also added linters, stole straight from akari's config --- config/options.nix | 3 +- config/plugins/default.nix | 1 + config/plugins/lang/csharp.nix | 9 ++++ config/plugins/lang/css.nix | 34 ++++++++++++ config/plugins/lang/default.nix | 16 ++++++ config/plugins/lang/docker.nix | 21 ++++++++ config/plugins/lang/html.nix | 44 ++++++++++++++++ config/plugins/lang/json.nix | 32 ++++++++++++ config/plugins/lang/nix.nix | 36 +++++++++++++ config/plugins/lang/rust.nix | 24 +++++++++ config/plugins/lang/ts.nix | 92 +++++++++++++++++++++++++++++++++ config/plugins/lang/yaml.nix | 15 ++++++ config/plugins/lsp/default.nix | 31 ----------- 13 files changed, 325 insertions(+), 33 deletions(-) create mode 100644 config/plugins/lang/csharp.nix create mode 100644 config/plugins/lang/css.nix create mode 100644 config/plugins/lang/default.nix create mode 100644 config/plugins/lang/docker.nix create mode 100644 config/plugins/lang/html.nix create mode 100644 config/plugins/lang/json.nix create mode 100644 config/plugins/lang/nix.nix create mode 100644 config/plugins/lang/rust.nix create mode 100644 config/plugins/lang/ts.nix create mode 100644 config/plugins/lang/yaml.nix diff --git a/config/options.nix b/config/options.nix index 92460d2..efcc818 100644 --- a/config/options.nix +++ b/config/options.nix @@ -1,7 +1,7 @@ { pkgs, ... }: { colorschemes.oxocarbon.enable = true; - colorscheme = "shades_of_purple"; + colorscheme = "oxocarbon"; opts = { number = true; @@ -11,5 +11,4 @@ # Set as leader globals.mapleader = " "; - } diff --git a/config/plugins/default.nix b/config/plugins/default.nix index eeb8590..a7e18f7 100644 --- a/config/plugins/default.nix +++ b/config/plugins/default.nix @@ -4,6 +4,7 @@ ./telescope ./ui ./aw + ./lang ]; # Persistence diff --git a/config/plugins/lang/csharp.nix b/config/plugins/lang/csharp.nix new file mode 100644 index 0000000..7fae402 --- /dev/null +++ b/config/plugins/lang/csharp.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: +{ + plugins = { + + # TODO lint + lsp.servers.csharp_ls.enable = true; + }; +} + diff --git a/config/plugins/lang/css.nix b/config/plugins/lang/css.nix new file mode 100644 index 0000000..6a01b02 --- /dev/null +++ b/config/plugins/lang/css.nix @@ -0,0 +1,34 @@ +{ pkgs, lib, ... }: +{ + plugins = { + conform-nvim.settings = { + formatters_by_ft.css = [ + "prettierd" + "prettier" + ]; + + formatters = { + prettierd.command = "${pkgs.prettierd}/bin/prettierd"; + prettier.command = "${pkgs.nodePackages.prettier}/bin/prettier"; + }; + }; + + lsp.servers = { + cssls = { + enable = true; + cmd = [ + "${pkgs.vscode-langservers-extracted}/bin/vscode-css-language-server" + "--stdio" + ]; + }; + + tailwindcss = { + enable = true; + cmd = [ + (lib.getExe pkgs.tailwindcss-language-server) + "--stdio" + ]; + }; + }; + }; +} diff --git a/config/plugins/lang/default.nix b/config/plugins/lang/default.nix new file mode 100644 index 0000000..bcb0e51 --- /dev/null +++ b/config/plugins/lang/default.nix @@ -0,0 +1,16 @@ +{ pkgs, ... }: { + + imports = [ + ./css.nix + ./docker.nix + ./html.nix + ./json.nix + ./nix.nix + ./rust.nix + ./ts.nix + ./yaml.nix + ./csharp.nix + # TODO elixir + # TODO java + ]; +} diff --git a/config/plugins/lang/docker.nix b/config/plugins/lang/docker.nix new file mode 100644 index 0000000..96e8ae3 --- /dev/null +++ b/config/plugins/lang/docker.nix @@ -0,0 +1,21 @@ +{ pkgs, ... }: +{ + plugins = { + lsp.servers = { + dockerls.enable = true; + docker_compose_language_service.enable = true; + }; + + lint = { + lintersByFt = { + docker = [ "hadolint" ]; + }; + + linters = { + hadolint = { + cmd = "${pkgs.hadolint}/bin/hadolint"; + }; + }; + }; + }; +} diff --git a/config/plugins/lang/html.nix b/config/plugins/lang/html.nix new file mode 100644 index 0000000..0effa98 --- /dev/null +++ b/config/plugins/lang/html.nix @@ -0,0 +1,44 @@ +{ pkgs, lib, ... }: +{ + plugins = { + conform-nvim.settings = { + formatters_by_ft.html = [ + "prettierd" + "prettier" + ]; + + formatters = { + prettierd.command = "${pkgs.prettierd}/bin/prettierd"; + prettier.command = "${pkgs.nodePackages.prettier}/bin/prettier"; + }; + }; + + lsp = { + servers = { + html = { + enable = true; + cmd = [ + "${pkgs.vscode-langservers-extracted}/bin/vscode-html-language-server" + "--stdio" + ]; + }; + # TODO fix + # error: The option `plugins.lsp.servers.vuels.package' was accessed but has no value defined. Try setting the option. + #vuels.enable = true; # Vue + }; + + enabledServers = [ + { + name = "emmet_language_server"; + extraOptions = { + cmd = [ + (lib.getExe pkgs.emmet-language-server) + "--stdio" + ]; + filetypes = [ "html" ]; + }; + } + ]; + }; + }; +} diff --git a/config/plugins/lang/json.nix b/config/plugins/lang/json.nix new file mode 100644 index 0000000..351feb3 --- /dev/null +++ b/config/plugins/lang/json.nix @@ -0,0 +1,32 @@ +{ pkgs, ... }: +{ + plugins = { + conform-nvim.settings = { + formatters_by_ft = { + json = [ "jq" ]; + }; + + formatters = { + jq = { + command = "${pkgs.jq}/bin/jq"; + }; + }; + }; + + lint = { + lintersByFt = { + json = [ "jsonlint" ]; + }; + + linters = { + jsonlint = { + cmd = "${pkgs.nodePackages_latest.jsonlint}/bin/jsonlint"; + }; + }; + }; + + lsp.servers.jsonls = { + enable = true; + }; + }; +} diff --git a/config/plugins/lang/nix.nix b/config/plugins/lang/nix.nix new file mode 100644 index 0000000..f979c66 --- /dev/null +++ b/config/plugins/lang/nix.nix @@ -0,0 +1,36 @@ +{ pkgs, ... }: +{ + plugins = { + nix.enable = true; + hmts.enable = true; + nix-develop.enable = true; + + conform-nvim.settings = { + formatters_by_ft = { + nix = [ "nixfmt-rfc-style" ]; + }; + + formatters = { + nixfmt-rfc-style = { + command = "${pkgs.nixfmt-rfc-style}/bin/nixfmt"; + }; + }; + }; + + lint = { + lintersByFt = { + nix = [ "statix" ]; + }; + + linters = { + statix = { + cmd = "${pkgs.statix}/bin/statix"; + }; + }; + }; + }; + + extraConfigVim = '' + au BufRead,BufNewFile flake.lock setf json + ''; +} diff --git a/config/plugins/lang/rust.nix b/config/plugins/lang/rust.nix new file mode 100644 index 0000000..ce5eda8 --- /dev/null +++ b/config/plugins/lang/rust.nix @@ -0,0 +1,24 @@ +{ pkgs, ... }: +{ + plugins = { + lsp.servers.rust-analyzer = { + enable = true; + # Flip these in case rust is installed systemvise + installRustc = false; + installCargo = false; + settings.completion.callable.snippets = "add_parentheses"; + }; + + lint = { + lintersByFt = { + rust = [ "cargo" ]; + }; + + linters = { + cargo = { + cmd = "${pkgs.rustfmt}/bin/cargo-fmt"; + }; + }; + }; + }; +} diff --git a/config/plugins/lang/ts.nix b/config/plugins/lang/ts.nix new file mode 100644 index 0000000..a4fdef6 --- /dev/null +++ b/config/plugins/lang/ts.nix @@ -0,0 +1,92 @@ +{ pkgs, ... }: +{ + + plugins = { + conform-nvim.settings = { + formatters_by_ft = { + javascript = [ "eslint_d" ]; + javascriptreact = [ "eslint_d" ]; + typescript = [ "eslint_d" ]; + typescriptreact = [ "eslint_d" ]; + svelte = [ "eslint_d" ]; + }; + + formatters.eslint_d = { + command = "${pkgs.eslint_d}/bin/eslint_d"; + }; + }; + + lsp.servers = { + svelte.enable = true; + + eslint = { + enable = true; + filetypes = [ + "javascript" + "javascriptreact" + "javascript.jsx" + "typescript" + "typescriptreact" + "typescript.tsx" + "vue" + "html" + "markdown" + "json" + "jsonc" + "yaml" + "toml" + "xml" + "gql" + "graphql" + "svelte" + "css" + "less" + "scss" + "pcss" + "postcss" + ]; + }; + + ts_ls = { + enable = true; + filetypes = [ + "javascript" + "javascriptreact" + "typescript" + "typescriptreact" + "svelte" + ]; + + settings = { + complete_function_calls = true; + vtsls = { + autoUseWorkspaceTsdk = true; + experimental = { + completion = { + enableServerSideFuzzyMatch = true; + }; + }; + }; + + typescript = { + updateImportsOnFileMove.enabled = "always"; + suggest = { + completeFunctionCalls = true; + }; + + inlayHints = { + enumMemberValues.enabled = true; + functionLikeReturnTypes.enabled = true; + parameterNames.enabled = "literals"; + parameterTypes.enabled = true; + propertyDeclarationTypes.enabled = true; + variableType.enabled = false; + }; + }; + }; + }; + }; + + ts-autotag.enable = true; + }; +} diff --git a/config/plugins/lang/yaml.nix b/config/plugins/lang/yaml.nix new file mode 100644 index 0000000..9485eee --- /dev/null +++ b/config/plugins/lang/yaml.nix @@ -0,0 +1,15 @@ +{ + plugins.lsp.servers.yamlls = { + enable = true; + extraOptions = { + capabilities = { + textDocument = { + foldingRange = { + dynamicRegistration = false; + lineFoldingOnly = true; + }; + }; + }; + }; + }; +} diff --git a/config/plugins/lsp/default.nix b/config/plugins/lsp/default.nix index e473361..2a1359e 100644 --- a/config/plugins/lsp/default.nix +++ b/config/plugins/lsp/default.nix @@ -66,37 +66,6 @@ plugins.lsp = { enable = true; - servers = { - ts_ls.enable = true; # TS/JS - cssls.enable = true; # CSS - tailwindcss.enable = true; # TailwindCSS - html.enable = true; # HTML - astro.enable = true; # AstroJS - phpactor.enable = true; # PHP - svelte.enable = false; # Svelte - vuels.enable = false; # Vue - pyright.enable = true; # Python - marksman.enable = true; # Markdown - nil_ls.enable = true; # Nix - dockerls.enable = true; # Docker - bashls.enable = true; # Bash - clangd.enable = true; # C/C++ - csharp_ls.enable = true; # C# - yamlls.enable = true; # YAML - lua_ls = { - enable = true; - settings.telemetry.enable = false; - }; - - #Rust - rust-analyzer = { - enable = true; - # Flip these in case rust is installed systemvise - installRustc = false; - installCargo = false; - settings.completion.callable.snippets = "add_parentheses"; - }; - }; }; plugins.none-ls = {