diff --git a/config/programs/vim/modules/lsp/lsp.nix b/config/programs/vim/modules/lsp/lsp.nix new file mode 100644 index 00000000..63f644a4 --- /dev/null +++ b/config/programs/vim/modules/lsp/lsp.nix @@ -0,0 +1,42 @@ +{ + pkgs, + lib, + config, + ... +}: +with builtins; +with lib; let + settingsFormat = pkgs.formats.json {}; +in { + config = { + extraLua = let + json_setup = settingsFormat.generate "nix-neovim-lsp-server-setup.json" config.lspconfig; + in + if config.isDesktop + then '' + local from_json = require('nix-neovim.utils').from_json + for k, v in pairs(from_json("${json_setup})) do + require("lspconfig")[k].setup(v) + end + '' + else ""; + output.path.path = + if config.isDesktop + then config.lspconfigPath + else []; + }; + + options.lspconfig = mkOption { + type = with types; attrsOf (submodule {freeformType = settingsFormat.type;}); + default = {}; + description = '' + A set of options to `require("lspconfig").KEY.setup(VALUE)` in lua. + ''; + }; + + options.lspconfigPath = mkOption { + type = with types; listOf package; + default = []; + description = "lspconfig binaries."; + }; +} diff --git a/config/programs/vim/modules/lsp/misc.nix b/config/programs/vim/modules/lsp/misc.nix new file mode 100644 index 00000000..52ea2012 --- /dev/null +++ b/config/programs/vim/modules/lsp/misc.nix @@ -0,0 +1,46 @@ +{pkgs, ...}: { + lspconfigPath = with pkgs; [ + nodePackages.bash-language-server + clang + clang-tools + cmake-language-server + dhall-lsp-server + nodePackages.diagnostic-languageserver + nodePackages.dockerfile-language-server-nodejs + elixir-ls + gopls + haskell-language-server + nodePackages.vscode-css-languageserver-bin + nodePackages.vscode-html-languageserver-bin + nodePackages.vscode-json-languageserver + ltex-ls + lua-language-server + marksman + nil + pyright + nodePackages.typescript + nodePackages.typescript-language-server + nodePackages.vim-language-server + ]; + lspconfig = { + bashls = {}; + clangd = {}; + cmake = {}; + cssls = {}; + dhall_lsp_server = {}; + diagnosticls = {}; + dockerls = {}; + elixirls.cmd = "elixir-ls"; + gopls = {}; + hls.filetypes = ["haskell" "lhaskell" "cabal"]; + html = {}; + jsonls = {}; + ltex = {}; + lua_ls = {}; + marksman = {}; + nil_ls = {}; + pyright = {}; + tsserver = {}; + vimls = {}; + }; +} diff --git a/config/programs/vim/modules/lsp/rust-analyzer.nix b/config/programs/vim/modules/lsp/rust-analyzer.nix new file mode 100644 index 00000000..4c6bc3c6 --- /dev/null +++ b/config/programs/vim/modules/lsp/rust-analyzer.nix @@ -0,0 +1,8 @@ +{pkgs, ...}: { + lspconfigPath = with pkgs; [ + rust-analyzer + ]; + lspconfig = { + rust_analyzer = {}; + }; +}