1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 12:50:04 +08:00

perf(lspconfig): update bundle lspconfig

This commit is contained in:
wsdjeg 2022-09-10 19:50:22 +08:00
parent 9aa3de5561
commit d746dabfec
50 changed files with 2256 additions and 328 deletions

View File

@ -24,5 +24,5 @@ jobs:
if: ${{ github.head_ref == 'master' }}
run: |
gh pr close $PR_NUMBER
gh pr comment $PR_NUMBER --body "This pull request has been automatically closed. Please develop on a feature branch. Thank you."
gh pr comment $PR_NUMBER --body "Please develop on a feature branch. See https://github.com/neovim/nvim-lspconfig/pull/1464 for background."
exit 1

View File

@ -4,6 +4,7 @@
cache = true
ignore = {
"122", -- Setting a read-only field of a global variable.
"212", -- Unused argument, In the case of callback function, _arg_name is easier to understand than _, so this option is set to off.
"631", -- max_line_length, vscode pkg URL is too long
}

View File

@ -215,18 +215,40 @@ The global defaults for all servers can be overridden by extending the
if params and params.type <= vim.lsp.protocol.MessageType.Log then
vim.lsp.handlers["window/logMessage"](err, method, params, client_id)
end
end;
end,
["window/showMessage"] = function(err, method, params, client_id)
if params and params.type <= vim.lsp.protocol.MessageType.Warning.Error then
vim.lsp.handlers["window/showMessage"](err, method, params, client_id)
end
end;
end,
}
}
)
<
`setup {}` can additionally override these defaults in subsequent calls.
==============================================================================
SETUP HOOK *lspconfig-setup-hook*
`lspconfig` will execute the `on_setup` hook for each setup call to a server after
validating its configuration, and before attempting to launch the server
itself. One typical usage is to allow ad-hoc substitution for any
configuration entry, such as `cmd`.
>
local lspconfig = require 'lspconfig'
lspconfig.util.on_setup = util.add_hook_before(lspconfig.util.on_setup, function(config)
if some_condition and config.name == "clangd" then
local custom_server_prefix = "/my/custom/server/prefix"
config.cmd = { custom_server_prefix .. "/bin/clangd" }
end
end)
Note: This is primarily targeted at plugins developers, so make sure to use
`util.add_hook_before()` as a wrapper instead of overriding the original function
completely, to void breaking external integrations with lspconfig.
==============================================================================
SERVER CONFIGURATIONS *lspconfig-configurations*
@ -242,35 +264,49 @@ The `configs` module is a singleton where configs are defined. The schema for
validating using `vim.validate` is:
>
configs.SERVER_NAME = {
default_config = {'t'};
on_new_config = {'f', true};
on_attach = {'f', true};
commands = {'t', true};
docs = {'t', true};
default_config = {'t'},
on_new_config = {'f', true},
on_attach = {'f', true},
commands = {'t', true},
docs = {'t', true},
}
<
where the structure of the docs table is as follows:
>
docs = {
description = {'s', true};
default_config = {'t', true};
description = {'s', true},
default_config = {'t', true},
}
<
`commands` is a map of `name:definition` key:value pairs, where `definition`
is a list whose first value is a function implementing the command, and the
rest are either array values which will be formed into flags for the command,
or special keys like `description`. Example:
or special keys like `description`.
Warning: Commands is deprecated and will be removed in future releases.
It is recommended to use `vim.api.nvim_create_user_command()` instead in an `on_attach` function.
Example:
>
commands = {
TexlabBuild = {
function()
buf_build(0)
end;
"-range";
description = "Build the current buffer";
};
};
local function organize_imports()
local params = {
command = 'pyright.organizeimports',
arguments = { vim.uri_from_bufnr(0) },
}
vim.lsp.buf.execute_command(params)
end
local on_attach = function(client, bufnr)
if client.name == "pyright" then
vim.api.nvim_create_user_command("PyrightOrganizeImports", organize_imports, {desc = 'Organize Imports'})
end
end
require("lspconfig")['pyright'].setup({
on_attach = on_attach
})
<
The `configs.__newindex` metamethod consumes the config definition and returns
an object with a `setup()` method, to be invoked by users:
>
@ -283,6 +319,7 @@ Example:
>
configs.texlab.buf_build = buf_build
<
==============================================================================
ADDING NEW SERVERS *lspconfig-new*
@ -298,13 +335,13 @@ The steps for adding and enabling a new server configuration are:
if not configs.foo_lsp then
configs.foo_lsp = {
default_config = {
cmd = {'/home/neovim/lua-language-server/run.sh'};
filetypes = {'lua'};
cmd = {'/home/neovim/lua-language-server/run.sh'},
filetypes = {'lua'},
root_dir = function(fname)
return lspconfig.util.find_git_ancestor(fname)
end;
settings = {};
};
end,
settings = {},
},
}
end
@ -594,6 +631,18 @@ options, the `lspconfig` wiki lists community created plugins that build upon
the built-in client to provide functionality tailored to specific language
servers.
==============================================================================
Highlights *lspconfig-highlight*
LspInfoTitle Client name
LspInfoList Server name list
LspInfoFiletype `filetypes` area
LspInfoTip Tip
LspInfoBorder Window border
To set the border use: >
require('lspconfig.ui.windows').default_options.border = 'single'
< Accepts the same values as the `border` option to |nvim_open_win()|
==============================================================================
vim:tw=78:ts=8:ft=help:norl:

View File

