diff options
| author | Hirokazu Hata <h.hata.ai.t@gmail.com> | 2020-05-18 13:55:06 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-18 13:55:06 +0900 |
| commit | c5c3ab26b3d3b00967c3ef414e6d8d2231afa647 (patch) | |
| tree | 1a734a97af24738f99dbd18a674f651896459916 /lua | |
| parent | Merge pull request #240 from h-michael/metals (diff) | |
| parent | Init rnix (diff) | |
| download | nvim-lspconfig-c5c3ab26b3d3b00967c3ef414e6d8d2231afa647.tar nvim-lspconfig-c5c3ab26b3d3b00967c3ef414e6d8d2231afa647.tar.gz nvim-lspconfig-c5c3ab26b3d3b00967c3ef414e6d8d2231afa647.tar.bz2 nvim-lspconfig-c5c3ab26b3d3b00967c3ef414e6d8d2231afa647.tar.lz nvim-lspconfig-c5c3ab26b3d3b00967c3ef414e6d8d2231afa647.tar.xz nvim-lspconfig-c5c3ab26b3d3b00967c3ef414e6d8d2231afa647.tar.zst nvim-lspconfig-c5c3ab26b3d3b00967c3ef414e6d8d2231afa647.zip | |
Add rnix-lsp (#234)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim_lsp/rnix.lua | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/lua/nvim_lsp/rnix.lua b/lua/nvim_lsp/rnix.lua new file mode 100644 index 00000000..50acc2ec --- /dev/null +++ b/lua/nvim_lsp/rnix.lua @@ -0,0 +1,81 @@ +local configs = require 'nvim_lsp/configs' +local util = require 'nvim_lsp/util' + +local name = "rnix" + +local function make_installer() + local P = util.path.join + local install_dir = P{util.base_install_dir, name} + + local bin = P{install_dir, "bin", "rnix-lsp"} + local cmd = {bin} + + local X = {} + function X.install() + local install_info = X.info() + if install_info.is_installed then + print(name, "is already installed") + return + end + if not (util.has_bins("cargo")) then + error('Need "cargo" to install this.') + return + end + + local install_cmd = "cargo install rnix-lsp --root=" .. install_info.install_dir .. " rnix-lsp" + + vim.fn.system(install_cmd) + end + function X.info() + return { + is_installed = util.path.exists(bin); + install_dir = install_dir; + cmd = cmd; + } + end + function X.configure(config) + local install_info = X.info() + if install_info.is_installed then + config.cmd = cmd + end + end + return X +end + +local installer = make_installer() + +configs[name] = { + + default_config = { + cmd = {"rnix-lsp"}; + filetypes = {"nix"}; + root_dir = function(fname) + return util.find_git_ancestor(fname) or vim.loop.os_homedir() + end; + settings = { + }; + on_new_config = function(config) + installer.configure(config) + end; + init_options = { + }; + }; + docs = { + description = [[ +https://github.com/nix-community/rnix-lsp + +A language server for Nix providing basic completion and formatting via nixpkgs-fmt. + +To install manually, run `cargo install rnix-lsp`. If you are using nix, rnix-lsp is in nixpkgs. + +This server accepts configuration via the `settings` key. + + ]]; + default_config = { + root_dir = "vim's starting directory"; + }; + }; +}; + +configs[name].install = installer.install +configs[name].install_info = installer.info |