@ -18,6 +18,7 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [beancount](#beancount)
- [bicep](#bicep)
- [bsl_ls](#bsl_ls)
- [bufls](#bufls)
- [ccls](#ccls)
- [clangd](#clangd)
- [clarity_lsp](#clarity_lsp)
@ -29,6 +30,7 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [cssls](#cssls)
- [cssmodules_ls](#cssmodules_ls)
- [cucumber_language_server](#cucumber_language_server)
- [dagger](#dagger)
- [dartls](#dartls)
- [denols](#denols)
- [dhall_lsp_server](#dhall_lsp_server)
@ -53,6 +55,7 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [ghcide](#ghcide)
- [ghdl_ls](#ghdl_ls)
- [glint](#glint)
- [glslls](#glslls)
- [golangci_lint_ls](#golangci_lint_ls)
- [gopls](#gopls)
- [gradle_ls](#gradle_ls)
@ -80,13 +83,18 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [lelwel_ls](#lelwel_ls)
- [lemminx](#lemminx)
- [ltex](#ltex)
- [luau_lsp](#luau_lsp)
- [m68k](#m68k)
- [marksman](#marksman)
- [metals](#metals)
- [mint](#mint)
- [mlir_lsp_server](#mlir_lsp_server)
- [mlir_pdll_lsp_server](#mlir_pdll_lsp_server)
- [mm0_ls](#mm0_ls)
- [nickel_ls](#nickel_ls)
- [nil_ls](#nil_ls)
- [nimls](#nimls)
- [nxls](#nxls)
- [ocamlls](#ocamlls)
- [ocamllsp](#ocamllsp)
- [ols](#ols)
@ -109,10 +117,12 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [pylsp](#pylsp)
- [pyre](#pyre)
- [pyright](#pyright)
- [qml_lsp](#qml_lsp)
- [quick_lint_js](#quick_lint_js)
- [r_language_server](#r_language_server)
- [racket_langserver](#racket_langserver)
- [reason_ls](#reason_ls)
- [relay_lsp](#relay_lsp)
- [remark_ls](#remark_ls)
- [rescriptls](#rescriptls)
- [rls](#rls)
@ -128,6 +138,7 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [solang](#solang)
- [solargraph](#solargraph)
- [solc](#solc)
- [solidity](#solidity)
- [solidity_ls](#solidity_ls)
- [sorbet](#sorbet)
- [sourcekit](#sourcekit)
@ -141,8 +152,10 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [svelte](#svelte)
- [svlangserver](#svlangserver)
- [svls](#svls)
- [syntax_tree](#syntax_tree)
- [tailwindcss](#tailwindcss)
- [taplo](#taplo)
- [tblgen_lsp_server](#tblgen_lsp_server)
- [teal_ls](#teal_ls)
- [terraform_lsp](#terraform_lsp)
- [terraformls](#terraformls)
@ -155,6 +168,7 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [vala_ls](#vala_ls)
- [vdmj](#vdmj)
- [verible](#verible)
- [veridian](#veridian)
- [vimls](#vimls)
- [visualforce_ls](#visualforce_ls)
- [vls](#vls)
@ -246,7 +260,7 @@ require'lspconfig'.angularls.setup{}
```
- `root_dir` :
```lua
root_pattern("angular.json", ".git")
root_pattern("angular.json")
```
@ -722,6 +736,40 @@ require'lspconfig'.bsl_ls.setup{}
```
## bufls
https://github.com/bufbuild/buf-language-server
`buf-language-server` can be installed via `go install`:
```sh
go install github.com/bufbuild/buf-language-server/cmd/bufls@latest
```
bufls is a Protobuf language server compatible with Buf modules and workspaces
**Snippet to enable the language server:**
```lua
require'lspconfig'.bufls.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "bufls", "serve" }
```
- `filetypes` :
```lua
{ "proto" }
```
- `root_dir` :
```lua
root_pattern("buf.work.yaml", ".git")
```
## ccls
https://github.com/MaskRay/ccls/wiki
@ -813,7 +861,7 @@ require'lspconfig'.clangd.setup{}
```
- `filetypes` :
```lua
{ "c", "cpp", "objc", "objcpp", "cuda" }
{ "c", "cpp", "objc", "objcpp", "cuda", "proto" }
```
- `root_dir` :
```lua
@ -865,7 +913,7 @@ require'lspconfig'.clarity_lsp.setup{}
## clojure_lsp
https://github.com/snoe/clojure-lsp
https://github.com/clojure-lsp/clojure-lsp
Clojure Language Server
@ -1182,6 +1230,39 @@ require'lspconfig'.cucumber_language_server.setup{}
```
## dagger
https://github.com/dagger/cuelsp
Dagger's lsp server for cuelang.
**Snippet to enable the language server:**
```lua
require'lspconfig'.dagger.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "cuelsp" }
```
- `filetypes` :
```lua
{ "cue" }
```
- `root_dir` :
```lua
root_pattern("cue.mod", ".git")
```
- `single_file_support` :
```lua
true
```
## dartls
https://github.com/dart-lang/sdk/tree/master/pkg/analysis_server/tool/lsp_spec
@ -1236,7 +1317,7 @@ https://github.com/denoland/deno
Deno's built-in language server
To approrpiately highlight codefences returned from denols, you will need to augment vim.g.markdown_fenced languages
To appropriately highlight codefences returned from denols, you will need to augment vim.g.markdown_fenced languages
in your init.lua. Example:
```lua
@ -1283,10 +1364,6 @@ require'lspconfig'.denols.setup{}
```lua
root_pattern("deno.json", "deno.jsonc", ".git")
```
- `single_file_support` :
```lua
true
```
## dhall_lsp_server
@ -2203,6 +2280,53 @@ require'lspconfig'.glint.setup{}
```
## glslls
https://github.com/svenstaro/glsl-language-server
Language server implementation for GLSL
`glslls` can be compiled and installed manually, or, if your distribution has access to the AUR,
via the `glsl-language-server` AUR package
**Snippet to enable the language server:**
```lua
require'lspconfig'.glslls.setup{}
```
**Default values:**
- `capabilities` :
```lua
{
offsetEncoding = { "utf-8", "utf-16" },
textDocument = {
completion = {
editsNearCursor = true
}
}
}
```
- `cmd` :
```lua
{ "glslls", "--stdin" }
```
- `filetypes` :
```lua
{ "glsl" }
```
- `root_dir` :
```lua
see source file
```
- `single_file_support` :
```lua
true
```
## golangci_lint_ls
Combination of both lint server and client
@ -2269,7 +2393,7 @@ require'lspconfig'.gopls.setup{}
```
- `filetypes` :
```lua
{ "go", "gomod", "gotmpl" }
{ "go", "gomod", "gowork", "gotmpl" }
```
- `root_dir` :
```lua
@ -3321,9 +3445,9 @@ require'lspconfig'.lelwel_ls.setup{}
https://github.com/eclipse/lemminx
The easiest way to install the server is to get a binary at https://download.jboss.org/jbosstools/vscode/stable/lemminx-binary/ and place it in your PATH.
The easiest way to install the server is to get a binary from https://github.com/redhat-developer/vscode-xml/releases and place it on your PATH.
NOTE to macOS users: Binaries from unidentified developers are blocked by default. If you trust the downloaded binary from jboss.org, run it once, cancel the prompt, then remove the binary from Gatekeeper quarantine with `xattr -d com.apple.quarantine lemminx`. It should now run without being blocked.
NOTE to macOS users: Binaries from unidentified developers are blocked by default. If you trust the downloaded binary, run it once, cancel the prompt, then remove the binary from Gatekeeper quarantine with `xattr -d com.apple.quarantine lemminx`. It should now run without being blocked.
@ -3398,6 +3522,31 @@ require'lspconfig'.ltex.setup{}
```
## luau_lsp
**Snippet to enable the language server:**
```lua
require'lspconfig'.luau_lsp.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "luau-lsp", "lsp" }
```
- `filetypes` :
```lua
{ "luau" }
```
- `root_dir` :
```lua
root_pattern(".git")
```
## m68k
https://github.com/grahambates/m68k-lsp
@ -3499,6 +3648,14 @@ require'lspconfig'.metals.setup{}
**Default values:**
- `capabilities` :
```lua
{
workspace = {
configuration = false
}
}
```
- `cmd` :
```lua
{ "metals" }
@ -3561,6 +3718,72 @@ require'lspconfig'.mint.setup{}
```
## mlir_lsp_server
https://mlir.llvm.org/docs/Tools/MLIRLSP/#mlir-lsp-language-server--mlir-lsp-server=
The Language Server for the LLVM MLIR language
`mlir-lsp-server` can be installed at the llvm-project repository (https://github.com/llvm/llvm-project)
**Snippet to enable the language server:**
```lua
require'lspconfig'.mlir_lsp_server.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "mlir-lsp-server" }
```
- `filetypes` :
```lua
{ "mlir" }
```
- `root_dir` :
```lua
see source file
```
- `single_file_support` :
```lua
true
```
## mlir_pdll_lsp_server
https://mlir.llvm.org/docs/Tools/MLIRLSP/#pdll-lsp-language-server--mlir-pdll-lsp-server
The Language Server for the LLVM PDLL language
`mlir-pdll-lsp-server` can be installed at the llvm-project repository (https://github.com/llvm/llvm-project)
**Snippet to enable the language server:**
```lua
require'lspconfig'.mlir_pdll_lsp_server.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "mlir-pdll-lsp-server" }
```
- `filetypes` :
```lua
{ "pdll" }
```
- `root_dir` :
```lua
see source file
```
## mm0_ls
https://github.com/digama0/mm0
@ -3620,7 +3843,7 @@ cd nickel/lsp/nls
cargo install --path .
```
In order to have lspconfig detect Nickel filetypes (a prequisite for autostarting a server),
In order to have lspconfig detect Nickel filetypes (a prerequisite for autostarting a server),
install the [Nickel vim plugin](https://github.com/nickel-lang/vim-nickel).
@ -3646,6 +3869,42 @@ require'lspconfig'.nickel_ls.setup{}
```
## nil_ls
https://github.com/oxalica/nil
A new language server for Nix Expression Language.
If you are using Nix with Flakes support, run `nix profile install github:oxalica/nil` to install.
Check the repository README for more information.
**Snippet to enable the language server:**
```lua
require'lspconfig'.nil_ls.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "nil" }
```
- `filetypes` :
```lua
{ "nix" }
```
- `root_dir` :
```lua
root_pattern("flake.nix", ".git")
```
- `single_file_support` :
```lua
true
```
## nimls
https://github.com/PMunch/nimlsp
@ -3683,6 +3942,40 @@ require'lspconfig'.nimls.setup{}
```
## nxls
https://github.com/nrwl/nx-console/tree/master/apps/nxls
nxls, a language server for Nx Workspaces
`nxls` can be installed via `npm`:
```sh
npm i -g nxls
```
**Snippet to enable the language server:**
```lua
require'lspconfig'.nxls.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "nxls", "--stdio" }
```
- `filetypes` :
```lua
{ "json", "jsonc" }
```
- `root_dir` :
```lua
util.root_pattern
```
## ocamlls
https://github.com/ocaml-lsp/ocaml-language-server
@ -4524,8 +4817,25 @@ https://github.com/python-lsp/python-lsp-server
A Python 3.6+ implementation of the Language Server Protocol.
The language server can be installed via `pipx install 'python-lsp-server[all]'`.
Further instructions can be found in the [project's README](https://github.com/python-lsp/python-lsp-server).
See the [project's README](https://github.com/python-lsp/python-lsp-server) for installation instructions.
Configuration options are documented [here](https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md).
In order to configure an option, it must be translated to a nested Lua table and included in the `settings` aregument to the `setup{}` function.
For example, in order to set the `pylsp.plugins.pycodestyle.ignore` option:
```lua
require'lspconfig'.pylsp.setup{
settings = {
pylsp = {
plugins = {
pycodestyle = {
ignore = {'W391'},
maxLineLength = 100
}
}
}
}
}
```
Note: This is a community fork of `pyls`.
@ -4637,6 +4947,35 @@ require'lspconfig'.pyright.setup{}
```
## qml_lsp
https://invent.kde.org/sdk/qml-lsp
LSP implementation for QML (autocompletion, live linting, etc. in editors)
**Snippet to enable the language server:**
```lua
require'lspconfig'.qml_lsp.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "qml-lsp" }
```
- `filetypes` :
```lua
{ "qml" }
```
- `root_dir` :
```lua
see source file
```
## quick_lint_js
https://quick-lint-js.com/
@ -4777,6 +5116,73 @@ require'lspconfig'.reason_ls.setup{}
```
## relay_lsp
https://github.com/facebook/relay
`Relay` is a JavaScript framework for building data-driven React applications
Setup:
- Make sure you have a Relay config file somewhere in your project.
- We support standard config file formats (`.yml`, `.js`, `.json`), and the the `relay` field in your `package.json`
- Make sure you have the `relay-compiler` installed in your project. The bare minimum is v13.
- Make sure you are able to run the `relay-compiler` command from the command line. If `yarn relay-compiler` works, it's very likely that the LSP will work.
- Remove / disable any conflicting GraphQL LSPs you have installed.
Relay LSP is a part of the Relay Compiler binary and available when adding `relay-compiler` to your project's devDependencies.
```lua
require'lspconfig'.relay_lsp.setup {
-- (default: false) Whether or not we should automatically start
-- the Relay Compiler in watch mode when you open a project
auto_start_compiler = false,
-- (default: null) Path to a relay config relative to the
-- `root_dir`. Without this, the compiler will search for your
-- config. This is helpful if your relay project is in a nested
-- directory.
path_to_config = nil,
}
```
**Snippet to enable the language server:**
```lua
require'lspconfig'.relay_lsp.setup{}
```
**Default values:**
- `auto_start_compiler` :
```lua
false
```
- `cmd` :
```lua
{ "relay-compiler", "lsp" }
```
- `filetypes` :
```lua
{ "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" }
```
- `handlers` :
```lua
{
["window/showStatus"] = <function 1>
}
```
- `on_new_config` :
```lua
see source file
```
- `root_dir` :
```lua
root_pattern("relay.config.*", "package.json")
```
## remark_ls
https://github.com/remarkjs/remark-language-server
@ -5387,7 +5793,74 @@ require'lspconfig'.solc.setup{}
```
- `root_dir` :
```lua
root_pattern(".git")
root_pattern('hardhat.config.*', '.git')
```
## solidity
https://github.com/qiuxiang/solidity-ls
npm i solidity-ls -g
Make sure that solc is installed and it's the same version of the file. solc-select is recommended.
Solidity language server is a LSP with autocomplete, go to definition and diagnostics.
If you use brownie, use this root_dir:
root_dir = util.root_pattern('brownie-config.yaml', '.git')
on includePath, you can add an extra path to search for external libs, on remapping you can remap lib <> path, like:
```lua
{ solidity = { includePath = '/Users/your_user/.brownie/packages/', remapping = { ["@OpenZeppelin/"] = 'OpenZeppelin/openzeppelin-contracts@4.6.0/' } } }
```
**For brownie users**
Change the root_dir to:
```lua
root_pattern("brownie-config.yaml", ".git")
```
The best way of using it is to have a package.json in your project folder with the packages that you will use.
After installing with package.json, just create a `remappings.txt` with:
```
@OpenZeppelin/=node_modules/OpenZeppelin/openzeppelin-contracts@4.6.0/
```
You can omit the node_modules as well.
**Snippet to enable the language server:**
```lua
require'lspconfig'.solidity.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "solidity-ls", "--stdio" }
```
- `filetypes` :
```lua
{ "solidity" }
```
- `root_dir` :
```lua
root_pattern("package.json", ".git")
```
- `settings` :
```lua
{
solidity = {
includePath = "",
remapping = {}
}
}
```
@ -5951,6 +6424,44 @@ require'lspconfig'.svls.setup{}
```
## syntax_tree
https://ruby-syntax-tree.github.io/syntax_tree/
A fast Ruby parser and formatter.
Syntax Tree is a suite of tools built on top of the internal CRuby parser. It
provides the ability to generate a syntax tree from source, as well as the
tools necessary to inspect and manipulate that syntax tree. It can be used to
build formatters, linters, language servers, and more.
```sh
gem install syntax_tree
```
**Snippet to enable the language server:**
```lua
require'lspconfig'.syntax_tree.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "stree", "lsp" }
```
- `filetypes` :
```lua
{ "ruby" }
```
- `root_dir` :
```lua
root_pattern(".streerc", "Gemfile", ".git")
```
## tailwindcss
https://github.com/tailwindlabs/tailwindcss-intellisense
@ -5975,7 +6486,7 @@ require'lspconfig'.tailwindcss.setup{}
```
- `filetypes` :
```lua
{ "aspnetcorerazor", "astro", "astro-markdown", "blade", "django-html", "htmldjango", "edge", "eelixir", "ejs", "erb", "eruby", "gohtml", "haml", "handlebars", "hbs", "html", "html-eex", "heex", "jade", "leaf", "liquid", "markdown", "mdx", "mustache", "njk", "nunjucks", "php", "razor", "slim", "twig", "css", "less", "postcss", "sass", "scss", "stylus", "sugarss", "javascript", "javascriptreact", "reason", "rescript", "typescript", "typescriptreact", "vue", "svelte" }
{ "aspnetcorerazor", "astro", "astro-markdown", "blade", "django-html", "htmldjango", "edge", "eelixir", "elixir", "ejs", "erb", "eruby", "gohtml", "haml", "handlebars", "hbs", "html", "html-eex", "heex", "jade", "leaf", "liquid", "markdown", "mdx", "mustache", "njk", "nunjucks", "php", "razor", "slim", "twig", "css", "less", "postcss", "sass", "scss", "stylus", "sugarss", "javascript", "javascriptreact", "reason", "rescript", "typescript", "typescriptreact", "vue", "svelte" }
```
- `init_options` :
```lua
@ -6016,7 +6527,7 @@ require'lspconfig'.tailwindcss.setup{}
## taplo
https://taplo.tamasfe.dev/lsp/
https://taplo.tamasfe.dev/cli/usage/language-server.html
Language server for Taplo, a TOML toolkit.
@ -6052,6 +6563,37 @@ require'lspconfig'.taplo.setup{}
```
## tblgen_lsp_server
https://mlir.llvm.org/docs/Tools/MLIRLSP/#tablegen-lsp-language-server--tblgen-lsp-server
The Language Server for the LLVM TableGen language
`tblgen-lsp-server` can be installed at the llvm-project repository (https://github.com/llvm/llvm-project)
**Snippet to enable the language server:**
```lua
require'lspconfig'.tblgen_lsp_server.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "tblgen-lsp-server" }
```
- `filetypes` :
```lua
{ "tablegen" }
```
- `root_dir` :
```lua
see source file
```
## teal_ls
https://github.com/teal-language/teal-language-server
@ -6377,7 +6919,7 @@ https://github.com/theia-ide/typescript-language-server
npm install -g typescript typescript-language-server
```
To configure type language server, add a
To configure typescript language server, add a
[`tsconfig.json`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) or
[`jsconfig.json`](https://code.visualstudio.com/docs/languages/jsconfig) to the root of your
project.
@ -6533,7 +7075,7 @@ require'lspconfig'.vdmj.setup{}
java = "$JAVA_HOME/bin/java",
java_opts = { "-Xmx3000m", "-Xss1m" },
logfile = "path.join(vim.fn.stdpath 'cache', 'vdm-lsp.log')",
mavenrepo = "$HOME/.m2/repository/com/fujitsu",
mavenrepo = "$HOME/.m2/repository/dk/au/ece/vdmj",
version = "The latest version installed in `mavenrepo`"
}
```
@ -6577,6 +7119,42 @@ require'lspconfig'.verible.setup{}
```
## veridian
https://github.com/vivekmalneedi/veridian
A SystemVerilog LanguageServer.
Download the latest release for your OS from the releases page
# install with slang feature, if C++17 compiler is available
cargo install --git https://github.com/vivekmalneedi/veridian.git --all-features
# install if C++17 compiler is not available
cargo install --git https://github.com/vivekmalneedi/veridian.git
**Snippet to enable the language server:**
```lua
require'lspconfig'.veridian.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "veridian" }
```
- `filetypes` :
```lua
{ "systemverilog", "verilog" }
```
- `root_dir` :
```lua
see source file
```
## vimls
https://github.com/iamcco/vim-language-server

View File

@ -18,6 +18,7 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [beancount](#beancount)
- [bicep](#bicep)
- [bsl_ls](#bsl_ls)
- [bufls](#bufls)
- [ccls](#ccls)
- [clangd](#clangd)
- [clarity_lsp](#clarity_lsp)
@ -29,6 +30,7 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [cssls](#cssls)
- [cssmodules_ls](#cssmodules_ls)
- [cucumber_language_server](#cucumber_language_server)
- [dagger](#dagger)
- [dartls](#dartls)
- [denols](#denols)
- [dhall_lsp_server](#dhall_lsp_server)
@ -53,6 +55,7 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [ghcide](#ghcide)
- [ghdl_ls](#ghdl_ls)
- [glint](#glint)
- [glslls](#glslls)
- [golangci_lint_ls](#golangci_lint_ls)
- [gopls](#gopls)
- [gradle_ls](#gradle_ls)
@ -80,13 +83,18 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [lelwel_ls](#lelwel_ls)
- [lemminx](#lemminx)
- [ltex](#ltex)
- [luau_lsp](#luau_lsp)
- [m68k](#m68k)
- [marksman](#marksman)
- [metals](#metals)
- [mint](#mint)
- [mlir_lsp_server](#mlir_lsp_server)
- [mlir_pdll_lsp_server](#mlir_pdll_lsp_server)
- [mm0_ls](#mm0_ls)
- [nickel_ls](#nickel_ls)
- [nil_ls](#nil_ls)
- [nimls](#nimls)
- [nxls](#nxls)
- [ocamlls](#ocamlls)
- [ocamllsp](#ocamllsp)
- [ols](#ols)
@ -109,10 +117,12 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [pylsp](#pylsp)
- [pyre](#pyre)
- [pyright](#pyright)
- [qml_lsp](#qml_lsp)
- [quick_lint_js](#quick_lint_js)
- [r_language_server](#r_language_server)
- [racket_langserver](#racket_langserver)
- [reason_ls](#reason_ls)
- [relay_lsp](#relay_lsp)
- [remark_ls](#remark_ls)
- [rescriptls](#rescriptls)
- [rls](#rls)
@ -128,6 +138,7 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [solang](#solang)
- [solargraph](#solargraph)
- [solc](#solc)
- [solidity](#solidity)
- [solidity_ls](#solidity_ls)
- [sorbet](#sorbet)
- [sourcekit](#sourcekit)
@ -141,8 +152,10 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [svelte](#svelte)
- [svlangserver](#svlangserver)
- [svls](#svls)
- [syntax_tree](#syntax_tree)
- [tailwindcss](#tailwindcss)
- [taplo](#taplo)
- [tblgen_lsp_server](#tblgen_lsp_server)
- [teal_ls](#teal_ls)
- [terraform_lsp](#terraform_lsp)
- [terraformls](#terraformls)
@ -155,6 +168,7 @@ autogenerated from the Lua files. You can view this file in Nvim by running
- [vala_ls](#vala_ls)
- [vdmj](#vdmj)
- [verible](#verible)
- [veridian](#veridian)
- [vimls](#vimls)
- [visualforce_ls](#visualforce_ls)
- [vls](#vls)
@ -246,7 +260,7 @@ require'lspconfig'.angularls.setup{}
```
- `root_dir` :
```lua
root_pattern("angular.json", ".git")
root_pattern("angular.json")
```
@ -722,6 +736,40 @@ require'lspconfig'.bsl_ls.setup{}
```
## bufls
https://github.com/bufbuild/buf-language-server
`buf-language-server` can be installed via `go install`:
```sh
go install github.com/bufbuild/buf-language-server/cmd/bufls@latest
```
bufls is a Protobuf language server compatible with Buf modules and workspaces
**Snippet to enable the language server:**
```lua
require'lspconfig'.bufls.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "bufls", "serve" }
```
- `filetypes` :
```lua
{ "proto" }
```
- `root_dir` :
```lua
root_pattern("buf.work.yaml", ".git")
```
## ccls
https://github.com/MaskRay/ccls/wiki
@ -813,7 +861,7 @@ require'lspconfig'.clangd.setup{}
```
- `filetypes` :
```lua
{ "c", "cpp", "objc", "objcpp", "cuda" }
{ "c", "cpp", "objc", "objcpp", "cuda", "proto" }
```
- `root_dir` :
```lua
@ -865,7 +913,7 @@ require'lspconfig'.clarity_lsp.setup{}
## clojure_lsp
https://github.com/snoe/clojure-lsp
https://github.com/clojure-lsp/clojure-lsp
Clojure Language Server
@ -1182,6 +1230,39 @@ require'lspconfig'.cucumber_language_server.setup{}
```
## dagger
https://github.com/dagger/cuelsp
Dagger's lsp server for cuelang.
**Snippet to enable the language server:**
```lua
require'lspconfig'.dagger.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "cuelsp" }
```
- `filetypes` :
```lua
{ "cue" }
```
- `root_dir` :
```lua
root_pattern("cue.mod", ".git")
```
- `single_file_support` :
```lua
true
```
## dartls
https://github.com/dart-lang/sdk/tree/master/pkg/analysis_server/tool/lsp_spec
@ -1236,7 +1317,7 @@ https://github.com/denoland/deno
Deno's built-in language server
To approrpiately highlight codefences returned from denols, you will need to augment vim.g.markdown_fenced languages
To appropriately highlight codefences returned from denols, you will need to augment vim.g.markdown_fenced languages
in your init.lua. Example:
```lua
@ -1283,10 +1364,6 @@ require'lspconfig'.denols.setup{}
```lua
root_pattern("deno.json", "deno.jsonc", ".git")
```
- `single_file_support` :
```lua
true
```
## dhall_lsp_server
@ -2203,6 +2280,53 @@ require'lspconfig'.glint.setup{}
```
## glslls
https://github.com/svenstaro/glsl-language-server
Language server implementation for GLSL
`glslls` can be compiled and installed manually, or, if your distribution has access to the AUR,
via the `glsl-language-server` AUR package
**Snippet to enable the language server:**
```lua
require'lspconfig'.glslls.setup{}
```
**Default values:**
- `capabilities` :
```lua
{
offsetEncoding = { "utf-8", "utf-16" },
textDocument = {
completion = {
editsNearCursor = true
}
}
}
```
- `cmd` :
```lua
{ "glslls", "--stdin" }
```
- `filetypes` :
```lua
{ "glsl" }
```
- `root_dir` :
```lua
see source file
```
- `single_file_support` :
```lua
true
```
## golangci_lint_ls
Combination of both lint server and client
@ -2269,7 +2393,7 @@ require'lspconfig'.gopls.setup{}
```
- `filetypes` :
```lua
{ "go", "gomod", "gotmpl" }
{ "go", "gomod", "gowork", "gotmpl" }
```
- `root_dir` :
```lua
@ -3321,9 +3445,9 @@ require'lspconfig'.lelwel_ls.setup{}
https://github.com/eclipse/lemminx
The easiest way to install the server is to get a binary at https://download.jboss.org/jbosstools/vscode/stable/lemminx-binary/ and place it in your PATH.
The easiest way to install the server is to get a binary from https://github.com/redhat-developer/vscode-xml/releases and place it on your PATH.
NOTE to macOS users: Binaries from unidentified developers are blocked by default. If you trust the downloaded binary from jboss.org, run it once, cancel the prompt, then remove the binary from Gatekeeper quarantine with `xattr -d com.apple.quarantine lemminx`. It should now run without being blocked.
NOTE to macOS users: Binaries from unidentified developers are blocked by default. If you trust the downloaded binary, run it once, cancel the prompt, then remove the binary from Gatekeeper quarantine with `xattr -d com.apple.quarantine lemminx`. It should now run without being blocked.
@ -3398,6 +3522,31 @@ require'lspconfig'.ltex.setup{}
```
## luau_lsp
**Snippet to enable the language server:**
```lua
require'lspconfig'.luau_lsp.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "luau-lsp", "lsp" }
```
- `filetypes` :
```lua
{ "luau" }
```
- `root_dir` :
```lua
root_pattern(".git")
```
## m68k
https://github.com/grahambates/m68k-lsp
@ -3499,6 +3648,14 @@ require'lspconfig'.metals.setup{}
**Default values:**
- `capabilities` :
```lua
{
workspace = {
configuration = false
}
}
```
- `cmd` :
```lua
{ "metals" }
@ -3561,6 +3718,72 @@ require'lspconfig'.mint.setup{}
```
## mlir_lsp_server
https://mlir.llvm.org/docs/Tools/MLIRLSP/#mlir-lsp-language-server--mlir-lsp-server=
The Language Server for the LLVM MLIR language
`mlir-lsp-server` can be installed at the llvm-project repository (https://github.com/llvm/llvm-project)
**Snippet to enable the language server:**
```lua
require'lspconfig'.mlir_lsp_server.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "mlir-lsp-server" }
```
- `filetypes` :
```lua
{ "mlir" }
```
- `root_dir` :
```lua
see source file
```
- `single_file_support` :
```lua
true
```
## mlir_pdll_lsp_server
https://mlir.llvm.org/docs/Tools/MLIRLSP/#pdll-lsp-language-server--mlir-pdll-lsp-server
The Language Server for the LLVM PDLL language
`mlir-pdll-lsp-server` can be installed at the llvm-project repository (https://github.com/llvm/llvm-project)
**Snippet to enable the language server:**
```lua
require'lspconfig'.mlir_pdll_lsp_server.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "mlir-pdll-lsp-server" }
```
- `filetypes` :
```lua
{ "pdll" }
```
- `root_dir` :
```lua
see source file
```
## mm0_ls
https://github.com/digama0/mm0
@ -3620,7 +3843,7 @@ cd nickel/lsp/nls
cargo install --path .
```
In order to have lspconfig detect Nickel filetypes (a prequisite for autostarting a server),
In order to have lspconfig detect Nickel filetypes (a prerequisite for autostarting a server),
install the [Nickel vim plugin](https://github.com/nickel-lang/vim-nickel).
@ -3646,6 +3869,42 @@ require'lspconfig'.nickel_ls.setup{}
```
## nil_ls
https://github.com/oxalica/nil
A new language server for Nix Expression Language.
If you are using Nix with Flakes support, run `nix profile install github:oxalica/nil` to install.
Check the repository README for more information.
**Snippet to enable the language server:**
```lua
require'lspconfig'.nil_ls.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "nil" }
```
- `filetypes` :
```lua
{ "nix" }
```
- `root_dir` :
```lua
root_pattern("flake.nix", ".git")
```
- `single_file_support` :
```lua
true
```
## nimls
https://github.com/PMunch/nimlsp
@ -3683,6 +3942,40 @@ require'lspconfig'.nimls.setup{}
```
## nxls
https://github.com/nrwl/nx-console/tree/master/apps/nxls
nxls, a language server for Nx Workspaces
`nxls` can be installed via `npm`:
```sh
npm i -g nxls
```
**Snippet to enable the language server:**
```lua
require'lspconfig'.nxls.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "nxls", "--stdio" }
```
- `filetypes` :
```lua
{ "json", "jsonc" }
```
- `root_dir` :
```lua
util.root_pattern
```
## ocamlls
https://github.com/ocaml-lsp/ocaml-language-server
@ -4524,8 +4817,25 @@ https://github.com/python-lsp/python-lsp-server
A Python 3.6+ implementation of the Language Server Protocol.
The language server can be installed via `pipx install 'python-lsp-server[all]'`.
Further instructions can be found in the [project's README](https://github.com/python-lsp/python-lsp-server).
See the [project's README](https://github.com/python-lsp/python-lsp-server) for installation instructions.
Configuration options are documented [here](https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md).
In order to configure an option, it must be translated to a nested Lua table and included in the `settings` aregument to the `setup{}` function.
For example, in order to set the `pylsp.plugins.pycodestyle.ignore` option:
```lua
require'lspconfig'.pylsp.setup{
settings = {
pylsp = {
plugins = {
pycodestyle = {
ignore = {'W391'},
maxLineLength = 100
}
}
}
}
}
```
Note: This is a community fork of `pyls`.
@ -4637,6 +4947,35 @@ require'lspconfig'.pyright.setup{}
```
## qml_lsp
https://invent.kde.org/sdk/qml-lsp
LSP implementation for QML (autocompletion, live linting, etc. in editors)
**Snippet to enable the language server:**
```lua
require'lspconfig'.qml_lsp.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "qml-lsp" }
```
- `filetypes` :
```lua
{ "qml" }
```
- `root_dir` :
```lua
see source file
```
## quick_lint_js
https://quick-lint-js.com/
@ -4777,6 +5116,73 @@ require'lspconfig'.reason_ls.setup{}
```
## relay_lsp
https://github.com/facebook/relay
`Relay` is a JavaScript framework for building data-driven React applications
Setup:
- Make sure you have a Relay config file somewhere in your project.
- We support standard config file formats (`.yml`, `.js`, `.json`), and the the `relay` field in your `package.json`
- Make sure you have the `relay-compiler` installed in your project. The bare minimum is v13.
- Make sure you are able to run the `relay-compiler` command from the command line. If `yarn relay-compiler` works, it's very likely that the LSP will work.
- Remove / disable any conflicting GraphQL LSPs you have installed.
Relay LSP is a part of the Relay Compiler binary and available when adding `relay-compiler` to your project's devDependencies.
```lua
require'lspconfig'.relay_lsp.setup {
-- (default: false) Whether or not we should automatically start
-- the Relay Compiler in watch mode when you open a project
auto_start_compiler = false,
-- (default: null) Path to a relay config relative to the
-- `root_dir`. Without this, the compiler will search for your
-- config. This is helpful if your relay project is in a nested
-- directory.
path_to_config = nil,
}
```
**Snippet to enable the language server:**
```lua
require'lspconfig'.relay_lsp.setup{}
```
**Default values:**
- `auto_start_compiler` :
```lua
false
```
- `cmd` :
```lua
{ "relay-compiler", "lsp" }
```
- `filetypes` :
```lua
{ "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" }
```
- `handlers` :
```lua
{
["window/showStatus"] = <function 1>
}
```
- `on_new_config` :
```lua
see source file
```
- `root_dir` :
```lua
root_pattern("relay.config.*", "package.json")
```
## remark_ls
https://github.com/remarkjs/remark-language-server
@ -5387,7 +5793,74 @@ require'lspconfig'.solc.setup{}
```
- `root_dir` :
```lua
root_pattern(".git")
root_pattern('hardhat.config.*', '.git')
```
## solidity
https://github.com/qiuxiang/solidity-ls
npm i solidity-ls -g
Make sure that solc is installed and it's the same version of the file. solc-select is recommended.
Solidity language server is a LSP with autocomplete, go to definition and diagnostics.
If you use brownie, use this root_dir:
root_dir = util.root_pattern('brownie-config.yaml', '.git')
on includePath, you can add an extra path to search for external libs, on remapping you can remap lib <> path, like:
```lua
{ solidity = { includePath = '/Users/your_user/.brownie/packages/', remapping = { ["@OpenZeppelin/"] = 'OpenZeppelin/openzeppelin-contracts@4.6.0/' } } }
```
**For brownie users**
Change the root_dir to:
```lua
root_pattern("brownie-config.yaml", ".git")
```
The best way of using it is to have a package.json in your project folder with the packages that you will use.
After installing with package.json, just create a `remappings.txt` with:
```
@OpenZeppelin/=node_modules/OpenZeppelin/openzeppelin-contracts@4.6.0/
```
You can omit the node_modules as well.
**Snippet to enable the language server:**
```lua
require'lspconfig'.solidity.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "solidity-ls", "--stdio" }
```
- `filetypes` :
```lua
{ "solidity" }
```
- `root_dir` :
```lua
root_pattern("package.json", ".git")
```
- `settings` :
```lua
{
solidity = {
includePath = "",
remapping = {}
}
}
```
@ -5951,6 +6424,44 @@ require'lspconfig'.svls.setup{}
```
## syntax_tree
https://ruby-syntax-tree.github.io/syntax_tree/
A fast Ruby parser and formatter.
Syntax Tree is a suite of tools built on top of the internal CRuby parser. It
provides the ability to generate a syntax tree from source, as well as the
tools necessary to inspect and manipulate that syntax tree. It can be used to
build formatters, linters, language servers, and more.
```sh
gem install syntax_tree
```
**Snippet to enable the language server:**
```lua
require'lspconfig'.syntax_tree.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "stree", "lsp" }
```
- `filetypes` :
```lua
{ "ruby" }
```
- `root_dir` :
```lua
root_pattern(".streerc", "Gemfile", ".git")
```
## tailwindcss
https://github.com/tailwindlabs/tailwindcss-intellisense
@ -5975,7 +6486,7 @@ require'lspconfig'.tailwindcss.setup{}
```
- `filetypes` :
```lua
{ "aspnetcorerazor", "astro", "astro-markdown", "blade", "django-html", "htmldjango", "edge", "eelixir", "ejs", "erb", "eruby", "gohtml", "haml", "handlebars", "hbs", "html", "html-eex", "heex", "jade", "leaf", "liquid", "markdown", "mdx", "mustache", "njk", "nunjucks", "php", "razor", "slim", "twig", "css", "less", "postcss", "sass", "scss", "stylus", "sugarss", "javascript", "javascriptreact", "reason", "rescript", "typescript", "typescriptreact", "vue", "svelte" }
{ "aspnetcorerazor", "astro", "astro-markdown", "blade", "django-html", "htmldjango", "edge", "eelixir", "elixir", "ejs", "erb", "eruby", "gohtml", "haml", "handlebars", "hbs", "html", "html-eex", "heex", "jade", "leaf", "liquid", "markdown", "mdx", "mustache", "njk", "nunjucks", "php", "razor", "slim", "twig", "css", "less", "postcss", "sass", "scss", "stylus", "sugarss", "javascript", "javascriptreact", "reason", "rescript", "typescript", "typescriptreact", "vue", "svelte" }
```
- `init_options` :
```lua
@ -6016,7 +6527,7 @@ require'lspconfig'.tailwindcss.setup{}
## taplo
https://taplo.tamasfe.dev/lsp/
https://taplo.tamasfe.dev/cli/usage/language-server.html
Language server for Taplo, a TOML toolkit.
@ -6052,6 +6563,37 @@ require'lspconfig'.taplo.setup{}
```
## tblgen_lsp_server
https://mlir.llvm.org/docs/Tools/MLIRLSP/#tablegen-lsp-language-server--tblgen-lsp-server
The Language Server for the LLVM TableGen language
`tblgen-lsp-server` can be installed at the llvm-project repository (https://github.com/llvm/llvm-project)
**Snippet to enable the language server:**
```lua
require'lspconfig'.tblgen_lsp_server.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "tblgen-lsp-server" }
```
- `filetypes` :
```lua
{ "tablegen" }
```
- `root_dir` :
```lua
see source file
```
## teal_ls
https://github.com/teal-language/teal-language-server
@ -6377,7 +6919,7 @@ https://github.com/theia-ide/typescript-language-server
npm install -g typescript typescript-language-server
```
To configure type language server, add a
To configure typescript language server, add a
[`tsconfig.json`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) or
[`jsconfig.json`](https://code.visualstudio.com/docs/languages/jsconfig) to the root of your
project.
@ -6533,7 +7075,7 @@ require'lspconfig'.vdmj.setup{}
java = "$JAVA_HOME/bin/java",
java_opts = { "-Xmx3000m", "-Xss1m" },
logfile = "path.join(vim.fn.stdpath 'cache', 'vdm-lsp.log')",
mavenrepo = "$HOME/.m2/repository/com/fujitsu",
mavenrepo = "$HOME/.m2/repository/dk/au/ece/vdmj",
version = "The latest version installed in `mavenrepo`"
}
```
@ -6577,6 +7119,42 @@ require'lspconfig'.verible.setup{}
```
## veridian
https://github.com/vivekmalneedi/veridian
A SystemVerilog LanguageServer.
Download the latest release for your OS from the releases page
# install with slang feature, if C++17 compiler is available
cargo install --git https://github.com/vivekmalneedi/veridian.git --all-features
# install if C++17 compiler is not available
cargo install --git https://github.com/vivekmalneedi/veridian.git
**Snippet to enable the language server:**
```lua
require'lspconfig'.veridian.setup{}
```
**Default values:**
- `cmd` :
```lua
{ "veridian" }
```
- `filetypes` :
```lua
{ "systemverilog", "verilog" }
```
- `root_dir` :
```lua
see source file
```
## vimls
https://github.com/iamcco/vim-language-server

12
bundle/nvim-lspconfig/flake.lock generated vendored
View File

@ -2,11 +2,11 @@
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1642700792,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
"type": "github"
},
"original": {
@ -17,11 +17,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1643202076,
"narHash": "sha256-EcrUSBkBnw3KtDBoDwHvvwR1R6YF0axNFE4Vd2++iok=",
"lastModified": 1659522808,
"narHash": "sha256-HBcM19nGhI3IWwPNVlYb0MZ8VW6iKp4JbAVkeIHVykc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e722007bf05802573b41701c49da6c8814878171",
"rev": "168d1c578909dc143ba52dbed661c36e76b12b36",
"type": "github"
},
"original": {

View File

@ -4,74 +4,9 @@ local M = {
util = require 'lspconfig.util',
}
M._root = {}
function M.available_servers()
return vim.tbl_keys(configs)
end
-- Called from plugin/lspconfig.vim because it requires knowing that the last
-- script in scriptnames to be executed is lspconfig.
function M._root._setup()
M._root.commands = {
LspInfo = {
function()
require 'lspconfig.ui.lspinfo'()
end,
'-nargs=0',
description = '`:LspInfo` Displays attached, active, and configured language servers',
},
LspLog = {
function()
vim.cmd(string.format('tabnew %s', vim.lsp.get_log_path()))
end,
'-nargs=0',
description = '`:LspLog` Opens the Nvim LSP client log.',
},
LspStart = {
function(server_name)
if server_name then
if configs[server_name] then
configs[server_name].launch()
end
else
local buffer_filetype = vim.bo.filetype
for _, config in pairs(configs) do
for _, filetype_match in ipairs(config.filetypes or {}) do
if buffer_filetype == filetype_match then
config.launch()
end
end
end
end
end,
'-nargs=? -complete=custom,v:lua.lsp_complete_configured_servers',
description = '`:LspStart` Manually launches a language server.',
},
LspStop = {
function(cmd_args)
for _, client in ipairs(M.util.get_clients_from_cmd_args(cmd_args)) do
client.stop()
end
end,
'-nargs=? -complete=customlist,v:lua.lsp_get_active_client_ids',
description = '`:LspStop` Manually stops the given language client(s).',
},
LspRestart = {
function(cmd_args)
for _, client in ipairs(M.util.get_clients_from_cmd_args(cmd_args)) do
client.stop()
vim.defer_fn(function()
configs[client.name].launch()
end, 500)
end
end,
'-nargs=? -complete=customlist,v:lua.lsp_get_active_client_ids',
description = '`:LspRestart` Manually restart the given language client(s).',
},
}
M.util.create_module_commands('_root', M._root.commands)
vim.deprecate('lspconfig.available_servers', 'lspconfig.util.available_servers', '0.1.4', 'lspconfig')
return M.util.available_servers()
end
local mt = {}

View File

@ -30,17 +30,19 @@ function configs.__newindex(t, config_name, config_def)
-- Force this part.
default_config.name = config_name
function M.setup(config)
function M.setup(user_config)
local lsp_group = vim.api.nvim_create_augroup('lspconfig', { clear = false })
validate {
cmd = { config.cmd, 't', true },
root_dir = { config.root_dir, 'f', true },
filetypes = { config.filetype, 't', true },
on_new_config = { config.on_new_config, 'f', true },
on_attach = { config.on_attach, 'f', true },
commands = { config.commands, 't', true },
cmd = { user_config.cmd, 't', true },
root_dir = { user_config.root_dir, 'f', true },
filetypes = { user_config.filetype, 't', true },
on_new_config = { user_config.on_new_config, 'f', true },
on_attach = { user_config.on_attach, 'f', true },
commands = { user_config.commands, 't', true },
}
if config.commands then
for k, v in pairs(config.commands) do
if user_config.commands then
for k, v in pairs(user_config.commands) do
validate {
['command.name'] = { k, 's' },
['command.fn'] = { v[1], 'f' },
@ -48,10 +50,10 @@ function configs.__newindex(t, config_name, config_def)
end
end
config = tbl_deep_extend('keep', config, default_config)
local config = tbl_deep_extend('keep', user_config, default_config)
if util.on_setup then
pcall(util.on_setup, config)
pcall(util.on_setup, config, user_config)
end
if config.autostart == true then
@ -64,14 +66,17 @@ function configs.__newindex(t, config_name, config_def)
event = 'BufReadPost'
pattern = '*'
end
api.nvim_command(
string.format(
"autocmd %s %s unsilent lua require'lspconfig'[%q].manager.try_add()",
event,
pattern,
vim.api.nvim_create_autocmd(event, {
pattern = pattern,
callback = function()
M.manager.try_add()
end,
group = lsp_group,
desc = string.format(
'Checks whether server %s should start a new instance or attach to an existing one.',
config.name
)
)
),
})
end
local get_root_dir = config.root_dir
@ -88,15 +93,18 @@ function configs.__newindex(t, config_name, config_def)
end
if root_dir then
-- Lazy-launching: attach when a buffer in this directory is opened.
api.nvim_command(
string.format(
"autocmd BufReadPost %s/* unsilent lua require'lspconfig'[%q].manager.try_add_wrapper()",
vim.fn.fnameescape(root_dir),
config.name
)
)
-- Attach for all existing buffers in this directory.
vim.api.nvim_create_autocmd('BufReadPost', {
pattern = vim.fn.fnameescape(root_dir) .. '/*',
callback = function()
M.manager.try_add_wrapper()
end,
group = lsp_group,
desc = string.format(
'Checks whether server %s should attach to a newly opened buffer inside workspace %q.',
config.name,
root_dir
),
})
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
local bufname = api.nvim_buf_get_name(bufnr)
if util.bufname_valid(bufname) then
@ -183,15 +191,15 @@ function configs.__newindex(t, config_name, config_def)
M._setup_buffer(client.id, bufnr)
else
if vim.api.nvim_buf_is_valid(bufnr) then
api.nvim_command(
string.format(
"autocmd BufEnter <buffer=%d> ++once lua require'lspconfig'[%q]._setup_buffer(%d,%d)",
bufnr,
config_name,
client.id,
bufnr
)
)
vim.api.nvim_create_autocmd('BufEnter', {
callback = function()
M._setup_buffer(client.id, bufnr)
end,
group = lsp_group,
buffer = bufnr,
once = true,
desc = 'Reattaches the server with the updated configurations if changed.',
})
end
end
end)
@ -283,13 +291,10 @@ function configs.__newindex(t, config_name, config_def)
M.commands = vim.tbl_deep_extend('force', M.commands, client.config.commands)
end
if not M.commands_created and not vim.tbl_isempty(M.commands) then
-- Create the module commands
util.create_module_commands(config_name, M.commands)
M.commands_created = true
end
end
M.commands_created = false
M.commands = config_def.commands
M.name = config_name
M.document_config = config_def

View File

@ -30,10 +30,10 @@ return {
default_config = {
cmd = cmd,
filetypes = { 'typescript', 'html', 'typescriptreact', 'typescript.tsx' },
-- Check for angular.json or .git first since that is the root of the project.
-- Check for angular.json since that is the root of the project.
-- Don't check for tsconfig.json or package.json since there are multiple of these
-- in an angular monorepo setup.
root_dir = util.root_pattern('angular.json', '.git'),
root_dir = util.root_pattern 'angular.json',
},
on_new_config = function(new_config, new_root_dir)
local new_probe_dir = get_probe_dir(new_root_dir)
@ -69,7 +69,7 @@ require'lspconfig'.angularls.setup{
```
]],
default_config = {
root_dir = [[root_pattern("angular.json", ".git")]],
root_dir = [[root_pattern("angular.json")]],
},
},
}

View File

@ -0,0 +1,33 @@
local util = require 'lspconfig.util'
local bin_name = 'bufls'
local cmd = { bin_name, 'serve' }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, 'start' }
end
return {
default_config = {
cmd = cmd,
filetypes = { 'proto' },
root_dir = function(fname)
return util.root_pattern('buf.work.yaml', '.git')(fname)
end,
},
docs = {
description = [[
https://github.com/bufbuild/buf-language-server
`buf-language-server` can be installed via `go install`:
```sh
go install github.com/bufbuild/buf-language-server/cmd/bufls@latest
```
bufls is a Protobuf language server compatible with Buf modules and workspaces
]],
default_config = {
root_dir = [[root_pattern("buf.work.yaml", ".git")]],
},
},
}

View File

@ -42,7 +42,7 @@ local default_capabilities = {
return {
default_config = {
cmd = { 'clangd' },
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' },
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda', 'proto' },
root_dir = function(fname)
return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname)
end,

View File

@ -8,7 +8,7 @@ return {
},
docs = {
description = [[
https://github.com/snoe/clojure-lsp
https://github.com/clojure-lsp/clojure-lsp
Clojure Language Server
]],

View File

@ -3,7 +3,7 @@ local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'csharp-ls' },
root_dir = util.root_pattern('*.sln', '*.csproj', '.git'),
root_dir = util.root_pattern('*.sln', '*.csproj', '*.fsproj', '.git'),
filetypes = { 'cs' },
init_options = {
AutomaticWorkspaceInit = true,

View File

@ -0,0 +1,22 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'cuelsp' },
filetypes = { 'cue' },
root_dir = function(fname)
return util.root_pattern('cue.mod', '.git')(fname)
end,
single_file_support = true,
},
docs = {
description = [[
https://github.com/dagger/cuelsp
Dagger's lsp server for cuelang.
]],
default_config = {
root_dir = [[root_pattern("cue.mod", ".git")]],
},
},
}

View File

@ -1,8 +1,9 @@
local util = require 'lspconfig.util'
local cmd = (vim.fn.has 'win32' == 1
and { 'cmd.exe', '/C', 'dart', 'language-server', '--protocol=lsp' }
or { 'dart', 'language-server', '--protocol=lsp' })
local cmd = (
vim.fn.has 'win32' == 1 and { 'cmd.exe', '/C', 'dart', 'language-server', '--protocol=lsp' }
or { 'dart', 'language-server', '--protocol=lsp' }
)
return {
default_config = {

View File

@ -1,25 +1,18 @@
local util = require 'lspconfig.util'
local lsp = vim.lsp
local function buf_cache(bufnr)
local function buf_cache(bufnr, client)
local params = {}
params['referrer'] = { uri = vim.uri_from_bufnr(bufnr) }
params['uris'] = {}
lsp.buf_request(bufnr, 'deno/cache', params, function(_) end)
client.request_sync('deno/cache', params)
end
local function virtual_text_document_handler(uri, result)
if not result then
local function virtual_text_document_handler(uri, res, client)
if not res then
return nil
end
for _, res in pairs(result) do
-- Error might be present because of race, deno server will eventually send a result. #1995
if res.error ~= nil then
require('vim.lsp.log').warn(
'deno/virtual_text_document handler failed (might be a temporary issue), error: ' .. tostring(res.error)
)
else
local lines = vim.split(res.result, '\n')
local bufnr = vim.uri_to_bufnr(uri)
@ -32,18 +25,17 @@ local function virtual_text_document_handler(uri, result)
vim.api.nvim_buf_set_option(bufnr, 'readonly', true)
vim.api.nvim_buf_set_option(bufnr, 'modified', false)
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
end
end
lsp.buf_attach_client(bufnr, client.id)
end
local function virtual_text_document(uri)
local function virtual_text_document(uri, client)
local params = {
textDocument = {
uri = uri,
},
}
local result = lsp.buf_request_sync(0, 'deno/virtualTextDocument', params)
virtual_text_document_handler(uri, result)
local result = client.request_sync('deno/virtualTextDocument', params)
virtual_text_document_handler(uri, result, client)
end
local function denols_handler(err, result, ctx)
@ -51,10 +43,11 @@ local function denols_handler(err, result, ctx)
return nil
end
local client = vim.lsp.get_client_by_id(ctx.client_id)
for _, res in pairs(result) do
local uri = res.uri or res.targetUri
if uri:match '^deno:' then
virtual_text_document(uri)
virtual_text_document(uri, client)
res['uri'] = uri
res['targetUri'] = uri
end
@ -66,8 +59,6 @@ end
return {
default_config = {
cmd = { 'deno', 'lsp' },
-- single file support is required for now to make the lsp work correctly, see #2000
single_file_support = true,
filetypes = {
'javascript',
'javascriptreact',
@ -86,7 +77,7 @@ return {
['textDocument/references'] = denols_handler,
['workspace/executeCommand'] = function(err, result, context)
if context.params.command == 'deno.cache' then
buf_cache(context.bufnr)
buf_cache(context.bufnr, vim.lsp.get_client_by_id(context.client_id))
else
lsp.handlers[context.method](err, result, context)
end
@ -96,7 +87,13 @@ return {
commands = {
DenolsCache = {
function()
buf_cache(0)
local clients = vim.lsp.get_active_clients()
for _, client in ipairs(clients) do
if client.name == 'denols' then
buf_cache(0, client)
break
end
end
end,
description = 'Cache a module and all of its dependencies.',
},
@ -107,7 +104,7 @@ https://github.com/denoland/deno
Deno's built-in language server
To approrpiately highlight codefences returned from denols, you will need to augment vim.g.markdown_fenced languages
To appropriately highlight codefences returned from denols, you will need to augment vim.g.markdown_fenced languages
in your init.lua. Example:
```lua

View File

@ -0,0 +1,28 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'glslls', '--stdin' },
filetypes = { 'glsl' },
root_dir = util.find_git_ancestor,
single_file_support = true,
capabilities = {
textDocument = {
completion = {
editsNearCursor = true,
},
},
offsetEncoding = { 'utf-8', 'utf-16' },
},
},
docs = {
description = [[
https://github.com/svenstaro/glsl-language-server
Language server implementation for GLSL
`glslls` can be compiled and installed manually, or, if your distribution has access to the AUR,
via the `glsl-language-server` AUR package
]],
},
}

View File

@ -3,7 +3,7 @@ local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'gopls' },
filetypes = { 'go', 'gomod', 'gotmpl' },
filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' },
root_dir = function(fname)
return util.root_pattern 'go.work'(fname) or util.root_pattern('go.mod', '.git')(fname)
end,

View File

@ -11,9 +11,9 @@ return {
description = [[
https://github.com/eclipse/lemminx
The easiest way to install the server is to get a binary at https://download.jboss.org/jbosstools/vscode/stable/lemminx-binary/ and place it in your PATH.
The easiest way to install the server is to get a binary from https://github.com/redhat-developer/vscode-xml/releases and place it on your PATH.
NOTE to macOS users: Binaries from unidentified developers are blocked by default. If you trust the downloaded binary from jboss.org, run it once, cancel the prompt, then remove the binary from Gatekeeper quarantine with `xattr -d com.apple.quarantine lemminx`. It should now run without being blocked.
NOTE to macOS users: Binaries from unidentified developers are blocked by default. If you trust the downloaded binary, run it once, cancel the prompt, then remove the binary from Gatekeeper quarantine with `xattr -d com.apple.quarantine lemminx`. It should now run without being blocked.
]],
default_config = {

View File

@ -0,0 +1,27 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'luau-lsp', 'lsp' },
filetypes = { 'luau' },
root_dir = util.find_git_ancestor,
},
docs = {
[[
https://github.com/JohnnyMorganz/luau-lsp
Language server for the [Luau](https://luau-lang.org/) language.
`luau-lsp` can be installed by downloading one of the release assets available at https://github.com/JohnnyMorganz/luau-lsp.
You might also have to set up automatic filetype detection for Luau files, for example like so:
```vim
autocmd BufRead,BufNewFile *.luau setf luau
```
]],
default_config = {
root_dir = [[root_pattern(".git")]],
},
},
}

View File

@ -13,6 +13,11 @@ return {
snippetAutoIndent = false,
},
},
capabilities = {
workspace = {
configuration = false,
},
},
},
docs = {
description = [[

View File

@ -0,0 +1,19 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'mlir-lsp-server' },
filetypes = { 'mlir' },
root_dir = util.find_git_ancestor,
single_file_support = true,
},
docs = {
description = [[
https://mlir.llvm.org/docs/Tools/MLIRLSP/#mlir-lsp-language-server--mlir-lsp-server=
The Language Server for the LLVM MLIR language
`mlir-lsp-server` can be installed at the llvm-project repository (https://github.com/llvm/llvm-project)
]],
},
}

View File

@ -0,0 +1,20 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'mlir-pdll-lsp-server' },
filetypes = { 'pdll' },
root_dir = function(fname)
return util.root_pattern 'pdll_compile_commands.yml'(fname) or util.find_git_ancestor(fname)
end,
},
docs = {
description = [[
https://mlir.llvm.org/docs/Tools/MLIRLSP/#pdll-lsp-language-server--mlir-pdll-lsp-server
The Language Server for the LLVM PDLL language
`mlir-pdll-lsp-server` can be installed at the llvm-project repository (https://github.com/llvm/llvm-project)
]],
},
}

View File

@ -30,7 +30,7 @@ cd nickel/lsp/nls
cargo install --path .
```
In order to have lspconfig detect Nickel filetypes (a prequisite for autostarting a server),
In order to have lspconfig detect Nickel filetypes (a prerequisite for autostarting a server),
install the [Nickel vim plugin](https://github.com/nickel-lang/vim-nickel).
]],
},

View File

@ -0,0 +1,23 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'nil' },
filetypes = { 'nix' },
single_file_support = true,
root_dir = util.root_pattern('flake.nix', '.git'),
},
docs = {
description = [[
https://github.com/oxalica/nil
A new language server for Nix Expression Language.
If you are using Nix with Flakes support, run `nix profile install github:oxalica/nil` to install.
Check the repository README for more information.
]],
default_config = {
root_dir = [[root_pattern("flake.nix", ".git")]],
},
},
}

View File

@ -0,0 +1,31 @@
local util = require 'lspconfig.util'
local bin_name = 'nxls'
local cmd = { bin_name, '--stdio' }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end
return {
default_config = {
cmd = cmd,
filetypes = { 'json', 'jsonc' },
root_dir = util.root_pattern('nx.json', '.git'),
},
docs = {
description = [[
https://github.com/nrwl/nx-console/tree/master/apps/nxls
nxls, a language server for Nx Workspaces
`nxls` can be installed via `npm`:
```sh
npm i -g nxls
```
]],
default_config = {
root_dir = [[util.root_pattern]],
},
},
}

View File

@ -4,7 +4,7 @@ return {
default_config = {
cmd = { 'pasls' },
filetypes = { 'pascal' },
root_dir = util.find_git_ancestor,
root_dir = util.root_pattern('*.lpi', '*.lpk', '.git'),
single_file_support = true,
},
docs = {

View File

@ -22,8 +22,25 @@ https://github.com/python-lsp/python-lsp-server
A Python 3.6+ implementation of the Language Server Protocol.
The language server can be installed via `pipx install 'python-lsp-server[all]'`.
Further instructions can be found in the [project's README](https://github.com/python-lsp/python-lsp-server).
See the [project's README](https://github.com/python-lsp/python-lsp-server) for installation instructions.
Configuration options are documented [here](https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md).
In order to configure an option, it must be translated to a nested Lua table and included in the `settings` aregument to the `setup{}` function.
For example, in order to set the `pylsp.plugins.pycodestyle.ignore` option:
```lua
require'lspconfig'.pylsp.setup{
settings = {
pylsp = {
plugins = {
pycodestyle = {
ignore = {'W391'},
maxLineLength = 100
}
}
}
}
}
```
Note: This is a community fork of `pyls`.
]],

View File

@ -0,0 +1,16 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'qml-lsp' },
filetypes = { 'qml' },
root_dir = util.root_pattern '*.qml',
},
docs = {
description = [[
https://invent.kde.org/sdk/qml-lsp
LSP implementation for QML (autocompletion, live linting, etc. in editors)
]],
},
}

View File

@ -0,0 +1,117 @@
local util = require 'lspconfig.util'
local log = require 'vim.lsp.log'
local bin_name = 'relay-compiler'
local cmd = { bin_name, 'lsp' }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, 'lsp' }
end
return {
default_config = {
-- (default: false) Whether or not we should automatically start the
-- Relay Compiler in watch mode when you open a project
auto_start_compiler = false,
-- (default: nil) Path to a relay config relative to the `root_dir`.
-- Without this, the compiler will search for your config. This is
-- helpful if your relay project is in a nested directory.
path_to_config = nil,
cmd = cmd,
filetypes = {
'javascript',
'javascriptreact',
'javascript.jsx',
'typescript',
'typescriptreact',
'typescript.tsx',
},
root_dir = util.root_pattern('relay.config.*', 'package.json'),
on_new_config = function(config, root_dir)
local project_root = util.find_node_modules_ancestor(root_dir)
local node_bin_path = util.path.join(project_root, 'node_modules', '.bin')
local compiler_cmd = { util.path.join(node_bin_path, bin_name), '--watch' }
local path = node_bin_path .. util.path.path_separator .. vim.env.PATH
if config.cmd_env then
config.cmd_env.PATH = path
else
config.cmd_env = { PATH = path }
end
if config.path_to_config then
config.path_to_config = util.path.sanitize(config.path_to_config)
local path_to_config = util.path.join(root_dir, config.path_to_config)
if util.path.exists(path_to_config) then
vim.list_extend(config.cmd, { config.path_to_config })
vim.list_extend(compiler_cmd, { config.path_to_config })
else
log.error "[Relay LSP] Can't find Relay config file. Fallback to the default location..."
end
end
if config.auto_start_compiler then
vim.fn.jobstart(compiler_cmd, {
on_exit = function()
log.info '[Relay LSP] Relay Compiler exited'
end,
cwd = project_root,
})
end
end,
handlers = {
['window/showStatus'] = function(_, result)
if not result then
return {}
end
local log_message = string.format('[Relay LSP] %q', result.message)
if result.type == 1 then
log.error(log_message)
end
if result.type == 2 then
log.warn(log_message)
end
if result.type == 3 then
log.info(log_message)
end
return {}
end,
},
},
docs = {
description = [[
https://github.com/facebook/relay
`Relay` is a JavaScript framework for building data-driven React applications
Setup:
- Make sure you have a Relay config file somewhere in your project.
- We support standard config file formats (`.yml`, `.js`, `.json`), and the the `relay` field in your `package.json`
- Make sure you have the `relay-compiler` installed in your project. The bare minimum is v13.
- Make sure you are able to run the `relay-compiler` command from the command line. If `yarn relay-compiler` works, it's very likely that the LSP will work.
- Remove / disable any conflicting GraphQL LSPs you have installed.
Relay LSP is a part of the Relay Compiler binary and available when adding `relay-compiler` to your project's devDependencies.
```lua
require'lspconfig'.relay_lsp.setup {
-- (default: false) Whether or not we should automatically start
-- the Relay Compiler in watch mode when you open a project
auto_start_compiler = false,
-- (default: null) Path to a relay config relative to the
-- `root_dir`. Without this, the compiler will search for your
-- config. This is helpful if your relay project is in a nested
-- directory.
path_to_config = nil,
}
```
]],
default_config = {
root_dir = [[root_pattern("relay.config.*", "package.json")]],
auto_start_compiler = false,
path_to_config = nil,
},
},
}

View File

@ -40,14 +40,14 @@ return {
end
local cargo_workspace_dir = nil
if cm == 0 then
cargo_workspace_dir = vim.fn.json_decode(cargo_metadata)['workspace_root']
cargo_workspace_dir = vim.json.decode(cargo_metadata)['workspace_root']
else
vim.notify(
string.format('[lspconfig] cmd (%q) failed:\n%s', table.concat(cmd, ' '), cargo_metadata_err),
vim.log.levels.WARN
)
end
return cargo_workspace_dir
return util.path.sanitize(cargo_workspace_dir)
or cargo_crate_dir
or util.root_pattern 'rust-project.json'(fname)
or util.find_git_ancestor(fname)

View File

@ -4,7 +4,7 @@ return {
default_config = {
cmd = { 'solc', '--lsp' },
filetypes = { 'solidity' },
root_dir = util.root_pattern '.git',
root_dir = util.root_pattern('hardhat.config.*', '.git'),
},
docs = {
description = [[
@ -13,7 +13,7 @@ https://docs.soliditylang.org/en/latest/installing-solidity.html
solc is the native language server for the Solidity language.
]],
default_config = {
root_dir = [[root_pattern(".git")]],
root_dir = [[root_pattern('hardhat.config.*', '.git')]],
},
},
}

View File

@ -0,0 +1,49 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'solidity-ls', '--stdio' },
filetypes = { 'solidity' },
root_dir = util.root_pattern('.git', 'package.json'),
settings = { solidity = { includePath = '', remapping = {} } },
},
docs = {
description = [[
https://github.com/qiuxiang/solidity-ls
npm i solidity-ls -g
Make sure that solc is installed and it's the same version of the file. solc-select is recommended.
Solidity language server is a LSP with autocomplete, go to definition and diagnostics.
If you use brownie, use this root_dir:
root_dir = util.root_pattern('brownie-config.yaml', '.git')
on includePath, you can add an extra path to search for external libs, on remapping you can remap lib <> path, like:
```lua
{ solidity = { includePath = '/Users/your_user/.brownie/packages/', remapping = { ["@OpenZeppelin/"] = 'OpenZeppelin/openzeppelin-contracts@4.6.0/' } } }
```
**For brownie users**
Change the root_dir to:
```lua
root_pattern("brownie-config.yaml", ".git")
```
The best way of using it is to have a package.json in your project folder with the packages that you will use.
After installing with package.json, just create a `remappings.txt` with:
```
@OpenZeppelin/=node_modules/OpenZeppelin/openzeppelin-contracts@4.6.0/
```
You can omit the node_modules as well.
]],
default_config = {
root_dir = [[root_pattern("package.json", ".git")]],
},
},
}

View File

@ -1,4 +1,4 @@
local util = require 'lspconfig/util'
local util = require 'lspconfig.util'
local root_files = {
'pyproject.toml',

View File

@ -7,12 +7,24 @@ local root_files = {
'stylua.toml',
'selene.toml',
}
local bin_name = 'lua-language-server'
local cmd = { bin_name }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name }
end
return {
default_config = {
cmd = { 'lua-language-server' },
cmd = cmd,
filetypes = { 'lua' },
root_dir = function(fname)
return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname)
local root = util.root_pattern(unpack(root_files))(fname)
if root and root ~= vim.env.HOME then
return root
end
return util.find_git_ancestor(fname)
end,
single_file_support = true,
log_level = vim.lsp.protocol.MessageType.Warning,

View File

@ -0,0 +1,37 @@
local util = require 'lspconfig.util'
local bin_name = 'stree'
local cmd = { bin_name, 'lsp' }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, 'lsp' }
end
return {
default_config = {
cmd = cmd,
filetypes = { 'ruby' },
root_dir = function(fname)
return util.root_pattern '.streerc'(fname) or util.root_pattern('Gemfile', '.git')(fname)
end,
},
docs = {
description = [[
https://ruby-syntax-tree.github.io/syntax_tree/
A fast Ruby parser and formatter.
Syntax Tree is a suite of tools built on top of the internal CRuby parser. It
provides the ability to generate a syntax tree from source, as well as the
tools necessary to inspect and manipulate that syntax tree. It can be used to
build formatters, linters, language servers, and more.
```sh
gem install syntax_tree
```
]],
default_config = {
root_dir = [[root_pattern(".streerc", "Gemfile", ".git")]],
},
},
}

View File

@ -21,6 +21,7 @@ return {
'htmldjango',
'edge',
'eelixir', -- vim ft
'elixir',
'ejs',
'erb',
'eruby', -- vim ft

View File

@ -11,7 +11,7 @@ return {
},
docs = {
description = [[
https://taplo.tamasfe.dev/lsp/
https://taplo.tamasfe.dev/cli/usage/language-server.html
Language server for Taplo, a TOML toolkit.

View File

@ -0,0 +1,20 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'tblgen-lsp-server' },
filetypes = { 'tablegen' },
root_dir = function(fname)
return util.root_pattern 'tablegen_compile_commands.yml'(fname) or util.find_git_ancestor(fname)
end,
},
docs = {
description = [[
https://mlir.llvm.org/docs/Tools/MLIRLSP/#tablegen-lsp-language-server--tblgen-lsp-server
The Language Server for the LLVM TableGen language
`tblgen-lsp-server` can be installed at the llvm-project repository (https://github.com/llvm/llvm-project)
]],
},
}

View File

@ -33,7 +33,7 @@ https://github.com/theia-ide/typescript-language-server
npm install -g typescript typescript-language-server
```
To configure type language server, add a
To configure typescript language server, add a
[`tsconfig.json`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) or
[`jsconfig.json`](https://code.visualstudio.com/docs/languages/jsconfig) to the root of your
project.

View File

@ -1,6 +1,13 @@
local util = require 'lspconfig.util'
local mavenrepo = util.path.join(vim.env.HOME, '.m2', 'repository', 'com', 'fujitsu')
local function get_default_mavenrepo()
local repo = util.path.join(vim.env.HOME, '.m2', 'repository', 'dk', 'au', 'ece', 'vdmj')
if util.path.exists(repo) then
return repo
else
return util.path.join(vim.env.HOME, '.m2', 'repository', 'com', 'fujitsu')
end
end
local function get_jar_path(config, package, version)
return util.path.join(config.options.mavenrepo, package, version, package .. '-' .. version .. '.jar')
@ -44,8 +51,7 @@ return {
java = vim.env.JAVA_HOME and util.path.join(vim.env.JAVA_HOME, 'bin', 'java') or 'java',
java_opts = { '-Xmx3000m', '-Xss1m' },
annotation_paths = {},
mavenrepo = mavenrepo,
version = get_latest_installed_version(mavenrepo),
mavenrepo = get_default_mavenrepo(),
logfile = util.path.join(vim.fn.stdpath 'cache', 'vdm-lsp.log'),
debugger_port = -1,
high_precision = false,
@ -80,7 +86,7 @@ by neovim.
java = '$JAVA_HOME/bin/java',
java_opts = { '-Xmx3000m', '-Xss1m' },
annotation_paths = {},
mavenrepo = '$HOME/.m2/repository/com/fujitsu',
mavenrepo = '$HOME/.m2/repository/dk/au/ece/vdmj',
version = 'The latest version installed in `mavenrepo`',
logfile = "path.join(vim.fn.stdpath 'cache', 'vdm-lsp.log')",
debugger_port = -1,

View File

@ -0,0 +1,23 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'veridian' },
filetypes = { 'systemverilog', 'verilog' },
root_dir = util.find_git_ancestor,
},
docs = {
description = [[
https://github.com/vivekmalneedi/veridian
A SystemVerilog LanguageServer.
Download the latest release for your OS from the releases page
# install with slang feature, if C++17 compiler is available
cargo install --git https://github.com/vivekmalneedi/veridian.git --all-features
# install if C++17 compiler is not available
cargo install --git https://github.com/vivekmalneedi/veridian.git
]],
},
}

View File

@ -1,3 +1,4 @@
local api = vim.api
local configs = require 'lspconfig.configs'
local windows = require 'lspconfig.ui.windows'
local util = require 'lspconfig.util'
@ -52,7 +53,7 @@ local function make_config_info(config, bufnr)
config_info.cmd_is_executable = 'NA'
end
local buffer_dir = vim.api.nvim_buf_call(bufnr, function()
local buffer_dir = api.nvim_buf_call(bufnr, function()
return vim.fn.expand '%:p:h'
end)
local root_dir = config.get_root_dir(buffer_dir)
@ -150,7 +151,12 @@ return function()
local buf_clients = vim.lsp.buf_get_clients()
local clients = vim.lsp.get_active_clients()
local buffer_filetype = vim.bo.filetype
local original_bufnr = vim.api.nvim_get_current_buf()
local original_bufnr = api.nvim_get_current_buf()
windows.default_options.wrap = true
windows.default_options.breakindent = true
windows.default_options.breakindentopt = 'shift:25'
windows.default_options.showbreak = 'NONE'
local win_info = windows.percentage_range_window(0.8, 0.7)
local bufnr, win_id = win_info.bufnr, win_info.win_id
@ -169,6 +175,9 @@ return function()
end
end
-- insert the tips at the top of window
table.insert(buf_lines, 'Use [q] or [Esc] to quit the window')
local header = {
'',
'Language client log: ' .. (vim.lsp.get_log_path()),
@ -216,22 +225,39 @@ return function()
local matching_config_header = {
'',
'Configured servers list: ' .. table.concat(vim.tbl_keys(configs), ', '),
'Configured servers list: ' .. table.concat(util.available_servers(), ', '),
}
vim.list_extend(buf_lines, matching_config_header)
local fmt_buf_lines = indent_lines(buf_lines, ' ')
fmt_buf_lines = vim.lsp.util._trim(fmt_buf_lines, {})
vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, fmt_buf_lines)
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
vim.api.nvim_buf_set_option(bufnr, 'filetype', 'lspinfo')
api.nvim_buf_set_lines(bufnr, 0, -1, true, fmt_buf_lines)
api.nvim_buf_set_option(bufnr, 'modifiable', false)
api.nvim_buf_set_option(bufnr, 'filetype', 'lspinfo')
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<esc>', '<cmd>bd<CR>', { noremap = true })
vim.api.nvim_command(
string.format('autocmd BufHidden,BufLeave <buffer> ++once lua pcall(vim.api.nvim_win_close, %d, true)', win_id)
)
local augroup = api.nvim_create_augroup('lspinfo', { clear = false })
local function close()
api.nvim_clear_autocmds { group = augroup, buffer = bufnr }
if api.nvim_buf_is_valid(bufnr) then
api.nvim_buf_delete(bufnr, { force = true })
end
if api.nvim_win_is_valid(win_id) then
api.nvim_win_close(win_id, true)
end
end
vim.keymap.set('n', '<ESC>', close, { buffer = bufnr, nowait = true })
vim.keymap.set('n', 'q', close, { buffer = bufnr, nowait = true })
api.nvim_create_autocmd({ 'BufDelete', 'BufLeave', 'BufHidden' }, {
once = true,
buffer = bufnr,
callback = close,
group = augroup,
})
vim.fn.matchadd(
'Error',
@ -246,12 +272,14 @@ return function()
vim.cmd 'let m=matchadd("string", "true")'
vim.cmd 'let m=matchadd("error", "false")'
for _, config in pairs(configs) do
vim.fn.matchadd('Title', '\\%(Client\\|Config\\):.*\\zs' .. config.name .. '\\ze')
vim.fn.matchadd('Visual', 'list:.*\\zs' .. config.name .. '\\ze')
vim.fn.matchadd('LspInfoTitle', '\\%(Client\\|Config\\):.*\\zs' .. config.name .. '\\ze')
vim.fn.matchadd('LspInfoList', 'list:.*\\zs' .. config.name .. '\\ze')
if config.filetypes then
for _, ft in pairs(config.filetypes) do
vim.fn.matchadd('Type', '\\%(filetypes\\|filetype\\):.*\\zs' .. ft .. '\\ze')
vim.fn.matchadd('LspInfoFiletype', '\\%(filetypes\\|filetype\\):.*\\zs' .. ft .. '\\ze')
end
end
end
api.nvim_buf_add_highlight(bufnr, 0, 'LspInfoTip', 0, 0, -1)
end

View File

@ -1,6 +1,8 @@
-- The following is extracted and modified from plenary.vnim by
-- TJ Devries. It is not a stable API, and is expected to change
--
local api = vim.api
local function apply_defaults(original, defaults)
if original == nil then
original = {}
@ -19,18 +21,15 @@ end
local win_float = {}
win_float.default_options = {
winblend = 15,
percentage = 0.9,
}
win_float.default_options = {}
function win_float.default_opts(options)
options = apply_defaults(options, win_float.default_options)
options = apply_defaults(options, { percentage = 0.9 })
local width = math.floor(vim.o.columns * options.percentage)
local height = math.floor(vim.o.lines * options.percentage)
local top = math.floor(((vim.o.lines - height) / 2) - 1)
local top = math.floor(((vim.o.lines - height) / 2))
local left = math.floor((vim.o.columns - width) / 2)
local opts = {
@ -52,6 +51,8 @@ function win_float.default_opts(options)
},
}
opts.border = options.border and options.border
return opts
end
@ -75,7 +76,7 @@ function win_float.percentage_range_window(col_range, row_range, options)
assert(row_range <= 1)
assert(row_range > 0)
height_percentage = row_range
row_start_percentage = (1 - height_percentage) / 2
row_start_percentage = (1 - height_percentage) / 3
elseif type(row_range) == 'table' then
height_percentage = row_range[2] - row_range[1]
row_start_percentage = row_range[1]
@ -85,6 +86,7 @@ function win_float.percentage_range_window(col_range, row_range, options)
win_opts.height = math.ceil(vim.o.lines * height_percentage)
win_opts.row = math.ceil(vim.o.lines * row_start_percentage)
win_opts.border = options.border or 'none'
local width_percentage, col_start_percentage
if type(col_range) == 'number' then
@ -102,11 +104,21 @@ function win_float.percentage_range_window(col_range, row_range, options)
win_opts.col = math.floor(vim.o.columns * col_start_percentage)
win_opts.width = math.floor(vim.o.columns * width_percentage)
local bufnr = options.bufnr or vim.api.nvim_create_buf(false, true)
local win_id = vim.api.nvim_open_win(bufnr, true, win_opts)
vim.api.nvim_win_set_buf(win_id, bufnr)
local bufnr = options.bufnr or api.nvim_create_buf(false, true)
local win_id = api.nvim_open_win(bufnr, true, win_opts)
api.nvim_win_set_option(win_id, 'winhl', 'FloatBorder:LspInfoBorder')
vim.cmd 'setlocal nocursorcolumn ts=2 sw=2'
for k, v in pairs(win_float.default_options) do
if k ~= 'border' then
vim.opt_local[k] = v
end
end
api.nvim_win_set_buf(win_id, bufnr)
api.nvim_win_set_option(win_id, 'cursorcolumn', false)
api.nvim_buf_set_option(bufnr, 'tabstop', 2)
api.nvim_buf_set_option(bufnr, 'shiftwidth', 2)
return {
bufnr = bufnr,

View File

@ -3,7 +3,6 @@ local validate = vim.validate
local api = vim.api
local lsp = vim.lsp
local uv = vim.loop
local fn = vim.fn
local M = {}
@ -21,11 +20,13 @@ M.default_config = {
M.on_setup = nil
function M.bufname_valid(bufname)
if bufname and bufname ~= '' and (bufname:match '^([a-zA-Z]:).*' or bufname:match '^/') then
return true
else
if not bufname then
return false
end
if bufname:match '^/' or bufname:match '^[a-zA-Z]:' or bufname:match '^zipfile://' or bufname:match '^tarfile:' then
return true
end
return false
end
function M.validate_bufnr(bufnr)
@ -59,45 +60,49 @@ function M.add_hook_after(func, new_fn)
end
end
-- Maps lspconfig-style command options to nvim_create_user_command (i.e. |command-attributes|) option names.
local opts_aliases = {
['description'] = 'desc',
}
---@param command_definition table<string | integer, any>
function M._parse_user_command_options(command_definition)
---@type table<string, string | boolean | number>
local opts = {}
for k, v in pairs(command_definition) do
if type(k) == 'string' then
local attribute = k.gsub(k, '^%-+', '')
opts[opts_aliases[attribute] or attribute] = v
elseif type(k) == 'number' and type(v) == 'string' and v:match '^%-' then
-- Splits strings like "-nargs=* -complete=customlist,v:lua.something" into { "-nargs=*", "-complete=customlist,v:lua.something" }
for _, command_attribute in ipairs(vim.split(v, '%s')) do
-- Splits attribute into a key-value pair, like "-nargs=*" to { "-nargs", "*" }
local attribute, value = unpack(vim.split(command_attribute, '=', { plain = true }))
attribute = attribute.gsub(attribute, '^%-+', '')
opts[opts_aliases[attribute] or attribute] = value or true
end
end
end
return opts
end
function M.create_module_commands(module_name, commands)
for command_name, def in pairs(commands) do
local parts = { 'command!' }
-- Insert attributes.
for k, v in pairs(def) do
if type(k) == 'string' and type(v) == 'boolean' and v then
table.insert(parts, '-' .. k)
elseif type(k) == 'number' and type(v) == 'string' and v:match '^%-' then
table.insert(parts, v)
local opts = M._parse_user_command_options(def)
api.nvim_create_user_command(command_name, function(info)
require('lspconfig')[module_name].commands[command_name][1](unpack(info.fargs))
end, opts)
end
end
table.insert(parts, command_name)
-- The command definition.
table.insert(
parts,
string.format("lua require'lspconfig'[%q].commands[%q][1](<f-args>)", module_name, command_name)
)
api.nvim_command(table.concat(parts, ' '))
end
end
function M.has_bins(...)
for i = 1, select('#', ...) do
if 0 == fn.executable((select(i, ...))) then
return false
end
end
return true
end
M.script_path = function()
local str = debug.getinfo(2, 'S').source:sub(2)
return str:match '(.*[/\\])'
end
-- Some path utilities
M.path = (function()
local is_windows = uv.os_uname().version:match 'Windows'
local function escape_wildcards(path)
return path:gsub('([%[%]%?%*])', '\\%1')
end
local function sanitize(path)
if is_windows then
path = path:sub(1, 1):upper() .. path:sub(2)
@ -210,6 +215,7 @@ M.path = (function()
local path_separator = is_windows and ';' or ':'
return {
escape_wildcards = escape_wildcards,
is_dir = is_dir,
is_file = is_file,
is_absolute = is_absolute,
@ -333,7 +339,7 @@ function M.root_pattern(...)
local patterns = vim.tbl_flatten { ... }
local function matcher(path)
for _, pattern in ipairs(patterns) do
for _, p in ipairs(vim.fn.glob(M.path.join(path, pattern), true, true)) do
for _, p in ipairs(vim.fn.glob(M.path.join(M.path.escape_wildcards(path), pattern), true, true)) do
if M.path.exists(p) then
return path
end
@ -341,6 +347,7 @@ function M.root_pattern(...)
end
end
return function(startpath)
startpath = M.strip_archive_subpath(startpath)
return M.search_ancestors(startpath, matcher)
end
end
@ -406,17 +413,6 @@ function M.get_other_matching_providers(filetype)
return other_matching_configs
end
function M.get_clients_from_cmd_args(arg)
local result = {}
for id in (arg or ''):gmatch '(%d+)' do
result[id] = vim.lsp.get_client_by_id(tonumber(id))
end
if vim.tbl_isempty(result) then
return M.get_managed_clients()
end
return vim.tbl_values(result)
end
function M.get_active_client_by_name(bufnr, servername)
for _, client in pairs(vim.lsp.buf_get_clients(bufnr)) do
if client.name == servername then
@ -437,4 +433,24 @@ function M.get_managed_clients()
return clients
end
function M.available_servers()
local servers = {}
local configs = require 'lspconfig.configs'
for server, config in pairs(configs) do
if config.manager ~= nil then
table.insert(servers, server)
end
end
return servers
end
-- For zipfile: or tarfile: virtual paths, returns the path to the archive.
-- Other paths are returned unaltered.
function M.strip_archive_subpath(path)
-- Matches regex from zip.vim / tar.vim
path = vim.fn.substitute(path, 'zipfile://\\(.\\{-}\\)::[^\\\\].*$', '\\1', '')
path = vim.fn.substitute(path, 'tarfile:\\(.\\{-}\\)::.*$', '\\1', '')
return path
end
return M

View File

@ -0,0 +1,129 @@
local api = vim.api
if vim.g.lspconfig ~= nil then
return
end
vim.g.lspconfig = 1
local version_info = vim.version()
if vim.fn.has 'nvim-0.7' ~= 1 then
local warning_str = string.format(
'[lspconfig] requires neovim 0.7 or later. Detected neovim version: 0.%s.%s',
version_info.minor,
version_info.patch
)
vim.notify_once(warning_str)
return
end
local completion_sort = function(items)
table.sort(items)
return items
end
local lsp_complete_configured_servers = function(arg)
return completion_sort(vim.tbl_filter(function(s)
return s:sub(1, #arg) == arg
end, require('lspconfig.util').available_servers()))
end
local lsp_get_active_client_ids = function(arg)
local clients = vim.tbl_map(function(client)
return ('%d (%s)'):format(client.id, client.name)
end, require('lspconfig.util').get_managed_clients())
return completion_sort(vim.tbl_filter(function(s)
return s:sub(1, #arg) == arg
end, clients))
end
local get_clients_from_cmd_args = function(arg)
local result = {}
for id in (arg or ''):gmatch '(%d+)' do
result[id] = vim.lsp.get_client_by_id(tonumber(id))
end
if vim.tbl_isempty(result) then
return require('lspconfig.util').get_managed_clients()
end
return vim.tbl_values(result)
end
for group, hi in pairs {
LspInfoBorder = { link = 'Label', default = true },
LspInfoList = { link = 'Function', default = true },
LspInfoTip = { link = 'Comment', default = true },
LspInfoTitle = { link = 'Title', default = true },
LspInfoFiletype = { link = 'Type', default = true },
} do
api.nvim_set_hl(0, group, hi)
end
-- Called from plugin/lspconfig.vim because it requires knowing that the last
-- script in scriptnames to be executed is lspconfig.
api.nvim_create_user_command('LspInfo', function()
require 'lspconfig.ui.lspinfo'()
end, {
desc = 'Displays attached, active, and configured language servers',
})
api.nvim_create_user_command('LspStart', function(info)
local server_name = string.len(info.args) > 0 and info.args or nil
if server_name then
local config = require('lspconfig.configs')[server_name]
if config then
config.launch()
return
end
end
local other_matching_configs = require('lspconfig.util').get_other_matching_providers(vim.bo.filetype)
for _, config in ipairs(other_matching_configs) do
config.launch()
end
end, {
desc = 'Manually launches a language server',
nargs = '?',
complete = lsp_complete_configured_servers,
})
api.nvim_create_user_command('LspRestart', function(info)
for _, client in ipairs(get_clients_from_cmd_args(info.args)) do
client.stop()
vim.defer_fn(function()
require('lspconfig.configs')[client.name].launch()
end, 500)
end
end, {
desc = 'Manually restart the given language client(s)',
nargs = '?',
complete = lsp_get_active_client_ids,
})
api.nvim_create_user_command('LspStop', function(info)
local current_buf = vim.api.nvim_get_current_buf()
local server_name = string.len(info.args) > 0 and info.args or nil
if not server_name then
local servers_on_buffer = vim.lsp.get_active_clients { buffer = current_buf }
for _, client in ipairs(servers_on_buffer) do
local filetypes = client.config.filetypes
if filetypes and vim.tbl_contains(filetypes, vim.bo[current_buf].filetype) then
client.stop()
end
end
else
for _, client in ipairs(get_clients_from_cmd_args(server_name)) do
client.stop()
end
end
end, {
desc = 'Manually stops the given language client(s)',
nargs = '?',
complete = lsp_get_active_client_ids,
})
api.nvim_create_user_command('LspLog', function()
vim.cmd(string.format('tabnew %s', vim.lsp.get_log_path()))
end, {
desc = 'Opens the Nvim LSP client log.',
})

View File

@ -1,16 +0,0 @@
if exists('g:lspconfig')
finish
endif
let g:lspconfig = 1
lua << EOF
lsp_complete_configured_servers = function()
return table.concat(require'lspconfig'.available_servers(), '\n')
end
lsp_get_active_client_ids = function()
return vim.tbl_map(function(client)
return ("%d (%s)"):format(client.id, client.name)
end, require'lspconfig.util'.get_managed_clients())
end
require'lspconfig'._root._setup()
EOF

View File

@ -159,7 +159,7 @@ local function make_lsp_sections()
os.exit(1)
return
end
local data = fn.json_decode(readfile(package_json_name))
local data = vim.json.decode(readfile(package_json_name))
-- The entire autogenerated section.
return make_section(0, '\n', {
-- The default settings section

View File

@ -18,6 +18,22 @@ end)
describe('lspconfig', function()
describe('util', function()
describe('path', function()
describe('escape_wildcards', function()
it('doesnt escape if not needed', function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
return lspconfig.util.path.escape_wildcards('/usr/local/test/fname.lua') == '/usr/local/test/fname.lua'
]])
end)
it('escapes if needed', function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
return lspconfig.util.path.escape_wildcards('/usr/local/test/[sq brackets] fname?*.lua') == '/usr/local/test/\\[sq brackets\\] fname\\?\\*.lua'
]])
end)
end)
describe('exists', function()
it('is present directory', function()
ok(exec_lua [[
@ -32,7 +48,7 @@ describe('lspconfig', function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
local not_exist_dir = vim.fn.getcwd().."/not/exsts"
local not_exist_dir = vim.fn.getcwd().."/not/exists"
return lspconfig.util.path.exists(not_exist_dir) == false
]])
end)
@ -76,7 +92,7 @@ describe('lspconfig', function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
local not_exist_dir = vim.fn.getcwd().."/not/exsts"
local not_exist_dir = vim.fn.getcwd().."/not/exists"
return not lspconfig.util.path.is_dir(not_exist_dir)
]])
end)
@ -190,7 +206,66 @@ describe('lspconfig', function()
]])
end)
end)
describe('strip_archive_subpath', function()
it('strips zipfile subpaths', function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
return lspconfig.util.strip_archive_subpath("zipfile:///one/two.zip::three/four") == "/one/two.zip"
]])
end)
it('strips tarfile subpaths', function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
return lspconfig.util.strip_archive_subpath("tarfile:/one/two.tgz::three/four") == "/one/two.tgz"
]])
end)
it('returns non-archive paths as-is', function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
return lspconfig.util.strip_archive_subpath("/one/two.zip") == "/one/two.zip"
]])
end)
end)
describe('user commands', function()
it('should translate command definition to nvim_create_user_command options', function()
eq(
{
nargs = '*',
complete = 'custom,v:lua.some_global',
},
exec_lua [[
local util = require("lspconfig.util")
return util._parse_user_command_options({
function () end,
"-nargs=* -complete=custom,v:lua.some_global"
})
]]
)
eq(
{
desc = 'My awesome description.',
nargs = '*',
complete = 'custom,v:lua.another_global',
},
exec_lua [[
local util = require("lspconfig.util")
return util._parse_user_command_options({
function () end,
["-nargs"] = "*",
"-complete=custom,v:lua.another_global",
description = "My awesome description."
})
]]
)
end)
end)
end)
describe('config', function()
it('normalizes user, server, and base default configs', function()
eq(
@ -251,5 +326,37 @@ describe('lspconfig', function()
}
)
end)
it("excludes indexed server configs that haven't been set up", function()
eq(
exec_lua [[
local lspconfig = require("lspconfig")
local actual = nil
local _ = lspconfig.sumneko_lua
local _ = lspconfig.tsserver
lspconfig.rust_analyzer.setup {}
return require("lspconfig.util").available_servers()
]],
{ 'rust_analyzer' }
)
end)
it('provides user_config to the on_setup hook', function()
eq(
exec_lua [[
local lspconfig = require "lspconfig"
local util = require "lspconfig.util"
local user_config
util.on_setup = function (_, _user_config)
user_config = _user_config
end
lspconfig.rust_analyzer.setup { custom_user_config = "custom" }
return user_config
]],
{
custom_user_config = 'custom',
}
)
end)
end)
end)

View File

@ -29,11 +29,9 @@ local function load_plugins()
}
end
_G.load_config = function()
local load_config = function()
vim.lsp.set_log_level 'trace'
if vim.fn.has 'nvim-0.5.1' == 1 then
require('vim.lsp.log').set_format_func(vim.inspect)
end
local nvim_lsp = require 'lspconfig'
local on_attach = function(_, bufnr)
local function buf_set_option(...)
@ -86,9 +84,13 @@ if vim.fn.isdirectory(install_path) == 0 then
vim.fn.system { 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path }
load_plugins()
require('packer').sync()
vim.cmd [[autocmd User PackerComplete ++once lua load_config()]]
local packer_group = vim.api.nvim_create_augroup('Packer', { clear = true })
vim.api.nvim_create_autocmd(
'User',
{ pattern = 'PackerComplete', callback = load_config, group = packer_group, once = true }
)
else
load_plugins()
require('packer').sync()
_G.load_config()
load_config()
end