1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-13 21:50:39 +08:00

fix(compatible): fix nvim-0.5.0 support

This commit is contained in:
Eric Wong 2024-06-13 08:44:55 +08:00
parent 7edc45e572
commit f818591314
183 changed files with 12816 additions and 13176 deletions

View File

@ -1,22 +1,24 @@
vim.api.nvim_create_user_command('Nvim', function(opt)
local cmd = { 'nvim-qt', '--' }
for _, v in pairs(opt.fargs) do
table.insert(cmd, v)
end
if vim.api.nvim_create_user_command then
vim.api.nvim_create_user_command('Nvim', function(opt)
local cmd = { 'nvim-qt', '--' }
for _, v in pairs(opt.fargs) do
table.insert(cmd, v)
end
vim.fn.jobstart(cmd)
end, { nargs = '*', complete = 'file' })
vim.fn.jobstart(cmd)
end, { nargs = '*', complete = 'file' })
vim.api.nvim_create_user_command('Vim', function(opt)
local cmd = { 'gvim', }
for _, v in pairs(opt.fargs) do
table.insert(cmd, v)
end
vim.api.nvim_create_user_command('Vim', function(opt)
local cmd = { 'gvim' }
for _, v in pairs(opt.fargs) do
table.insert(cmd, v)
end
vim.fn.jobstart(cmd, {
env = {
VIM = '',
VIMRUNTIME = ''
}
})
end, { nargs = '*', complete = 'file' })
vim.fn.jobstart(cmd, {
env = {
VIM = '',
VIMRUNTIME = '',
},
})
end, { nargs = '*', complete = 'file' })
end

View File

@ -89,7 +89,9 @@ function! SpaceVim#layers#lsp#plugins() abort
\ 'merged' : 0,
\ }])
endif
elseif s:use_nvim_lsp
" this is the laste commit support nvim-0.5.0
" https://github.com/neovim/nvim-lspconfig/tree/4569e14e59bed1d18a91db76fe3261628f60e3f0
elseif has('nvim-0.5.0')
call add(plugins, [g:_spacevim_root_dir . 'bundle/nvim-lspconfig', {'merged' : 0, 'loadconf' : 1}])
if g:spacevim_autocomplete_method ==# 'deoplete'
call add(plugins, [g:_spacevim_root_dir . 'bundle/deoplete-lsp', {'merged' : 0}])

View File

@ -12,8 +12,16 @@ endif
let s:save_cpo = &cpo
set cpo&vim
""
" @section Key Binding Guide, plugins-mapping-guide
" @parentsection plugins
" The key binding guide plugin is to display the description of the key
" binding.
"
" - Lua version: require nvim-0.8.0
" - Old Vim Script version: for vim and old nvim
if has('nvim-0.9.0')
if has('nvim-0.8.0')
function! SpaceVim#mapping#guide#parse_mappings() abort " {{{
lua require("spacevim.plugin.guide").parse_mappings()

View File

@ -66,6 +66,12 @@ body:
description: "You can download a minimal_init.lua via `curl -fLO https://raw.githubusercontent.com/neovim/nvim-lspconfig/master/test/minimal_init.lua`. Then edit it to include your language server and add necessary configuration and paste it here."
validations:
required: true
- type: textarea
attributes:
label: "Health check"
description: "Run `:checkhealth lspconfig` and paste the results here."
validations:
required: true
- type: input
attributes:
label: "LSP log"

View File

@ -3,3 +3,9 @@ name: Pull Request
about: Submit a pull request
title: ''
---
<!--
If you want to make changes to the README.md, do so in scripts/README_template.md.
The CONFIG.md is auto-generated with all the options from the various LSP configuration;
do not edit it manually
-->

View File

@ -5,7 +5,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install codespell
run: pip install codespell
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
fetch-depth: 0
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install codespell
- name: Use codespell
run: codespell --quiet-level=2 --check-hidden --skip=./doc/server_configurations.md,./doc/server_configurations.txt --ignore-words=.codespellignorewords
run: |
codespell --quiet-level=2 --check-hidden --skip=./doc/server_configurations.md,./doc/server_configurations.txt --ignore-words=.codespellignorewords || exit

View File

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

View File

@ -10,24 +10,41 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v2
- name: Setup luacheck
run: |
sudo apt update
sudo apt install -y lua5.1 luarocks
sudo luarocks install luacheck
- name: Setup selene
run: |
wget "https://github.com/Kampfkarren/selene/releases/download/$VERSION/selene-$VERSION-linux.zip"
echo "$SHA256_CHECKSUM selene-$VERSION-linux.zip" > "selene-$VERSION-linux.zip.checksum"
sha256sum --check "selene-$VERSION-linux.zip.checksum"
unzip "selene-$VERSION-linux.zip"
install -Dp selene "$HOME/.local/bin/selene"
echo "::add-matcher::.github/workflows/problem_matchers/selene.json"
env:
VERSION: "0.15.0"
SHA256_CHECKSUM: "8ff9272170158fbd9c1af38206ecadc894dc456665dc9bd9f0d43a26e5e8f1af"
- name: Add $HOME/.local/bin to $PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Run luacheck
uses: lunarmodules/luacheck@v0
with:
args: lua/* test/*
run: luacheck lua/* test/*
- name: Run selene
uses: NTBBloodbath/selene-action@v1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --display-style=quiet .
run: selene --display-style=quiet .
style-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v2
- name: Lint with stylua
uses: JohnnyMorganz/stylua-action@1.0.0

View File

@ -45,6 +45,7 @@ jobs:
uses: actions/checkout@v2
- name: Setup build dependencies
run: |
rm -f /usr/local/bin/2to3
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" &&
brew install ninja libtool automake pkg-config gettext
- name: Run test with building Nvim

View File

@ -4,7 +4,6 @@
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

@ -3,4 +3,4 @@ line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferSingle"
call_parentheses = "None"
no_call_parentheses = true

View File

@ -0,0 +1 @@
Notice: CONFIG.md was moved to [doc/server_configurations.md](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md). This notice will be removed after the release of neovim 0.6.

View File

@ -1,6 +1,6 @@
## Requirements
- [Neovim](https://neovim.io/) 0.6 or later
- [Neovim](https://neovim.io/) 0.5 or later
- Lint task requires [luacheck](https://github.com/luarocks/luacheck#installation) and [stylua](https://github.com/JohnnyMorganz/StyLua). If using nix, you can use `nix develop` to install these to a local nix shell.
- Documentation is generated by `scripts/docgen.lua`.
- Only works on linux and macOS
@ -9,14 +9,6 @@
The point of lspconfig is to provide the minimal configuration necessary for a server to act in compliance with the language server protocol. In general, if a server requires custom client-side commands or off-spec handlers, then the server configuration should be added *without* those in lspconfig and receive a dedicated plugin such as nvim-jdtls, nvim-metals, etc.
## Pull requests (PRs)
- To avoid duplicate work, create a draft pull request.
- Avoid cosmetic changes to unrelated files in the same commit.
- Use a [feature branch](https://www.atlassian.com/git/tutorials/comparing-workflows) instead of the master branch.
- Use a **rebase workflow** for small PRs.
- After addressing review comments, it's fine to rebase and force-push.
## Adding a server to lspconfig
The general form of adding a new language server is to start with a minimal skeleton. This includes populated the `config` table with a `default_config` and `docs` table.
@ -24,18 +16,7 @@ The general form of adding a new language server is to start with a minimal skel
When choosing a server name, convert all dashes (`-`) to underscores (`_`) If the name of the server is a unique name (`pyright`, `clangd`) or a commonly used abbreviation (`zls`), prefer this as the server name. If the server instead follows the pattern x-language-server, prefer the convention `x_ls` (`jsonnet_ls`).
`default_config` should include, at minimum the following:
* `cmd`: a list which includes the executable name as the first entry, with arguments constituting subsequent list elements (`--stdio` is common).
Note that Windows has a limitation when it comes to directly invoking a server that's installed by `npm` or `gem`, so it requires additional handling.
```lua
local bin_name = 'typescript-language-server'
local cmd = { bin_name, '--stdio' }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end
```
* `cmd`: a list which includes the executable name as the first entry, with arguments constituting subsequent list elements (`--stdio` is common)
* `filetypes`: a list for filetypes a
* `root_dir`: a function (or function handle) which returns the root of the project used to determine if lspconfig should launch a new language server, or attach a previously launched server when you open a new buffer matching the filetype of the server. Note, lspconfig does not offer a dedicated single file mode (this is not codified in the spec). Do not add `vim.fn.cwd` or `util.path.dirname` in `root_dir`. A future version of lspconfig will provide emulation of a single file mode until this is formally codified in the specification. A good fallback is `util.find_git_ancestor`, see other configurations for examples.
@ -44,62 +25,38 @@ Additionally, the following options are often added:
* `init_options`: a table sent during initialization, corresponding to initializationOptions sent in [initializeParams](https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#initializeParams) as part of the first request sent from client to server during startup.
* `settings`: a table sent during [`workspace/didChangeConfiguration`](https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#didChangeConfigurationParams) shortly after server initialization. This is an undocumented convention for most language servers. There is often some duplication with initOptions.
An example for adding a new language server is shown below for `pyright`, a python language server included in lspconfig:
A minimal example for adding a new language server is shown below for `pyright`, a python language server included in lspconfig:
```lua
-- Only `configs` must be required, util is optional if you are using the root resolver functions, which is usually the case.
local configs = require 'lspconfig.configs'
local util = require 'lspconfig.util'
local bin_name = 'pyright-langserver'
local cmd = { bin_name, '--stdio' }
-- Having server name defined here is the convention, this is often times also the first entry in the `cmd` table.
local server_name = 'pyright'
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end
local root_files = {
'pyproject.toml',
'setup.py',
'setup.cfg',
'requirements.txt',
'Pipfile',
'pyrightconfig.json',
}
local function organize_imports()
local params = {
command = 'pyright.organizeimports',
arguments = { vim.uri_from_bufnr(0) },
}
vim.lsp.buf.execute_command(params)
end
return {
configs[server_name] = {
default_config = {
cmd = cmd,
-- This should be executable on the command line, arguments (such as `--stdio`) are additional entries in the list.
cmd = { 'pyright-langserver' },
-- These are the filetypes that the server will either attach or start in response to opening. The user must have a filetype plugin matching the filetype, either via the built-in runtime files or installed via plugin.
filetypes = { 'python' },
root_dir = util.root_pattern(unpack(root_files)),
single_file_support = true,
settings = {
python = {
analysis = {
autoSearchPaths = true,
useLibraryCodeForTypes = true,
diagnosticMode = 'workspace',
},
},
},
},
commands = {
PyrightOrganizeImports = {
organize_imports,
description = 'Organize Imports',
},
-- The root directory that lspconfig uses to determine if it should start a new language server, or attach the current buffer to a previously running language server.
root_dir = util.find_git_ancestor
end,
},
docs = {
-- extremely important: the package.json that contains language server settings, not the package.json that contains javascript dependencies for the project, or the package.json that contains vscode specific settings
package_json = 'https://raw.githubusercontent.com/microsoft/pyright/master/packages/vscode-pyright/package.json',
-- The description should include at minimum the link to the github project, and ideally the steps to install the language server.
description = [[
https://github.com/microsoft/pyright
`pyright`, a static type checker and language server for python
`pyright` can be installed via `npm`
`npm install -g pyright`
]],
},
}
@ -119,13 +76,13 @@ with the commit body containing additional details.
## Lint
PRs are checked with [luacheck](https://github.com/mpeterv/luacheck), [StyLua](https://github.com/JohnnyMorganz/StyLua) and [selene](https://github.com/Kampfkarren/selene). Please run the linter locally before submitting a PR:
PRs are checked with Luacheck and stylua. Please run the linter locally before submitting a PR:
make lint
## Generating docs
Github Actions automatically generates `server_configurations.md`. Only modify `scripts/README_template.md` or the `docs` table in the server config Lua file. Do not modify `server_configurations.md` directly.
Github Actions automatically generates `server_configurations.md`. Only modify `scripts/README_template.md` or the `docs` table in the server config (the lua file). Do not modify `server_configurations.md` directly.
To preview the generated `server_configurations.md` locally, run `scripts/docgen.lua` from
`nvim` (from the project root):

View File

@ -1,8 +1,8 @@
Copyright Neovim contributors. All rights reserved.
nvim-lspconfig is licensed under the terms of the Apache 2.0 license.
nvim-lsp is licensed under the terms of the Apache 2.0 license.
nvim-lspconfig's license follows:
nvim-lsp's license follows:
====
Apache License

View File

@ -1,158 +1,213 @@
# nvim-lspconfig
# lspconfig
[Configs](doc/server_configurations.md) for the [Nvim LSP client](https://neovim.io/doc/user/lsp.html) (`:help lsp`).
A [collection of common configurations](doc/server_configurations.md) for Neovim's built-in [language server client](https://neovim.io/doc/user/lsp.html).
* **Do not file Nvim LSP client issues here.** The Nvim LSP client does not live here. This is only a collection of LSP configs.
* If you found a bug in the Nvim LSP client, [report it at the Nvim core repo](https://github.com/neovim/neovim/issues/new?assignees=&labels=bug%2Clsp&template=lsp_bug_report.yml).
* These configs are **best-effort and unsupported.** See [contributions](#contributions).
This plugin allows for declaratively configuring, launching, and initializing language servers you have installed on your system.
**Disclaimer: Language server configurations are provided on a best-effort basis and are community-maintained. See [contributions](#contributions).**
See also `:help lspconfig`.
`lspconfig` has extensive help documentation, see `:help lspconfig`.
# LSP overview
Neovim supports the Language Server Protocol (LSP), which means it acts as a client to language servers and includes a Lua framework `vim.lsp` for building enhanced LSP tools. LSP facilitates features like:
- go-to-definition
- find-references
- hover
- completion
- rename
- format
- refactor
Neovim provides an interface for all of these features, and the language server client is designed to be highly extensible to allow plugins to integrate language server features which are not yet present in Neovim core such as [**auto**-completion](https://github.com/neovim/nvim-lspconfig/wiki/Autocompletion) (as opposed to manual completion with omnifunc) and [snippet integration](https://github.com/neovim/nvim-lspconfig/wiki/Snippets).
These features are not implemented in this repo, but in Neovim core. See `:help lsp` for more details.
## Install
* Requires [Neovim latest stable release](https://github.com/neovim/neovim/releases/latest) or [Nightly](https://github.com/neovim/neovim/releases/tag/nightly). Update Nvim and nvim-lspconfig before reporting an issue.
* Install nvim-lspconfig like any other Vim plugin, e.g. with [packer.nvim](https://github.com/wbthomason/packer.nvim):
```lua
local use = require('packer').use
require('packer').startup(function()
use 'wbthomason/packer.nvim' -- Package manager
use 'neovim/nvim-lspconfig' -- Configurations for Nvim LSP
end)
```
* Requires [Neovim v0.5.0](https://github.com/neovim/neovim/releases/tag/v0.5.0) or [Nightly](https://github.com/neovim/neovim/releases/tag/nightly). Update Neovim and 'lspconfig' before reporting an issue.
* Install 'lspconfig' like any other Vim plugin, e.g. with [vim-plug](https://github.com/junegunn/vim-plug):
```vim
Plug 'neovim/nvim-lspconfig'
```
## Quickstart
1. Install a language server, e.g. [pyright](doc/server_configurations.md#pyright)
```bash
npm i -g pyright
```
2. Add the language server setup to your init.lua.
```lua
require'lspconfig'.pyright.setup{}
```
3. Launch Nvim, the language server will attach and provide diagnostics.
```
nvim main.py
```
4. Run `:LspInfo` to see the status or to troubleshoot.
5. See [Suggested configuration](#Suggested-configuration) to setup common mappings and omnifunc completion.
See [server_configurations.md](doc/server_configurations.md) (`:help lspconfig-all` from Nvim) for the full list of configs, including installation instructions and additional, optional, customization suggestions for each language server. For servers that are not on your system path (e.g., `jdtls`, `elixirls`), you must manually add `cmd` to the `setup` parameter. Most language servers can be installed in less than a minute.
```bash
npm i -g pyright
```
## Suggested configuration
2. Add the language server setup to your init.vim. The server name must match those found in the table of contents in [server_configurations.md](doc/server_configurations.md). This list is also accessible via `:help lspconfig-server-configurations`.
nvim-lspconfig does not set keybindings or enable completion by default. The following example configuration provides suggested keymaps for the most commonly used language server functions, and manually triggered completion with omnifunc (\<c-x\>\<c-o\>).
```lua
lua << EOF
require'lspconfig'.pyright.setup{}
EOF
```
Note: you must pass the defined `on_attach` as an argument to **every `setup {}` call** and the keybindings in `on_attach` **only take effect on buffers with an active language server**.
3. Create a project, this project must contain a file matching the root directory trigger. See [Automatically launching language servers](#Automatically-launching-language-servers) for additional info.
```bash
mkdir test_python_project
cd test_python_project
git init
touch main.py
```
4. Launch neovim, the language server will now be attached and providing diagnostics (see `:LspInfo`)
```
nvim main.py
```
5. See [Keybindings and completion](#Keybindings-and-completion) for mapping useful functions and enabling omnifunc completion
## Automatically launching language servers
In order to automatically launch a language server, 'lspconfig' searches up the directory tree from your current buffer to find a file matching the `root_dir` pattern defined in each server's configuration. For [pyright](doc/server_configurations.md#pyright), this is any directory containing ".git", "setup.py", "setup.cfg", "pyproject.toml", or "requirements.txt").
Language servers require each project to have a `root` in order to provide completion and search across symbols that may not be defined in your current file, and to avoid having to index your entire filesystem on each startup.
## Enabling additional language servers
Enabling most language servers is as easy as installing the language server, ensuring it is on your PATH, and adding the following to your config:
```vim
lua << EOF
require'lspconfig'.rust_analyzer.setup{}
EOF
```
For a full list of servers, see [server_configurations.md](doc/server_configurations.md) or `:help lspconfig-server-configurations`. This document contains installation instructions and additional, optional, customization suggestions for each language server. For some servers that are not on your system path (e.g., `jdtls`, `elixirls`), you will be required to manually add `cmd` as an entry in the table passed to `setup`. Most language servers can be installed in less than a minute.
## Keybindings and completion
'lspconfig' does not map keybindings or enable completion by default. Manual, triggered completion can be provided by neovim's built-in omnifunc. For autocompletion, a general purpose [autocompletion plugin](https://github.com/neovim/nvim-lspconfig/wiki/Autocompletion) is required. The following example configuration provides suggested keymaps for the most commonly used language server functions, and manually triggered completion with omnifunc (\<c-x\>\<c-o\>).
Note: **you must pass the defined `on_attach` as an argument to every `setup {}` call** and **the keybindings in `on_attach` only take effect after the language server has started (attached to the current buffer)**.
```lua
-- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap=true, silent=true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
lua << EOF
local nvim_lsp = require('lspconfig')
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap=true, silent=true, buffer=bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<space>f', vim.lsp.buf.formatting, bufopts)
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
local lsp_flags = {
-- This is the default in Nvim 0.7+
debounce_text_changes = 150,
}
require('lspconfig')['pyright'].setup{
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { 'pyright', 'rust_analyzer', 'tsserver' }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = on_attach,
flags = lsp_flags,
}
require('lspconfig')['tsserver'].setup{
on_attach = on_attach,
flags = lsp_flags,
}
require('lspconfig')['rust_analyzer'].setup{
on_attach = on_attach,
flags = lsp_flags,
-- Server-specific settings...
settings = {
["rust-analyzer"] = {}
flags = {
debounce_text_changes = 150,
}
}
}
end
EOF
```
Manual, triggered completion is provided by Nvim's builtin omnifunc. For *auto*completion, a general purpose [autocompletion plugin](https://github.com/neovim/nvim-lspconfig/wiki/Autocompletion) is required.
The `on_attach` hook is used to only activate the bindings after the language server attaches to the current buffer.
## Troubleshooting
## Debugging
If you have an issue, the first step is to reproduce with a [minimal configuration](https://github.com/neovim/nvim-lspconfig/blob/master/test/minimal_init.lua).
If you have an issue with 'lspconfig', the first step is to reproduce with a [minimal configuration](https://github.com/neovim/nvim-lspconfig/blob/master/test/minimal_init.lua).
The most common reasons a language server does not start or attach are:
1. The language server is not installed. nvim-lspconfig does not install language servers for you. You should be able to run the `cmd` defined in each server's Lua module from the command line and see that the language server starts. If the `cmd` is an executable name instead of an absolute path to the executable, ensure it is on your path.
2. Missing filetype plugins. Certain languages are not detecting by vim/neovim because they have not yet been added to the filetype detection system. Ensure `:set ft?` shows the filetype and not an empty value.
3. Not triggering root detection. **Some** language servers will only start if it is opened in a directory, or child directory, containing a file which signals the *root* of the project. Most of the time, this is a `.git` folder, but each server defines the root config in the lua file. See [server_configurations.md](doc/server_configurations.md) or the source for the list of root directories.
4. You must pass `on_attach` and `capabilities` for **each** `setup {}` if you want these to take effect.
5. **Do not call `setup {}` twice for the same server**. The second call to `setup {}` will overwrite the first.
1. The language server is not installed. 'lspconfig' does not install language servers for you. You should be able to run the `cmd` defined in each server's lua module from the command line and see that the language server starts. If the `cmd` is an executable name, ensure it is on your path.
2. Not triggering root detection. The language server will only start if it is opened in a directory, or child directory, containing a file which signals the *root* of the project. Most of the time, this is a `.git` folder, but each server defines the root config in the lua file. See [server_configurations.md](doc/server_configurations.md) or the source for the list of root directories.
3. Misconfiguration. You must pass `on_attach` and `capabilities` for **each** `setup {}` if you want these to take effect. You must also **not call `setup {}` twice for the same server**. The second call to `setup {}` will overwrite the first.
:LspInfo provides a handy overview of your active and configured language servers. Note, that it will not report any configuration changes applied in `on_new_config`.
Before reporting a bug, check your logs and the output of `:LspInfo`. Add the following to your init.vim to enable logging:
```lua
lua << EOF
vim.lsp.set_log_level("debug")
EOF
```
Attempt to run the language server, and open the log with:
```
:LspLog
:lua vim.cmd('e'..vim.lsp.get_log_path())
```
Most of the time, the reason for failure is present in the logs.
## Commands
## Built-in commands
* `:LspInfo` shows the status of active and configured language servers.
The following support tab-completion for all arguments:
* `:LspStart <config_name>` Start the requested server name. Will only successfully start if the command detects a root directory matching the current config. Pass `autostart = false` to your `.setup{}` call for a language server if you would like to launch clients solely with this command. Defaults to all servers matching current buffer filetype.
* `:LspStop <client_id>` Defaults to stopping all buffer clients.
* `:LspRestart <client_id>` Defaults to restarting all buffer clients.
## Wiki
## The wiki
See the [wiki](https://github.com/neovim/nvim-lspconfig/wiki) for additional topics, including:
Please see the [wiki](https://github.com/neovim/nvim-lspconfig/wiki) for additional topics, including:
* [Automatic server installation](https://github.com/neovim/nvim-lspconfig/wiki/Installing-language-servers#automatically)
* [Installing language servers automatically](https://github.com/neovim/nvim-lspconfig/wiki/Installing-language-servers-automatically)
* [Snippets support](https://github.com/neovim/nvim-lspconfig/wiki/Snippets)
* [Project local settings](https://github.com/neovim/nvim-lspconfig/wiki/Project-local-settings)
* [Recommended plugins for enhanced language server features](https://github.com/neovim/nvim-lspconfig/wiki/Language-specific-plugins)
## Windows
In order for neovim to launch certain executables on Windows, it must append `.cmd` to the command name. To work around this, manually append `.cmd` to the entry `cmd` in a given plugin's setup{} call.
## Contributions
If you are missing a language server on the list in [server_configurations.md](doc/server_configurations.md), contributing
a new configuration for it helps others, especially if the server requires special setup. Follow these steps:
a new configuration for it would be appreciated. You can follow these steps:
1. Read [CONTRIBUTING.md](CONTRIBUTING.md).
2. Create a new file at `lua/lspconfig/server_configurations/SERVER_NAME.lua`.
- Copy an [existing config](https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/)
2. Choose a language from [the coc.nvim wiki](https://github.com/neoclide/coc.nvim/wiki/Language-servers) or
[emacs-lsp](https://github.com/emacs-lsp/lsp-mode#supported-languages).
3. Create a new file at `lua/lspconfig/SERVER_NAME.lua`.
- Copy an [existing config](https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/)
to get started. Most configs are simple. For an extensive example see
[texlab.lua](https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/texlab.lua).
3. Ask questions on our [Discourse](https://neovim.discourse.group/c/7-category/7) or in the [Neovim Matrix room](https://app.element.io/#/room/#neovim:matrix.org).
[texlab.lua](https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/texlab.lua).
4. Ask questions on our [Discourse](https://neovim.discourse.group/c/7-category/7) or in the [Neovim Gitter](https://gitter.im/neovim/neovim).
You can also help out by testing [PRs with the `needs-testing`](https://github.com/neovim/nvim-lspconfig/issues?q=is%3Apr+is%3Aopen+label%3Aneeds-testing) label) that affect language servers you use regularly.

View File

@ -0,0 +1,4 @@
function! health#lspconfig#check()
call health#report_start('Checking language server protocol configuration')
lua require 'lspconfig.health'.check()
endfunction

View File

@ -1,14 +1,29 @@
*lspconfig.txt* For Nvim version 0.7+
*lspconfig.txt* For Nvim version 0.5.1+ Last change: 2021 Nov 7
==============================================================================
TABLE OF CONTENTS *lspconfig-toc*
nvim-lspconfig provides user-contributed configs for the Nvim |lsp| client.
Type |gO| to see the table of contents.
1. Introduction (|lspconfig|)
2. LSP overview (|lspconfig-lsp|)
3. Quickstart (|lspconfig-quickstart|)
4. Setup {} (|lspconfig-setup|)
5. Global defaults (|lspconfig-global-defaults|)
6. Server configurations (|lspconfig-configurations|)
6a. Adding servers (|lspconfig-adding-servers|)
7. Root directories (|lspconfig-root-detection|)
7a. Advanced detection (|lspconfig-root-advanced|)
7b. Single file support (|lspconfig-single-file-support|)
8. Commands (|lspconfig-commands|)
9. Keybindings (|lspconfig-keybindings|)
10. Completion (|lspconfig-completion|)
11. Debugging (|lspconfig-debugging|)
12. Logging (|lspconfig-logging|)
13. Scope (|lspconfig-scope|)
==============================================================================
INTRODUCTION *lspconfig*
nvim-lspconfig is a collection of community-contributed configurations for the
built-in language server client in Nvim core. This plugin provides four
`lspconfig` is a collection of community contributed configurations for the
built-in language server client in Neovim core. This plugin provides four
primary functionalities:
- default launch commands, initialization options, and settings for each
@ -20,10 +35,33 @@ primary functionalities:
- utility commands such as LspInfo, LspStart, LspStop, and LspRestart for
managing language server instances
nvim-lspconfig is not required to use the builtin Nvim |lsp| client, it is
just a convenience layer.
`lspconfig` is not required to use the built-in client, it is only one front-end
interface for when a language server specific plugin is not available.
See |lspconfig-all| for the complete list of language server configurations.
See |lspconfig-server-configurations| by typing `K` over it for the complete
list of language servers configurations.
==============================================================================
LSP OVERVIEW *lspconfig-lsp*
Nvim supports the Language Server Protocol (LSP) via the built-in language
server client. LSP facilitates many features, some of which include:
- go-to-definition
- find-references
- hover
- completion
- rename
- format
- refactor
These features are implemented in Neovim core, not `lspconfig`. See `:help lsp`
for more details.
NOTE: Feature availability depends on the implementation details of the
server. A server may implement only a subset of these features. Always
consult the server documentation before filing a bug report on a missing
feature.
==============================================================================
QUICKSTART *lspconfig-quickstart*
@ -35,12 +73,12 @@ QUICKSTART *lspconfig-quickstart*
require'lspconfig'.clangd.setup{}
<
- create a new project, ensure that it contains a root marker which matches the
server requirements specified in |lspconfig-all|.
server requirements specified in |lspconfig-server-configurations|.
- open a file within that project, such as `main.c`.
- If you need more information about a server configuration, read the corresponding
entry in |lspconfig-all|.
entry in |lspconfig-server-configurations|.
==============================================================================
THE SETUP METAMETHOD *lspconfig-setup*
@ -54,8 +92,9 @@ Using the default configuration for a server is simple:
>
require'lspconfig'.clangd.setup{}
<
The available server names are listed in |lspconfig-all| and match the server
name in `config.SERVER_NAME` defined in each configuration's source file.
The available server names are listed in |lspconfig-server-configurations| and
match the server name in `config.SERVER_NAME` defined in each configuration's
source file.
The purpose of `setup{}` is to wrap the call to Nvim's built-in
`vim.lsp.start_client()` with an autocommand that automatically launch a
@ -179,6 +218,10 @@ passed overrides to `setup {}` are:
the language server. These settings allow a user to change optional runtime
settings of the language server.
The script that automatically generates `server_configurations.md` converts
the `package.json` referenced in a server configuration source file
into a list of optional settings listed in |lspconfig-server-configurations|.
As an example, to set the following settings found in the pyright
documentation:
@ -197,6 +240,12 @@ passed overrides to `setup {}` are:
}
}
<
Note that the autogenerated settings occasionally include VS code specific
settings. If a setting is not respected by a language server, consult
upstream documentation.
==============================================================================
OVERRIDING GLOBAL DEFAULTS *lspconfig-global-defaults*
@ -215,44 +264,23 @@ 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*
See |lspconfig-all| for the complete list of language server configurations.
See |lspconfig-server-configurations| by typing `K` over it for the complete
list of language servers configurations.
While the `setup {}` function is the primary interface to `lspconfig`, for
servers for which there is not a configuration, it is necessary to define a
@ -264,49 +292,35 @@ 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`.
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:
or special keys like `description`. Example:
>
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
})
commands = {
TexlabBuild = {
function()
buf_build(0)
end;
"-range";
description = "Build the current buffer";
};
};
<
The `configs.__newindex` metamethod consumes the config definition and returns
an object with a `setup()` method, to be invoked by users:
>
@ -316,36 +330,40 @@ After you set `configs.SERVER_NAME` you can add arbitrary language-specific
functions to it if necessary.
Example:
>
configs.texlab.buf_build = buf_build
<
==============================================================================
ADDING NEW SERVERS *lspconfig-new*
ADDING NEW SERVERS *lspconfig-adding-servers*
The steps for adding and enabling a new server configuration are:
The three steps for adding and enabling a new server configuration are:
1. load the `lspconfig` module (note that this is a stylistic choice) >
- load the `lspconfig` module (note that this is a stylistic choice)
>
local lspconfig = require 'lspconfig'
<
2. define the configuration >
- define the configuration
>
local configs = require 'lspconfig.configs'
-- Check if the config is already defined (useful when reloading this file)
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
3. call `setup()` to enable the FileType autocmd >
- call `setup()` to enable the FileType autocmd
>
lspconfig.foo_lsp.setup{}
<
==============================================================================
@ -391,9 +409,6 @@ below returns a function that takes as its argument the current buffer path.
>
root_dir = util.find_json_ancestor
<
Note: On Windows, `lspconfig` always assumes forward slash normalized paths with
capitalized drive letters.
==============================================================================
ADVANCED ROOT DIRECTORY DETECTION *lspconfig-root-advanced*
*lspconfig-root-composition*
@ -477,71 +492,65 @@ following is an example Lua block which demonstrates how to leverage
`on-attach` to selectively apply keybindings after a language servers has
attached to a given buffer.
>
>
-- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap=true, silent=true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
local nvim_lsp = require('lspconfig')
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap=true, silent=true, buffer=bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<space>f', vim.lsp.buf.formatting, bufopts)
end
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
local lsp_flags = {
-- This is the default in Nvim 0.7+
debounce_text_changes = 150,
}
require('lspconfig')['pyright'].setup{
on_attach = on_attach,
flags = lsp_flags,
}
require('lspconfig')['tsserver'].setup{
on_attach = on_attach,
flags = lsp_flags,
}
require('lspconfig')['rust_analyzer'].setup{
on_attach = on_attach,
flags = lsp_flags,
-- Server-specific settings...
settings = {
["rust-analyzer"] = {}
-- Mappings.
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { 'pyright', 'rust_analyzer', 'tsserver' }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = on_attach,
flags = {
debounce_text_changes = 150,
}
}
}
end
<
Note: these keymappings are meant for illustration and override some
infrequently used default mappings.
==============================================================================
COMPLETION SUPPORT *lspconfig-completion*
Manually triggered completion can be provided by Nvim's built-in omnifunc.
See |lsp-config|.
See `:help omnifunc` for more details.
For autocompletion, Nvim does not provide built-in functionality. Consult the
nvim-lspconfig wiki, which provides configuration examples for using
a completion plugin with the built-in client
For autocompletion, Nvim does not offer built-in functionality at this time.
Consult the `lspconfig` wiki, which provides configuration examples for using a
completion plugin with the built-in client
==============================================================================
DEBUGGING *lspconfig-debugging*
@ -554,17 +563,17 @@ is typically (in rough order):
- a plugin
- overrides in a user configuration
- the built-in client in Nvim core
- nvim-lspconfig
- `lspconfig`
The first step in debugging is to test with a minimal configuration (such as
`../test/minimal_init.lua`). Historically, many users problems are due to
plugins or misconfiguration.
Should that fail, identifying which component is the culprit is challenging.
The following are the only categories of bugs that pertain to nvim-lspconfig.
The following are the only categories of bugs that pertain to `lspconfig`.
- The root directory inferred for your project is wrong, or it should be
detected but is not due to a bug in the nvim-lspconfig path utilities.
detected but is not due to a bug in the `lspconfig` path utilities.
- The server is launching, but you believe that the default settings,
initialization options, or command arguments are suboptimal and should be
replaced based on your understanding of the server documentation.
@ -574,14 +583,14 @@ tracker. All bugs pertaining to plugins should be reported to the respective
plugin. All missing features in a language server should be reported to the
upstream language server issue tracker.
For debugging nvim-lspconfig issues, the most common hurdles users face are:
For debugging `lspconfig` issues, the most common hurdles users face are:
- The language server is not installed or is otherwise not executable.
nvim-lspconfig does not install language servers for you. Ensure the `cmd`
`lspconfig` does not install language servers for you. Ensure the `cmd`
defined in `server_configurations.md` is executable from the command
line. If the absolute path to the binary is not supplied in `cmd`, ensure
it is on your PATH.
- No root detected. nvim-lspconfig is built around the concept of projects. See
- No root detected. `lspconfig` is built around the concept of projects. See
|lspconfig-root-detection| for more details. Most of the time,
initializing a git repo will suffice.
- Misconfiguration. Often users will override `cmd`, `on_init`, or
@ -608,7 +617,7 @@ the built-in client, specifically considering the RPC logs. Example:
Attempt to run the language server, and open the log with:
>
:LspLog
:lua vim.cmd('e'..vim.lsp.get_log_path())
<
Note that `ERROR` messages containing `stderr` only indicate that the log was
sent to `stderr`. Many servers counter-intuitively send harmless messages
@ -631,18 +640,6 @@ 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:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,11 +2,11 @@
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
"lastModified": 1634851050,
"narHash": "sha256-N83GlSGPJJdcqhUxSCS/WwW5pksYf3VP1M13cDRTSVA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
"rev": "c91f3de5adaf1de973b797ef7485e441a65b8935",
"type": "github"
},
"original": {
@ -17,11 +17,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1659522808,
"narHash": "sha256-HBcM19nGhI3IWwPNVlYb0MZ8VW6iKp4JbAVkeIHVykc=",
"lastModified": 1626644568,
"narHash": "sha256-+WxW0u6AJUn/AzIxUuNKtEDxSRcUP0v/iZ/tRXhLGEc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "168d1c578909dc143ba52dbed661c36e76b12b36",
"rev": "d5bd34ebf2c2c2b380b76cb86bc68522bc6af4d7",
"type": "github"
},
"original": {

View File

@ -11,7 +11,6 @@
buildInputs = [
pkgs.stylua
pkgs.luaPackages.luacheck
pkgs.selene
];
};
}

View File

@ -4,9 +4,67 @@ local M = {
util = require 'lspconfig.util',
}
M._root = {}
function M.available_servers()
vim.deprecate('lspconfig.available_servers', 'lspconfig.util.available_servers', '0.1.4', 'lspconfig')
return M.util.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',
},
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)
end
local mt = {}

View File

@ -1,6 +1,6 @@
local util = require 'lspconfig.util'
local api, validate, lsp = vim.api, vim.validate, vim.lsp
local tbl_deep_extend = vim.tbl_deep_extend
local tbl_extend = vim.tbl_extend
local configs = {}
@ -25,24 +25,22 @@ function configs.__newindex(t, config_name, config_def)
local M = {}
local default_config = tbl_deep_extend('keep', config_def.default_config, util.default_config)
local default_config = tbl_extend('keep', config_def.default_config, util.default_config)
-- Force this part.
default_config.name = config_name
function M.setup(user_config)
local lsp_group = vim.api.nvim_create_augroup('lspconfig', { clear = false })
function M.setup(config)
validate {
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 },
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 },
}
if user_config.commands then
for k, v in pairs(user_config.commands) do
if config.commands then
for k, v in pairs(config.commands) do
validate {
['command.name'] = { k, 's' },
['command.fn'] = { v[1], 'f' },
@ -50,10 +48,10 @@ function configs.__newindex(t, config_name, config_def)
end
end
local config = tbl_deep_extend('keep', user_config, default_config)
config = tbl_extend('keep', config, default_config)
if util.on_setup then
pcall(util.on_setup, config, user_config)
pcall(util.on_setup, config)
end
if config.autostart == true then
@ -66,17 +64,14 @@ function configs.__newindex(t, config_name, config_def)
event = 'BufReadPost'
pattern = '*'
end
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.',
api.nvim_command(
string.format(
"autocmd %s %s unsilent lua require'lspconfig'[%q].manager.try_add()",
event,
pattern,
config.name
),
})
)
)
end
local get_root_dir = config.root_dir
@ -84,34 +79,21 @@ function configs.__newindex(t, config_name, config_def)
function M.launch()
local root_dir
if get_root_dir then
local bufnr = api.nvim_get_current_buf()
local bufname = api.nvim_buf_get_name(bufnr)
if not util.bufname_valid(bufname) then
return
end
root_dir = get_root_dir(util.path.sanitize(bufname), bufnr)
root_dir = get_root_dir(api.nvim_buf_get_name(0), api.nvim_get_current_buf())
end
if root_dir then
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
),
})
api.nvim_command(
string.format(
"autocmd %s unsilent lua require'lspconfig'[%q].manager.try_add_wrapper()",
'BufReadPost ' .. root_dir .. '/*',
config.name
)
)
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
local bufname = api.nvim_buf_get_name(bufnr)
if util.bufname_valid(bufname) then
local buf_dir = util.path.sanitize(bufname)
if buf_dir:sub(1, root_dir:len()) == root_dir then
M.manager.try_add_wrapper(bufnr)
end
local buf_dir = api.nvim_buf_get_name(bufnr)
if buf_dir:sub(1, root_dir:len()) == root_dir then
M.manager.try_add_wrapper(bufnr)
end
end
elseif config.single_file_support then
@ -119,13 +101,12 @@ function configs.__newindex(t, config_name, config_def)
-- Effectively this is the root from lspconfig's perspective, as we use
-- this to attach additional files in the same parent folder to the same server.
-- We just no longer send rootDirectory or workspaceFolders during initialization.
local bufname = api.nvim_buf_get_name(0)
if not util.bufname_valid(bufname) then
return
end
local pseudo_root = util.path.dirname(util.path.sanitize(bufname))
local client_id = M.manager.add(pseudo_root, true)
vim.lsp.buf_attach_client(vim.api.nvim_get_current_buf(), client_id)
local pseudo_root = util.path.dirname(api.nvim_buf_get_name(0))
M.manager.add(pseudo_root, true)
else
vim.notify(
string.format('[lspconfig] Autostart for %s failed: matching root directory not detected.', config_name)
)
end
end
@ -146,19 +127,21 @@ function configs.__newindex(t, config_name, config_def)
M.manager = nil
end
local make_config = function(root_dir)
local new_config = tbl_deep_extend('keep', vim.empty_dict(), config)
new_config.capabilities = tbl_deep_extend('keep', new_config.capabilities, {
local make_config = function(_root_dir)
local new_config = vim.tbl_deep_extend('keep', vim.empty_dict(), config)
new_config = vim.tbl_deep_extend('keep', new_config, default_config)
new_config.capabilities = new_config.capabilities or lsp.protocol.make_client_capabilities()
new_config.capabilities = vim.tbl_deep_extend('keep', new_config.capabilities, {
workspace = {
configuration = true,
},
})
if config_def.on_new_config then
pcall(config_def.on_new_config, new_config, root_dir)
pcall(config_def.on_new_config, new_config, _root_dir)
end
if config.on_new_config then
pcall(config.on_new_config, new_config, root_dir)
pcall(config.on_new_config, new_config, _root_dir)
end
new_config.on_init = util.add_hook_after(new_config.on_init, function(client, result)
@ -167,7 +150,7 @@ function configs.__newindex(t, config_name, config_def)
client.offset_encoding = result.offsetEncoding
end
-- Send `settings` to server via workspace/didChangeConfiguration
-- Send `settings to server via workspace/didChangeConfiguration
function client.workspace_did_change_configuration(settings)
if not settings then
return
@ -190,36 +173,32 @@ function configs.__newindex(t, config_name, config_def)
if bufnr == api.nvim_get_current_buf() then
M._setup_buffer(client.id, bufnr)
else
if vim.api.nvim_buf_is_valid(bufnr) then
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
api.nvim_command(
string.format(
"autocmd BufEnter <buffer=%d> ++once lua require'lspconfig'[%q]._setup_buffer(%d,%d)",
bufnr,
config_name,
client.id,
bufnr
)
)
end
end)
new_config.root_dir = root_dir
new_config.root_dir = _root_dir
new_config.workspace_folders = {
{
uri = vim.uri_from_fname(root_dir),
name = string.format('%s', root_dir),
uri = vim.uri_from_fname(_root_dir),
name = string.format('%s', _root_dir),
},
}
return new_config
end
local manager = util.server_per_root_dir_manager(function(root_dir)
return make_config(root_dir)
local manager = util.server_per_root_dir_manager(function(_root_dir)
return make_config(_root_dir)
end)
-- Try to attach the buffer `bufnr` to a client using this config, creating
-- a new client if one doesn't already exist for `bufnr`.
function manager.try_add(bufnr)
bufnr = bufnr or api.nvim_get_current_buf()
@ -230,21 +209,19 @@ function configs.__newindex(t, config_name, config_def)
local id
local root_dir
local bufname = api.nvim_buf_get_name(bufnr)
if not util.bufname_valid(bufname) then
return
end
local buf_path = util.path.sanitize(bufname)
if get_root_dir then
root_dir = get_root_dir(buf_path, bufnr)
root_dir = get_root_dir(api.nvim_buf_get_name(bufnr), bufnr)
end
if root_dir then
id = manager.add(root_dir, false)
elseif config.single_file_support then
local pseudo_root = util.path.dirname(buf_path)
local pseudo_root = util.path.dirname(api.nvim_buf_get_name(0))
id = manager.add(pseudo_root, true)
else
vim.notify(
string.format('lspconfig: Autostart for %s failed: matching root directory not detected.', config_name)
)
end
if id then
@ -252,27 +229,19 @@ function configs.__newindex(t, config_name, config_def)
end
end
-- Check that the buffer `bufnr` has a valid filetype according to
-- `config.filetypes`, then do `manager.try_add(bufnr)`.
function manager.try_add_wrapper(bufnr)
bufnr = bufnr or api.nvim_get_current_buf()
local buf_filetype = vim.api.nvim_buf_get_option(bufnr, 'filetype')
if config.filetypes then
for _, filetype in ipairs(config.filetypes) do
if buf_filetype == filetype then
manager.try_add(bufnr)
return
end
for _, filetype in ipairs(config.filetypes) do
if buf_filetype == filetype then
manager.try_add(bufnr)
return
end
-- `config.filetypes = nil` means all filetypes are valid.
else
manager.try_add(bufnr)
end
end
M.manager = manager
M.make_config = make_config
if reload and config.autostart ~= false then
if reload and not (config.autostart == false) then
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
manager.try_add_wrapper(bufnr)
end
@ -291,10 +260,13 @@ 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

@ -0,0 +1,28 @@
local M = {}
function M.check()
local configs = require 'lspconfig.configs'
if not configs or vim.tbl_count(configs) == 0 then
vim.fn['health#report_warn'] [[Can't find any config.]]
end
for _, top_level_config in pairs(configs) do
-- Only check configs that have a make_config function.
if not (top_level_config.make_config == nil) then
-- the folder needs to exist
local config = top_level_config.make_config '.'
local status, cmd = pcall(vim.lsp._cmd_parts, config.cmd)
if not status then
vim.fn['health#report_error'](string.format('%s: config.cmd error, %s', config.name, cmd))
else
if not (vim.fn.executable(cmd) == 1) then
vim.fn['health#report_error'](string.format('%s: The given command %q is not executable.', config.name, cmd))
else
vim.fn['health#report_info'](string.format('%s: configuration checked.', config.name))
end
end
end
end
end
return M

View File

@ -12,6 +12,7 @@ return {
root_dir = util.root_pattern('Makefile', '.git', '*.gpr', '*.adc'),
},
docs = {
package_json = 'https://raw.githubusercontent.com/AdaCore/ada_language_server/master/integration/vscode/ada/package.json',
description = [[
https://github.com/AdaCore/ada_language_server

View File

@ -11,29 +11,21 @@ end
local default_probe_dir = get_probe_dir(vim.fn.getcwd())
local bin_name = 'ngserver'
local args = {
'--stdio',
'--tsProbeLocations',
default_probe_dir,
'--ngProbeLocations',
default_probe_dir,
}
local cmd = { bin_name, unpack(args) }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, unpack(args) }
end
return {
default_config = {
cmd = cmd,
cmd = {
'ngserver',
'--stdio',
'--tsProbeLocations',
default_probe_dir,
'--ngProbeLocations',
default_probe_dir,
},
filetypes = { 'typescript', 'html', 'typescriptreact', 'typescript.tsx' },
-- Check for angular.json since that is the root of the project.
-- Check for angular.json or .git first 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',
root_dir = util.root_pattern('angular.json', '.git'),
},
on_new_config = function(new_config, new_root_dir)
local new_probe_dir = get_probe_dir(new_root_dir)
@ -69,7 +61,7 @@ require'lspconfig'.angularls.setup{
```
]],
default_config = {
root_dir = [[root_pattern("angular.json")]],
root_dir = [[root_pattern("angular.json", ".git")]],
},
},
}

View File

@ -1,15 +1,8 @@
local util = require 'lspconfig.util'
local bin_name = 'ansible-language-server'
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,
cmd = { 'ansible-language-server', '--stdio' },
settings = {
ansible = {
python = {
@ -27,7 +20,7 @@ return {
},
},
},
filetypes = { 'yaml.ansible' },
filetypes = { 'yaml', 'yaml.ansible' },
root_dir = util.root_pattern('ansible.cfg', '.ansible-lint'),
single_file_support = true,
},
@ -37,10 +30,9 @@ https://github.com/ansible/ansible-language-server
Language server for the ansible configuration management tool.
`ansible-language-server` can be installed via `npm`:
`ansible-language-server` can be installed via `yarn`:
```sh
npm install -g @ansible/ansible-language-server
yarn global add ansible-language-server
```
]],
},

View File

@ -1,26 +0,0 @@
local util = require 'lspconfig.util'
local bin_name = 'antlersls'
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 = { 'html', 'antlers' },
root_dir = util.root_pattern 'composer.json',
},
docs = {
description = [[
https://www.npmjs.com/package/antlers-language-server
`antlersls` can be installed via `npm`:
```sh
npm install -g antlers-language-server
```
]],
},
}

View File

@ -1,46 +0,0 @@
local util = require 'lspconfig.util'
return {
default_config = {
filetypes = { 'apexcode' },
root_dir = util.root_pattern 'sfdx-project.json',
on_new_config = function(config)
if not config.cmd and config.apex_jar_path then
config.cmd = {
'java',
'-cp',
config.apex_jar_path,
'-Ddebug.internal.errors=true',
'-Ddebug.semantic.errors=' .. tostring(config.apex_enable_semantic_errors or false),
'-Ddebug.completion.statistics=' .. tostring(config.apex_enable_completion_statistics or false),
'-Dlwc.typegeneration.disabled=true',
}
if config.apex_jvm_max_heap then
table.insert(config.cmd, '-Xmx' .. config.apex_jvm_max_heap)
end
table.insert(config.cmd, 'apex.jorje.lsp.ApexLanguageServerLauncher')
end
end,
},
docs = {
description = [[
https://github.com/forcedotcom/salesforcedx-vscode
Language server for Apex.
For manual installation, download the JAR file from the [VSCode
extension](https://github.com/forcedotcom/salesforcedx-vscode/tree/develop/packages/salesforcedx-vscode-apex).
```lua
require'lspconfig'.apex_ls.setup {
apex_jar_path = '/path/to/apex-jorje-lsp.jar',
apex_enable_semantic_errors = false, -- Whether to allow Apex Language Server to surface semantic errors
apex_enable_completion_statistics = false, -- Whether to allow Apex Language Server to collect telemetry on code completion usage
}
```
]],
default_config = {
root_dir = [[root_pattern('sfdx-project.json')]],
},
},
}

View File

@ -2,6 +2,7 @@ local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'arduino-language-server' },
filetypes = { 'arduino' },
root_dir = util.root_pattern '*.ino',
},
@ -12,52 +13,38 @@ https://github.com/arduino/arduino-language-server
Language server for Arduino
The `arduino-language-server` can be installed by running:
go get -u github.com/arduino/arduino-language-server
```
go install github.com/arduino/arduino-language-server@latest
```
The `arduino-cli` tools must also be installed. Follow these instructions for your distro:
https://arduino.github.io/arduino-cli/latest/installation/
The `arduino-cli` tool must also be installed. Follow [these
installation instructions](https://arduino.github.io/arduino-cli/latest/installation/) for
your platform.
After installing the `arduino-cli` tools, follow these instructions for generating
a configuration file:
https://arduino.github.io/arduino-cli/latest/getting-started/#create-a-configuration-file
and make sure you install any relevant platforms libraries:
https://arduino.github.io/arduino-cli/latest/getting-started/#install-the-core-for-your-board
After installing `arduino-cli`, follow [these
instructions](https://arduino.github.io/arduino-cli/latest/getting-started/#create-a-configuration-file)
for generating a configuration file if you haven't done so already, and make
sure you [install any relevant platforms
libraries](https://arduino.github.io/arduino-cli/latest/getting-started/#install-the-core-for-your-board).
Make sure to save the full path to the created `arduino-cli.yaml` file for later.
The language server also requires `clangd` be installed. It will look for `clangd` by default but
the binary path can be overridden if need be.
The language server also requires `clangd` to be installed. Follow [these
installation instructions](https://clangd.llvm.org/installation) for your
platform.
Next, you will need to decide which FQBN to use.
To identify the available FQBNs for boards you currently have connected, you may use the `arduino-cli` command, like so:
```sh
$ arduino-cli board list
Port Protocol Type Board Name FQBN Core
/dev/ttyACM0 serial Serial Port (USB) Arduino Uno arduino:avr:uno arduino:avr
^^^^^^^^^^^^^^^
```
After all dependencies are installed you'll need to set the command for the
language server in your setup:
After all dependencies are installed you'll need to override the lspconfig command for the
language server in your setup function with the necessary configurations:
```lua
require'lspconfig'.arduino_language_server.setup {
cmd = {
"arduino-language-server",
"-cli-config", "/path/to/arduino-cli.yaml",
"-fqbn", "arduino:avr:uno",
"-cli", "arduino-cli",
"-clangd", "clangd"
}
}
lspconfig.arduino_language_server.setup({
cmd = {
-- Required
"arduino-language-server",
"-cli-config", "/path/to/arduino-cli.yaml",
-- Optional
"-cli", "/path/to/arduino-cli",
"-clangd", "/path/to/clangd"
}
})
```
For further instruction about configuration options, run `arduino-language-server --help`.
]],
},
}

View File

@ -1,19 +0,0 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'asm-lsp' },
filetypes = { 'asm', 'vmasm' },
root_dir = util.find_git_ancestor,
},
docs = {
description = [[
https://github.com/bergercookie/asm-lsp
Language Server for GAS/GO Assembly
`asm-lsp` can be installed via cargo:
cargo install asm-lsp
]],
},
}

View File

@ -1,32 +0,0 @@
local util = require 'lspconfig.util'
local bin_name = 'astro-ls'
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 = { 'astro' },
root_dir = util.root_pattern('package.json', 'tsconfig.json', 'jsconfig.json', '.git'),
init_options = {
configuration = {},
},
},
docs = {
description = [[
https://github.com/withastro/language-tools/tree/main/packages/language-server
`astro-ls` can be installed via `npm`:
```sh
npm install -g @astrojs/language-server
```
]],
default_config = {
root_dir = [[root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git")]],
},
},
}

View File

@ -1,22 +0,0 @@
if vim.version().major == 0 and vim.version().minor < 7 then
vim.notify('The AWK language server requires nvim >= 0.7', vim.log.levels.ERROR)
return
end
return {
default_config = {
cmd = { 'awk-language-server' },
filetypes = { 'awk' },
single_file_support = true,
},
docs = {
description = [[
https://github.com/Beaglefoot/awk-language-server/
`awk-language-server` can be installed via `npm`:
```sh
npm install -g awk-language-server
```
]],
},
}

View File

@ -1,15 +1,8 @@
local util = require 'lspconfig.util'
local bin_name = 'bash-language-server'
local cmd = { bin_name, 'start' }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, 'start' }
end
return {
default_config = {
cmd = cmd,
cmd = { 'bash-language-server', 'start' },
cmd_env = {
-- Prevent recursive scanning which will cause issues when opening a file
-- directly in the home directory (e.g. ~/foo.sh).
@ -25,11 +18,6 @@ return {
description = [[
https://github.com/mads-hartmann/bash-language-server
`bash-language-server` can be installed via `npm`:
```sh
npm i -g bash-language-server
```
Language server for bash, written using tree sitter in typescript.
]],
default_config = {

View File

@ -2,13 +2,15 @@ local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'beancount-language-server', '--stdio' },
filetypes = { 'beancount', 'bean' },
cmd = { 'beancount-langserver' },
filetypes = { 'beancount' },
root_dir = util.find_git_ancestor,
single_file_support = true,
init_options = {
-- this is the path to the beancout journal file
journalFile = '',
-- this is the path to the python binary with beancount installed
pythonPath = 'python3',
},
},
docs = {
@ -18,7 +20,7 @@ https://github.com/polarmutex/beancount-language-server#installation
See https://github.com/polarmutex/beancount-language-server#configuration for configuration options
]],
default_config = {
root_dir = [[root_pattern(".git")]],
root_dir = [[root_pattern("elm.json")]],
},
},
}

View File

@ -1,33 +0,0 @@
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

@ -1,18 +1,10 @@
local util = require 'lspconfig.util'
local root_files = {
'compile_commands.json',
'.ccls',
}
return {
default_config = {
cmd = { 'ccls' },
filetypes = { 'c', 'cpp', 'objc', 'objcpp' },
root_dir = function(fname)
return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname)
end,
offset_encoding = 'utf-32',
root_dir = util.root_pattern('compile_commands.json', '.ccls', 'compile_flags.txt', '.git'),
-- ccls does not support sending a null root directory
single_file_support = false,
},
@ -21,7 +13,7 @@ return {
https://github.com/MaskRay/ccls/wiki
ccls relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html) specified
as compile_commands.json or, for simpler projects, a .ccls.
as compile_commands.json or, for simpler projects, a compile_flags.txt.
For details on how to automatically generate one using CMake look [here](https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html). Alternatively, you can use [Bear](https://github.com/rizsotto/Bear).
Customization options are passed to ccls at initialization time via init_options, a list of available options can be found [here](https://github.com/MaskRay/ccls/wiki/Customization#initialization-options). For example:
@ -44,7 +36,7 @@ lspconfig.ccls.setup {
]],
default_config = {
root_dir = [[root_pattern('compile_commands.json', '.ccls', '.git')]],
root_dir = [[root_pattern("compile_commands.json", ".ccls", "compile_flags.txt", ".git") or dirname]],
},
},
}

View File

@ -6,45 +6,48 @@ local function switch_source_header(bufnr)
local clangd_client = util.get_active_client_by_name(bufnr, 'clangd')
local params = { uri = vim.uri_from_bufnr(bufnr) }
if clangd_client then
clangd_client.request('textDocument/switchSourceHeader', params, function(err, result)
if err then
error(tostring(err))
end
if not result then
print 'Corresponding file cannot be determined'
return
end
vim.api.nvim_command('edit ' .. vim.uri_to_fname(result))
end, bufnr)
clangd_client.request(
'textDocument/switchSourceHeader',
params,
util.compat_handler(function(err, result)
if err then
error(tostring(err))
end
if not result then
print 'Corresponding file cannot be determined'
return
end
vim.api.nvim_command('edit ' .. vim.uri_to_fname(result))
end),
bufnr
)
else
print 'method textDocument/switchSourceHeader is not supported by any servers active on the current buffer'
end
end
local root_files = {
'.clangd',
'.clang-tidy',
'.clang-format',
'compile_commands.json',
'compile_flags.txt',
'configure.ac', -- AutoTools
}
local root_pattern = util.root_pattern('compile_commands.json', 'compile_flags.txt', '.git')
local default_capabilities = {
textDocument = {
completion = {
editsNearCursor = true,
local default_capabilities = vim.tbl_deep_extend(
'force',
util.default_config.capabilities or vim.lsp.protocol.make_client_capabilities(),
{
textDocument = {
completion = {
editsNearCursor = true,
},
},
},
offsetEncoding = { 'utf-8', 'utf-16' },
}
offsetEncoding = { 'utf-8', 'utf-16' },
}
)
return {
default_config = {
cmd = { 'clangd' },
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda', 'proto' },
cmd = { 'clangd', '--background-index' },
filetypes = { 'c', 'cpp', 'objc', 'objcpp' },
root_dir = function(fname)
return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname)
local filename = util.path.is_absolute(fname) and fname or util.path.join(vim.loop.cwd(), fname)
return root_pattern(filename)
end,
single_file_support = true,
capabilities = default_capabilities,
@ -61,27 +64,14 @@ return {
description = [[
https://clangd.llvm.org/installation.html
- **NOTE:** Clang >= 11 is recommended! See [#23](https://github.com/neovim/nvim-lsp/issues/23).
- If `compile_commands.json` lives in a build directory, you should
symlink it to the root of your source tree.
```
ln -s /path/to/myproject/build/compile_commands.json /path/to/myproject/
```
- clangd relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html)
specified as compile_commands.json, see https://clangd.llvm.org/installation#compile_commandsjson
**NOTE:** Clang >= 9 is recommended! See [this issue for more](https://github.com/neovim/nvim-lsp/issues/23).
clangd relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html) specified
as compile_commands.json or, for simpler projects, a compile_flags.txt.
For details on how to automatically generate one using CMake look [here](https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html). Alternatively, you can use [Bear](https://github.com/rizsotto/Bear).
]],
default_config = {
root_dir = [[
root_pattern(
'.clangd',
'.clang-tidy',
'.clang-format',
'compile_commands.json',
'compile_flags.txt',
'configure.ac',
'.git'
)
]],
root_dir = [[root_pattern("compile_commands.json", "compile_flags.txt", ".git") or dirname]],
capabilities = [[default capabilities, with offsetEncoding utf-8]],
},
},

View File

@ -1,19 +0,0 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'clarity-lsp' },
filetypes = { 'clar', 'clarity' },
root_dir = util.root_pattern '.git',
},
docs = {
description = [[
`clarity-lsp` is a language server for the Clarity language. Clarity is a decidable smart contract language that optimizes for predictability and security. Smart contracts allow developers to encode essential business logic on a blockchain.
To learn how to configure the clarity language server, see the [clarity-lsp documentation](https://github.com/hirosystems/clarity-lsp).
]],
default_config = {
root_dir = [[root_pattern(".git")]],
},
},
}

View File

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

View File

@ -1,13 +1,10 @@
local util = require 'lspconfig.util'
local root_files = { 'CMakePresets.json', 'CTestConfig.cmake', '.git', 'build', 'cmake' }
return {
default_config = {
cmd = { 'cmake-language-server' },
filetypes = { 'cmake' },
root_dir = function(fname)
return util.root_pattern(unpack(root_files))(fname)
end,
root_dir = util.root_pattern('.git', 'compile_commands.json', 'build'),
single_file_support = true,
init_options = {
buildDirectory = 'build',
@ -20,7 +17,7 @@ https://github.com/regen100/cmake-language-server
CMake LSP Implementation
]],
default_config = {
root_dir = [[root_pattern('CMakePresets.json', 'CTestConfig.cmake', '.git', 'build', 'cmake')]],
root_dir = [[root_pattern(".git", "compile_commands.json", "build") or dirname]],
},
},
}

View File

@ -5,6 +5,7 @@ return {
cmd = { 'codeql', 'execute', 'language-server', '--check-errors', 'ON_CHANGE', '-q' },
filetypes = { 'ql' },
root_dir = util.root_pattern 'qlpack.yml',
single_file_support = true,
log_level = vim.lsp.protocol.MessageType.Warning,
before_init = function(initialize_params)
initialize_params['workspaceFolders'] = {

View File

@ -14,7 +14,7 @@ https://github.com/elbywan/crystalline
Crystal language server.
]],
default_config = {
root_dir = [[root_pattern('shard.yml', '.git')]],
root_dir = [[root_pattern('shard.yml', '.git') or dirname]],
},
},
}

View File

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

View File

@ -1,15 +1,10 @@
local util = require 'lspconfig.util'
local bin_name = 'vscode-css-language-server'
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,
cmd = { bin_name, '--stdio' },
filetypes = { 'css', 'scss', 'less' },
root_dir = util.root_pattern('package.json', '.git'),
single_file_support = true,

View File

@ -1,31 +0,0 @@
local util = require 'lspconfig.util'
local bin_name = 'cssmodules-language-server'
local cmd = { bin_name }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name }
end
return {
default_config = {
cmd = cmd,
filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact' },
root_dir = util.find_package_json_ancestor,
},
docs = {
description = [[
https://github.com/antonk52/cssmodules-language-server
Language server for autocompletion and go-to-definition functionality for CSS modules.
You can install cssmodules-language-server via npm:
```sh
npm install -g cssmodules-language-server
```
]],
default_config = {
root_dir = [[root_pattern("package.json")]],
},
},
}

View File

@ -1,15 +1,8 @@
local util = require 'lspconfig.util'
local bin_name = 'cucumber-language-server'
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,
cmd = { 'cucumber-language-server', '--stdio' },
filetypes = { 'cucumber' },
root_dir = util.find_git_ancestor,
},

View File

@ -1,22 +0,0 @@
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,13 +1,36 @@
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 bin_name = 'dart'
local find_dart_sdk_root_path = function()
if os.getenv 'FLUTTER_SDK' then
local flutter_path = os.getenv 'FLUTTER_SDK'
return util.path.join(flutter_path, 'cache', 'dart-sdk', 'bin', 'dart')
elseif vim.fn['executable'] 'flutter' == 1 then
local flutter_path = vim.fn['resolve'](vim.fn['exepath'] 'flutter')
local flutter_bin = vim.fn['fnamemodify'](flutter_path, ':h')
return util.path.join(flutter_bin, 'cache', 'dart-sdk', 'bin', 'dart')
elseif vim.fn['executable'] 'dart' == 1 then
return vim.fn['resolve'](vim.fn['exepath'] 'dart')
else
return ''
end
end
local analysis_server_snapshot_path = function()
local dart_sdk_root_path = vim.fn['fnamemodify'](find_dart_sdk_root_path(), ':h')
local snapshot = util.path.join(dart_sdk_root_path, 'snapshots', 'analysis_server.dart.snapshot')
if vim.fn['has'] 'win32' == 1 or vim.fn['has'] 'win64' == 1 then
snapshot = snapshot:gsub('/', '\\')
end
return snapshot
end
return {
default_config = {
cmd = cmd,
cmd = { bin_name, analysis_server_snapshot_path(), '--lsp' },
filetypes = { 'dart' },
root_dir = util.root_pattern 'pubspec.yaml',
init_options = {
@ -25,6 +48,7 @@ return {
},
},
docs = {
package_json = 'https://raw.githubusercontent.com/Dart-Code/Dart-Code/master/package.json',
description = [[
https://github.com/dart-lang/sdk/tree/master/pkg/analysis_server/tool/lsp_spec

View File

@ -1,41 +1,65 @@
local util = require 'lspconfig.util'
local lsp = vim.lsp
local function buf_cache(bufnr, client)
local function deno_uri_to_uri(uri)
-- denols returns deno:/https/deno.land/std%400.85.0/http/server.ts
-- nvim-lsp only handles deno://
if string.sub(uri, 1, 6) == 'deno:/' and string.sub(uri, 7, 7) ~= '/' then
return string.gsub(uri, '^deno:/', 'deno://', 1)
end
return uri
end
local function uri_to_deno_uri(uri)
-- denols use deno:/ and nvim-lsp use deno:// as buffer_uri.
-- When buffer_uri is deno://, change uri to deno:/.
if string.sub(uri, 1, 7) == 'deno://' and string.sub(uri, 8, 8) ~= '/' then
return string.gsub(uri, '^deno://', 'deno:/', 1)
end
return uri
end
local function buf_cache(bufnr)
local params = {}
params['referrer'] = { uri = vim.uri_from_bufnr(bufnr) }
params['uris'] = {}
client.request_sync('deno/cache', params)
lsp.buf_request(bufnr, 'deno/cache', params, function(err)
if err then
error(tostring(err))
end
end)
end
local function virtual_text_document_handler(uri, res, client)
if not res then
local function virtual_text_document_handler(uri, result)
if not result then
return nil
end
local lines = vim.split(res.result, '\n')
local bufnr = vim.uri_to_bufnr(uri)
for client_id, res in pairs(result) do
local lines = vim.split(res.result, '\n')
local bufnr = vim.uri_to_bufnr(deno_uri_to_uri(uri))
local current_buf = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
if #current_buf ~= 0 then
return nil
local current_buf = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
if #current_buf ~= 0 then
return nil
end
vim.api.nvim_buf_set_lines(bufnr, 0, -1, nil, lines)
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)
lsp.buf_attach_client(bufnr, client_id)
end
vim.api.nvim_buf_set_lines(bufnr, 0, -1, nil, lines)
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)
lsp.buf_attach_client(bufnr, client.id)
end
local function virtual_text_document(uri, client)
local function virtual_text_document(uri)
local params = {
textDocument = {
uri = uri,
},
}
local result = client.request_sync('deno/virtualTextDocument', params)
virtual_text_document_handler(uri, result, client)
local result = lsp.buf_request_sync(0, 'deno/virtualTextDocument', params)
virtual_text_document_handler(uri, result)
end
local function denols_handler(err, result, ctx)
@ -43,17 +67,39 @@ 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, client)
res['uri'] = uri
res['targetUri'] = uri
if string.sub(uri, 1, 6) == 'deno:/' then
virtual_text_document(uri)
res['uri'] = deno_uri_to_uri(uri)
res['targetUri'] = deno_uri_to_uri(uri)
end
end
lsp.handlers[ctx.method](err, result, ctx)
-- TODO remove this conditional when the handler is no longer being wrapped
-- with util.compat_handler (just use the else clause)
if vim.fn.has 'nvim-0.5.1' then
lsp.handlers[ctx.method](err, result, ctx)
else
lsp.handlers[ctx.method](err, ctx.method, result)
end
end
local function denols_definition()
local params = lsp.util.make_position_params()
params.textDocument.uri = uri_to_deno_uri(params.textDocument.uri)
lsp.buf_request(0, 'textDocument/definition', params)
end
local function denols_references(context)
vim.validate { context = { context, 't', true } }
local params = lsp.util.make_position_params()
params.context = context or {
includeDeclaration = true,
}
params[vim.type_idx] = vim.types.dictionary
params.textDocument.uri = uri_to_deno_uri(params.textDocument.uri)
lsp.buf_request(0, 'textDocument/references', params)
end
return {
@ -67,33 +113,31 @@ return {
'typescriptreact',
'typescript.tsx',
},
root_dir = util.root_pattern('deno.json', 'deno.jsonc', '.git'),
root_dir = util.root_pattern('deno.json', 'deno.jsonc', 'tsconfig.json', '.git'),
init_options = {
enable = true,
lint = false,
unstable = false,
},
handlers = {
['textDocument/definition'] = denols_handler,
['textDocument/references'] = denols_handler,
['workspace/executeCommand'] = function(err, result, context)
if context.params.command == 'deno.cache' then
buf_cache(context.bufnr, vim.lsp.get_client_by_id(context.client_id))
else
lsp.handlers[context.method](err, result, context)
end
end,
['textDocument/definition'] = util.compat_handler(denols_handler),
['textDocument/references'] = util.compat_handler(denols_handler),
},
},
commands = {
DenolsDefinition = {
denols_definition,
description = 'Jump to definition. This handle deno:/ schema in deno:// buffer.',
},
DenolsReferences = {
function()
denols_references { includeDeclaration = true }
end,
description = 'List references. This handle deno:/ schema in deno:// buffer.',
},
DenolsCache = {
function()
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
buf_cache(0)
end,
description = 'Cache a module and all of its dependencies.',
},
@ -104,7 +148,7 @@ https://github.com/denoland/deno
Deno's built-in language server
To appropriately highlight codefences returned from denols, you will need to augment vim.g.markdown_fenced languages
To approrpiately highlight codefences returned from denols, you will need to augment vim.g.markdown_fenced languages
in your init.lua. Example:
```lua
@ -115,7 +159,7 @@ vim.g.markdown_fenced_languages = {
]],
default_config = {
root_dir = [[root_pattern("deno.json", "deno.jsonc", ".git")]],
root_dir = [[root_pattern("deno.json", "deno.jsonc", "tsconfig.json", ".git")]],
},
},
}

View File

@ -20,7 +20,7 @@ cabal install dhall-lsp-server
prebuilt binaries can be found [here](https://github.com/dhall-lang/dhall-haskell/releases).
]],
default_config = {
root_dir = [[root_pattern(".git")]],
root_dir = [[root_pattern(".git") or dirname]],
},
},
}

View File

@ -1,15 +1,13 @@
local util = require 'lspconfig.util'
local bin_name = 'diagnostic-languageserver'
local cmd = { bin_name, '--stdio' }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
bin_name = bin_name .. '.cmd'
end
return {
default_config = {
cmd = cmd,
cmd = { bin_name, '--stdio' },
root_dir = util.find_git_ancestor,
single_file_support = true,
filetypes = {},

View File

@ -1,15 +1,8 @@
local util = require 'lspconfig.util'
local bin_name = 'docker-langserver'
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,
cmd = { 'docker-langserver', '--stdio' },
filetypes = { 'dockerfile' },
root_dir = util.root_pattern 'Dockerfile',
single_file_support = true,

View File

@ -1,15 +1,8 @@
local util = require 'lspconfig.util'
local bin_name = 'dot-language-server'
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,
cmd = { 'dot-language-server', '--stdio' },
filetypes = { 'dot' },
root_dir = util.find_git_ancestor,
single_file_support = true,

View File

@ -4,7 +4,9 @@ return {
default_config = {
cmd = { 'efm-langserver' },
root_dir = util.find_git_ancestor,
single_file_support = true,
-- EFM does not support NULL root directories
-- https://github.com/neovim/nvim-lspconfig/issues/1412
single_file_support = false,
},
docs = {
@ -13,17 +15,6 @@ https://github.com/mattn/efm-langserver
General purpose Language Server that can use specified error message format generated from specified command.
Requires at minimum EFM version [v0.0.38](https://github.com/mattn/efm-langserver/releases/tag/v0.0.38) to support
launching the language server on single files. If on an older version of EFM, disable single file support:
```lua
require('lspconfig')['efm'].setup{
settings = ..., -- You must populate this according to the EFM readme
filetypes = ..., -- Populate this according to the note below
single_file_support = false, -- This is the important line for supporting older version of EFM
}
```
Note: In order for neovim's built-in language server client to send the appropriate `languageId` to EFM, **you must
specify `filetypes` in your call to `setup{}`**. Otherwise `lspconfig` will launch EFM on the `BufEnter` instead
of the `FileType` autocommand, and the `filetype` variable used to populate the `languageId` will not yet be set.

View File

@ -2,12 +2,13 @@ local util = require 'lspconfig.util'
return {
default_config = {
filetypes = { 'elixir', 'eelixir', 'heex' },
filetypes = { 'elixir', 'eelixir' },
root_dir = function(fname)
return util.root_pattern('mix.exs', '.git')(fname) or vim.loop.os_homedir()
end,
},
docs = {
package_json = 'https://raw.githubusercontent.com/elixir-lsp/vscode-elixir-ls/master/package.json',
description = [[
https://github.com/elixir-lsp/elixir-ls

View File

@ -3,11 +3,6 @@ local lsp = vim.lsp
local api = vim.api
local bin_name = 'elm-language-server'
local cmd = { bin_name }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name }
end
local default_capabilities = lsp.protocol.make_client_capabilities()
default_capabilities.offsetEncoding = { 'utf-8', 'utf-16' }
@ -15,7 +10,7 @@ local elm_root_pattern = util.root_pattern 'elm.json'
return {
default_config = {
cmd = cmd,
cmd = { bin_name },
-- TODO(ashkan) if we comment this out, it will allow elmls to operate on elm.json. It seems like it could do that, but no other editor allows it right now.
filetypes = { 'elm' },
root_dir = function(fname)
@ -25,10 +20,14 @@ return {
end
end,
init_options = {
elmPath = 'elm',
elmFormatPath = 'elm-format',
elmTestPath = 'elm-test',
elmAnalyseTrigger = 'change',
},
},
docs = {
package_json = 'https://raw.githubusercontent.com/elm-tooling/elm-language-client-vscode/master/package.json',
description = [[
https://github.com/elm-tooling/elm-language-server#installation

View File

@ -1,15 +1,8 @@
local util = require 'lspconfig.util'
local bin_name = 'ember-language-server'
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,
cmd = { 'ember-language-server', '--stdio' },
filetypes = { 'handlebars', 'typescript', 'javascript' },
root_dir = util.root_pattern('ember-cli-build.js', '.git'),
},

View File

@ -1,18 +1,10 @@
local util = require 'lspconfig.util'
local bin_name = 'emmet-ls'
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 = { 'html', 'typescriptreact', 'javascriptreact', 'css', 'sass', 'scss', 'less' },
cmd = { 'emmet-ls', '--stdio' },
filetypes = { 'html', 'css' },
root_dir = util.find_git_ancestor,
single_file_support = true,
},
docs = {
description = [[
@ -25,7 +17,6 @@ npm install -g emmet-ls
]],
default_config = {
root_dir = 'git root',
single_file_support = true,
},
},
}

View File

@ -1,13 +1,8 @@
local util = require 'lspconfig.util'
local cmd = { 'erlang_ls' }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', 'erlang_ls.cmd' }
end
return {
default_config = {
cmd = cmd,
cmd = { 'erlang_ls' },
filetypes = { 'erlang' },
root_dir = util.root_pattern('rebar.config', 'erlang.mk', '.git'),
single_file_support = true,

View File

@ -49,7 +49,7 @@ require'lspconfig'.esbonio.setup {
}
```
A full list and explanation of the available options can be found [here](https://swyddfa.github.io/esbonio/docs/latest/en/lsp/getting-started.html#configuration)
A full list and explanation of the available options can be found [here](https://swyddfa.github.io/esbonio/docs/lsp/editors/index.html)
]],
},
}

View File

@ -1,10 +1,20 @@
local util = require 'lspconfig.util'
local lsp = vim.lsp
local get_eslint_client = function()
local active_clients = lsp.get_active_clients()
for _, client in ipairs(active_clients) do
if client.name == 'eslint' then
return client
end
end
return nil
end
local function fix_all(opts)
opts = opts or {}
local eslint_lsp_client = util.get_active_client_by_name(opts.bufnr, 'eslint')
local eslint_lsp_client = get_eslint_client()
if eslint_lsp_client == nil then
return
end
@ -33,15 +43,9 @@ local function fix_all(opts)
end
local bin_name = 'vscode-eslint-language-server'
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,
cmd = { bin_name, '--stdio' },
filetypes = {
'javascript',
'javascriptreact',
@ -53,7 +57,6 @@ return {
},
-- https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats
root_dir = util.root_pattern(
'.eslintrc',
'.eslintrc.js',
'.eslintrc.cjs',
'.eslintrc.yaml',
@ -98,13 +101,6 @@ return {
uri = new_root_dir,
name = vim.fn.fnamemodify(new_root_dir, ':t'),
}
-- Support Yarn2 (PnP) projects
local pnp_cjs = util.path.join(new_root_dir, '.pnp.cjs')
local pnp_js = util.path.join(new_root_dir, '.pnp.js')
if util.path.exists(pnp_cjs) or util.path.exists(pnp_js) then
config.cmd = vim.list_extend({ 'yarn', 'exec' }, cmd)
end
end,
handlers = {
['eslint/openDoc'] = function(_, result)
@ -114,8 +110,6 @@ return {
local sysname = vim.loop.os_uname().sysname
if sysname:match 'Windows' then
os.execute(string.format('start %q', result.url))
elseif sysname:match 'Linux' then
os.execute(string.format('xdg-open %q', result.url))
else
os.execute(string.format('open %q', result.url))
end
@ -149,23 +143,22 @@ return {
description = [[
https://github.com/hrsh7th/vscode-langservers-extracted
`vscode-eslint-language-server` is a linting engine for JavaScript / Typescript.
It can be installed via `npm`:
vscode-eslint-language-server: A linting engine for JavaScript / Typescript
`vscode-eslint-language-server` can be installed via `npm`:
```sh
npm i -g vscode-langservers-extracted
```
`vscode-eslint-language-server` provides an `EslintFixAll` command that can be used to format a document on save:
vscode-eslint-language-server provides an EslintFixAll command that can be used to format document on save
```vim
autocmd BufWritePre *.tsx,*.ts,*.jsx,*.js EslintFixAll
autocmd BufWritePre <buffer> <cmd>EslintFixAll<CR>
```
See [vscode-eslint](https://github.com/microsoft/vscode-eslint/blob/55871979d7af184bf09af491b6ea35ebd56822cf/server/src/eslintServer.ts#L216-L229) for configuration options.
Messages handled in lspconfig: `eslint/openDoc`, `eslint/confirmESLintExecution`, `eslint/probeFailed`, `eslint/noLibrary`
Additional messages you can handle: `eslint/noConfig`
Additional messages you can handle: eslint/noConfig
Messages already handled in lspconfig: eslint/openDoc, eslint/confirmESLintExecution, eslint/probeFailed, eslint/noLibrary
]],
},
}

View File

@ -7,6 +7,7 @@ return {
root_dir = util.root_pattern '.flowconfig',
},
docs = {
package_json = 'https://raw.githubusercontent.com/flowtype/flow-for-vscode/master/package.json',
description = [[
https://flow.org/
https://github.com/facebook/flow

View File

@ -5,7 +5,6 @@ return {
cmd = { 'flux-lsp' },
filetypes = { 'flux' },
root_dir = util.find_git_ancestor,
single_file_support = true,
},
docs = {
description = [[

View File

@ -1,31 +0,0 @@
local util = require 'lspconfig.util'
local bin_name = 'foam-ls'
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 = { 'foam', 'OpenFOAM' },
root_dir = function(fname)
return util.search_ancestors(fname, function(path)
if util.path.exists(util.path.join(path, 'system', 'controlDict')) then
return path
end
end)
end,
},
docs = {
description = [[
https://github.com/FoamScience/foam-language-server
`foam-language-server` can be installed via `npm`
```sh
npm install -g foam-language-server
```
]],
},
}

View File

@ -2,32 +2,21 @@ local util = require 'lspconfig.util'
return {
default_config = {
cmd = {
'fortls',
'--notify_init',
'--hover_signature',
'--hover_language=fortran',
'--use_signature_help',
},
cmd = { 'fortls' },
filetypes = { 'fortran' },
root_dir = function(fname)
return util.root_pattern '.fortls'(fname) or util.find_git_ancestor(fname)
end,
settings = {},
settings = {
nthreads = 1,
},
},
docs = {
package_json = 'https://raw.githubusercontent.com/hansec/vscode-fortran-ls/master/package.json',
description = [[
https://github.com/gnikit/fortls
https://github.com/hansec/fortran-language-server
fortls is a Fortran Language Server, the server can be installed via pip
```sh
pip install fortls
```
Settings to the server can be passed either through the `cmd` option or through
a local configuration file e.g. `.fortls`. For more information
see the `fortls` [documentation](https://gnikit.github.io/fortls/options.html).
Fortran Language Server for the Language Server Protocol
]],
default_config = {
root_dir = [[root_pattern(".fortls")]],

View File

@ -1,22 +0,0 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'ghdl-ls' },
filetypes = { 'vhdl' },
root_dir = function(fname)
return util.root_pattern 'hdl-prj.json'(fname) or util.find_git_ancestor(fname)
end,
single_file_support = true,
},
docs = {
description = [[
https://github.com/ghdl/ghdl-language-server
A language server for VHDL, using ghdl as its backend.
`ghdl-ls` is part of pyghdl, for installation instructions see
[the upstream README](https://github.com/ghdl/ghdl/tree/master/pyGHDL/lsp).
]],
},
}

View File

@ -1,66 +0,0 @@
local util = require 'lspconfig.util'
local bin_name = 'glint-language-server'
local cmd = { bin_name }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name }
end
return {
default_config = {
cmd = cmd,
on_new_config = function(config, new_root_dir)
local project_root = util.find_node_modules_ancestor(new_root_dir)
-- Glint should not be installed globally.
local node_bin_path = util.path.join(project_root, 'node_modules', '.bin')
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
end,
filetypes = {
'html.handlebars',
'handlebars',
'typescript',
'typescript.glimmer',
'javascript',
'javascript.glimmer',
},
root_dir = util.root_pattern(
'.glintrc.yml',
'.glintrc',
'.glintrc.json',
'.glintrc.js',
'glint.config.js',
'package.json'
),
},
docs = {
description = [[
https://github.com/typed-ember/glint
https://typed-ember.gitbook.io/glint/
`glint-language-server` is installed when adding `@glint/core` to your project's devDependencies:
```sh
npm install @glint/core --save-dev
```
or
```sh
yarn add -D @glint/core
```
or
```sh
pnpm add -D @glint/core
```
]],
},
}

View File

@ -1,28 +0,0 @@
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

@ -5,10 +5,10 @@ return {
cmd = { 'golangci-lint-langserver' },
filetypes = { 'go', 'gomod' },
init_options = {
command = { 'golangci-lint', 'run', '--out-format', 'json' },
command = { 'golangci-lint', 'run', '--enable-all', '--disable', 'lll', '--out-format', 'json' },
},
root_dir = function(fname)
return util.root_pattern 'go.work'(fname) or util.root_pattern('go.mod', '.golangci.yaml', '.git')(fname)
return util.root_pattern 'go.work'(fname) or util.root_pattern('go.mod', '.git')(fname)
end,
},
docs = {
@ -28,7 +28,7 @@ go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.42.1
]],
default_config = {
root_dir = [[root_pattern('go.work') or root_pattern('go.mod', '.golangci.yaml', '.git')]],
root_dir = [[root_pattern('go.mod', '.git')]],
},
},
}

View File

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

View File

@ -1,48 +0,0 @@
local util = require 'lspconfig.util'
local bin_name = 'gradle-language-server'
if vim.fn.has 'win32' == 1 then
bin_name = bin_name .. '.bat'
end
local root_files = {
'settings.gradle', -- Gradle (multi-project)
}
local fallback_root_files = {
'build.gradle', -- Gradle
}
return {
default_config = {
filetypes = { 'groovy' },
root_dir = function(fname)
return util.root_pattern(unpack(root_files))(fname) or util.root_pattern(unpack(fallback_root_files))(fname)
end,
cmd = { bin_name },
-- gradle-language-server expects init_options.settings to be defined
init_options = {
settings = {
gradleWrapperEnabled = true,
},
},
},
docs = {
description = [[
https://github.com/microsoft/vscode-gradle
Microsoft's lsp server for gradle files
If you're setting this up manually, build vscode-gradle using `./gradlew installDist` and point `cmd` to the `gradle-language-server` generated in the build directory
]],
default_config = {
root_dir = [[root_pattern("settings.gradle")]],
cmd = { 'gradle-language-server' },
init_options = {
settings = {
gradleWrapperEnabled = true,
},
},
},
},
}

View File

@ -1,38 +0,0 @@
local util = require 'lspconfig.util'
local bin_name = 'grammarly-languageserver'
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 = { 'markdown' },
root_dir = util.find_git_ancestor,
single_file_support = true,
handlers = {
['$/updateDocumentState'] = function()
return ''
end,
},
},
docs = {
description = [[
https://github.com/znck/grammarly
`grammarly-languageserver` can be installed via `npm`:
```sh
npm i -g grammarly-languageserver
```
WARNING: Since this language server uses Grammarly's API, any document you open with it running is shared with them. Please evaluate their [privacy policy](https://www.grammarly.com/privacy-policy) before using this.
]],
default_config = {
root_dir = [[util.find_git_ancestor]],
},
},
}

View File

@ -1,16 +1,9 @@
local util = require 'lspconfig.util'
local bin_name = 'graphql-lsp'
local cmd = { bin_name, 'server', '-m', 'stream' }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, 'server', '-m', 'stream' }
end
return {
default_config = {
cmd = cmd,
filetypes = { 'graphql', 'typescriptreact', 'javascriptreact' },
cmd = { 'graphql-lsp', 'server', '-m', 'stream' },
filetypes = { 'graphql' },
root_dir = util.root_pattern('.git', '.graphqlrc*', '.graphql.config.*', 'graphql.config.*'),
},
@ -23,11 +16,9 @@ https://github.com/graphql/graphiql/tree/main/packages/graphql-language-service-
```sh
npm install -g graphql-language-service-cli
```
Note that you must also have [the graphql package](https://github.com/graphql/graphql-js) installed and create a [GraphQL config file](https://www.graphql-config.com/docs/user/user-introduction).
]],
default_config = {
root_dir = [[util.root_pattern('.git', '.graphqlrc*', '.graphql.config.*', 'graphql.config.*')]],
root_dir = [[root_pattern('.git', '.graphqlrc*', '.graphql.config.*')]],
},
},
}

View File

@ -1,20 +0,0 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'hdl_checker', '--lsp' },
filetypes = { 'vhdl', 'verilog', 'systemverilog' },
root_dir = util.find_git_ancestor,
single_file_support = true,
},
docs = {
description = [[
https://github.com/suoto/hdl_checker
Language server for hdl-checker.
Install using: `pip install hdl-checker --upgrade`
]],
default_config = {
root_dir = [[util.find_git_ancestor]],
},
},
}

View File

@ -1,21 +0,0 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'hh_client', 'lsp' },
filetypes = { 'php', 'hack' },
root_dir = util.root_pattern '.hhconfig',
},
docs = {
description = [[
Language server for programs written in Hack
https://hhvm.com/
https://github.com/facebook/hhvm
See below for how to setup HHVM & typechecker:
https://docs.hhvm.com/hhvm/getting-started/getting-started
]],
default_config = {
root_dir = [[root_pattern(".hhconfig")]],
},
},
}

View File

@ -8,6 +8,7 @@ return {
},
docs = {
package_json = 'https://raw.githubusercontent.com/alanz/vscode-hie-server/master/package.json',
description = [[
https://github.com/haskell/haskell-ide-engine

View File

@ -4,13 +4,7 @@ return {
default_config = {
cmd = { 'haskell-language-server-wrapper', '--lsp' },
filetypes = { 'haskell', 'lhaskell' },
root_dir = function(filepath)
return (
util.root_pattern('hie.yaml', 'stack.yaml', 'cabal.project')(filepath)
or util.root_pattern('*.cabal', 'package.yaml')(filepath)
)
end,
single_file_support = true,
root_dir = util.root_pattern('*.cabal', 'stack.yaml', 'cabal.project', 'package.yaml', 'hie.yaml'),
settings = {
haskell = {
formattingProvider = 'ormolu',
@ -39,17 +33,10 @@ return {
https://github.com/haskell/haskell-language-server
Haskell Language Server
]],
]],
default_config = {
root_dir = [[
function (filepath)
return (
util.root_pattern('hie.yaml', 'stack.yaml', 'cabal.project')(filepath)
or util.root_pattern('*.cabal', 'package.yaml')(filepath)
)
end
]],
root_dir = [[root_pattern("*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml")]],
},
},
}

View File

@ -1,29 +0,0 @@
local util = require 'lspconfig.util'
local bin_name = 'hoon-language-server'
local cmd = { bin_name }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name }
end
return {
default_config = {
cmd = cmd,
filetypes = { 'hoon' },
root_dir = util.find_git_ancestor,
single_file_support = true,
},
docs = {
description = [[
https://github.com/urbit/hoon-language-server
A language server for Hoon.
The language server can be installed via `npm install -g @hoon-language-server`
Start a fake ~zod with `urbit -F zod`.
Start the language server at the Urbit Dojo prompt with: `|start %language-server`
]],
},
}

View File

@ -1,21 +1,15 @@
local util = require 'lspconfig.util'
local bin_name = 'vscode-html-language-server'
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,
cmd = { bin_name, '--stdio' },
filetypes = { 'html' },
root_dir = util.root_pattern('package.json', '.git'),
single_file_support = true,
settings = {},
init_options = {
provideFormatter = true,
embeddedLanguages = { css = true, javascript = true },
configurationSection = { 'html', 'css', 'javascript' },
},
@ -32,8 +26,6 @@ npm i -g vscode-langservers-extracted
Neovim does not currently include built-in snippets. `vscode-html-language-server` only provides completions when snippet support is enabled.
To enable completion, install a snippet plugin and add the following override to your language client capabilities during setup.
The code-formatting feature of the lsp can be controlled with the `provideFormatter` option.
```lua
--Enable (broadcasting) snippet capability for completion
local capabilities = vim.lsp.protocol.make_client_capabilities()

View File

@ -1,15 +1,8 @@
local util = require 'lspconfig.util'
local bin_name = 'intelephense'
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,
cmd = { 'intelephense', '--stdio' },
filetypes = { 'php' },
root_dir = function(pattern)
local cwd = vim.loop.cwd()
@ -29,6 +22,7 @@ npm install -g intelephense
```
]],
default_config = {
package_json = 'https://raw.githubusercontent.com/bmewburn/vscode-intelephense/master/package.json',
root_dir = [[root_pattern("composer.json", ".git")]],
init_options = [[{
storagePath = Optional absolute path to storage dir. Defaults to os.tmpdir().

View File

@ -7,6 +7,7 @@ return {
settings = {},
},
docs = {
package_json = 'https://raw.githubusercontent.com/georgewfraser/java-language-server/master/package.json',
description = [[
https://github.com/georgewfraser/java-language-server

View File

@ -1,35 +1,38 @@
local util = require 'lspconfig.util'
local handlers = require 'vim.lsp.handlers'
local sysname = vim.loop.os_uname().sysname
local env = {
HOME = vim.loop.os_homedir(),
XDG_CACHE_HOME = os.getenv 'XDG_CACHE_HOME',
JDTLS_JVM_ARGS = os.getenv 'JDTLS_JVM_ARGS',
JAVA_HOME = os.getenv 'JAVA_HOME',
JDTLS_HOME = os.getenv 'JDTLS_HOME',
WORKSPACE = os.getenv 'WORKSPACE',
}
local function get_cache_dir()
return env.XDG_CACHE_HOME and env.XDG_CACHE_HOME or util.path.join(env.HOME, '.cache')
local function get_java_executable()
local executable = env.JAVA_HOME and util.path.join(env.JAVA_HOME, 'bin', 'java') or 'java'
return sysname:match 'Windows' and executable .. '.exe' or executable
end
local function get_jdtls_cache_dir()
return util.path.join(get_cache_dir(), 'jdtls')
local function get_workspace_dir()
return env.WORKSPACE and env.WORKSPACE or util.path.join(env.HOME, 'workspace')
end
local function get_jdtls_config_dir()
return util.path.join(get_jdtls_cache_dir(), 'config')
local function get_jdtls_jar()
return vim.fn.expand '$JDTLS_HOME/plugins/org.eclipse.equinox.launcher_*.jar'
end
local function get_jdtls_workspace_dir()
return util.path.join(get_jdtls_cache_dir(), 'workspace')
end
local function get_jdtls_jvm_args()
local args = {}
for a in string.gmatch((env.JDTLS_JVM_ARGS or ''), '%S+') do
local arg = string.format('--jvm-arg=%s', a)
table.insert(args, arg)
local function get_jdtls_config()
if sysname:match 'Linux' then
return util.path.join(env.JDTLS_HOME, 'config_linux')
elseif sysname:match 'Darwin' then
return util.path.join(env.JDTLS_HOME, 'config_mac')
elseif sysname:match 'Windows' then
return util.path.join(env.JDTLS_HOME, 'config_win')
else
return util.path.join(env.JDTLS_HOME, 'config_linux')
end
return unpack(args)
end
-- TextDocument version is reported as 0, override with nil so that
@ -47,6 +50,15 @@ local function fix_zero_version(workspace_edit)
return workspace_edit
end
-- Compatibility shim added for breaking changes to the lsp handler signature in nvim-0.5.1
local function remap_arguments(err, result, ctx)
if vim.fn.has 'nvim-0.5.1' == 1 then
handlers[ctx.method](err, result, ctx)
else
handlers[ctx.method](err, ctx.method, result)
end
end
local function on_textdocument_codeaction(err, actions, ctx)
for _, action in ipairs(actions) do
-- TODO: (steelsojka) Handle more than one edit?
@ -57,15 +69,15 @@ local function on_textdocument_codeaction(err, actions, ctx)
end
end
handlers[ctx.method](err, actions, ctx)
remap_arguments(err, actions, ctx)
end
local function on_textdocument_rename(err, workspace_edit, ctx)
handlers[ctx.method](err, fix_zero_version(workspace_edit), ctx)
remap_arguments(err, fix_zero_version(workspace_edit), ctx)
end
local function on_workspace_applyedit(err, workspace_edit, ctx)
handlers[ctx.method](err, fix_zero_version(workspace_edit), ctx)
remap_arguments(err, fix_zero_version(workspace_edit), ctx)
end
-- Non-standard notification that can be used to display progress
@ -91,12 +103,25 @@ local root_files = {
return {
default_config = {
cmd = {
'jdtls',
get_java_executable(),
'-Declipse.application=org.eclipse.jdt.ls.core.id1',
'-Dosgi.bundles.defaultStartLevel=4',
'-Declipse.product=org.eclipse.jdt.ls.core.product',
'-Dlog.protocol=true',
'-Dlog.level=ALL',
'-Xms1g',
'-Xmx2G',
'--add-modules=ALL-SYSTEM',
'--add-opens',
'java.base/java.util=ALL-UNNAMED',
'--add-opens',
'java.base/java.lang=ALL-UNNAMED',
'-jar',
get_jdtls_jar(),
'-configuration',
get_jdtls_config_dir(),
get_jdtls_config(),
'-data',
get_jdtls_workspace_dir(),
get_jdtls_jvm_args(),
get_workspace_dir(),
},
filetypes = { 'java' },
root_dir = function(fname)
@ -109,20 +134,21 @@ return {
end,
single_file_support = true,
init_options = {
workspace = get_jdtls_workspace_dir(),
workspace = get_workspace_dir(),
jvm_args = {},
os_config = nil,
},
handlers = {
-- Due to an invalid protocol implementation in the jdtls we have to conform these to be spec compliant.
-- https://github.com/eclipse/eclipse.jdt.ls/issues/376
['textDocument/codeAction'] = on_textdocument_codeaction,
['textDocument/rename'] = on_textdocument_rename,
['workspace/applyEdit'] = on_workspace_applyedit,
['language/status'] = vim.schedule_wrap(on_language_status),
['textDocument/codeAction'] = util.compat_handler(on_textdocument_codeaction),
['textDocument/rename'] = util.compat_handler(on_textdocument_rename),
['workspace/applyEdit'] = util.compat_handler(on_workspace_applyedit),
['language/status'] = util.compat_handler(vim.schedule_wrap(on_language_status)),
},
},
docs = {
package_json = 'https://raw.githubusercontent.com/redhat-developer/vscode-java/master/package.json',
description = [[
https://projects.eclipse.org/projects/eclipse.jdt.ls
@ -134,21 +160,25 @@ you can keep reading here.
For manual installation you can download precompiled binaries from the
[official downloads site](http://download.eclipse.org/jdtls/snapshots/?d)
and ensure that the `PATH` variable contains the `bin` directory of the extracted archive.
Due to the nature of java, settings cannot be inferred. Please set the following
environmental variables to match your installation. If you need per-project configuration
[direnv](https://github.com/direnv/direnv) is highly recommended.
```bash
# Mandatory:
# .bashrc
export JDTLS_HOME=/path/to/jdtls_root # Directory with the plugin and configs directories
# Optional:
export JAVA_HOME=/path/to/java_home # In case you don't have java in path or want to use a version in particular
export WORKSPACE=/path/to/workspace # Defaults to $HOME/workspace
```
```lua
-- init.lua
require'lspconfig'.jdtls.setup{}
```
You can also pass extra custom jvm arguments with the JDTLS_JVM_ARGS environment variable as a space separated list of arguments,
that will be converted to multiple --jvm-arg=<param> args when passed to the jdtls script. This will allow for example tweaking
the jvm arguments or integration with external tools like lombok:
```sh
export JDTLS_JVM_ARGS="-javaagent:$HOME/.local/share/java/lombok.jar"
```
For automatic installation you can use the following unofficial installers/launchers under your own risk:
- [jdtls-launcher](https://github.com/eruizc-dev/jdtls-launcher) (Includes lombok support by default)
```lua

View File

@ -1,16 +1,11 @@
local util = require 'lspconfig.util'
local bin_name = 'vscode-json-language-server'
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' },
cmd = { bin_name, '--stdio' },
filetypes = { 'json' },
init_options = {
provideFormatter = true,
},
@ -19,6 +14,7 @@ return {
},
docs = {
-- this language server config is in VSCode built-in package.json
package_json = 'https://raw.githubusercontent.com/microsoft/vscode/master/extensions/json-language-features/package.json',
description = [[
https://github.com/hrsh7th/vscode-langservers-extracted
@ -29,6 +25,20 @@ vscode-json-language-server, a language server for JSON and JSON schema
npm i -g vscode-langservers-extracted
```
vscode-json-language-server only provides range formatting. You can map a command that applies range formatting to the entire document:
```lua
require'lspconfig'.jsonls.setup {
commands = {
Format = {
function()
vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})
end
}
}
}
```
Neovim does not currently include built-in snippets. `vscode-json-language-server` only provides completions when snippet support is enabled. To enable completion, install a snippet plugin and add the following override to your language client capabilities during setup.
```lua

View File

@ -17,24 +17,16 @@ return {
return util.root_pattern 'jsonnetfile.json'(fname) or util.find_git_ancestor(fname)
end,
on_new_config = function(new_config, root_dir)
if not new_config.cmd_env then
new_config.cmd_env = {}
end
if not new_config.cmd_env.JSONNET_PATH then
new_config.cmd_env.JSONNET_PATH = jsonnet_path(root_dir)
end
new_config.cmd_env = {
JSONNET_PATH = jsonnet_path(root_dir),
}
end,
},
docs = {
description = [[
https://github.com/grafana/jsonnet-language-server
https://github.com/jdbaldry/jsonnet-language-server
A Language Server Protocol (LSP) server for Jsonnet.
The language server can be installed with `go`:
```sh
go install github.com/grafana/jsonnet-language-server@latest
```
]],
default_config = {
root_dir = [[root_pattern("jsonnetfile.json")]],

View File

@ -50,6 +50,7 @@ return {
single_file_support = true,
},
docs = {
package_json = 'https://raw.githubusercontent.com/julia-vscode/julia-vscode/master/package.json',
description = [[
https://github.com/julia-vscode/julia-vscode

View File

@ -31,6 +31,7 @@ return {
cmd = { bin_name },
},
docs = {
package_json = 'https://raw.githubusercontent.com/fwcd/vscode-kotlin/master/package.json',
description = [[
A kotlin language server which was developed for internal usage and
released afterwards. Maintaining is not done by the original author,

View File

@ -1,24 +1,14 @@
local util = require 'lspconfig.util'
local bin_name = 'lean-language-server'
local args = { '--stdio', '--', '-M', '4096', '-T', '100000' }
local cmd = { bin_name, unpack(args) }
if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, unpack(args) }
end
return {
default_config = {
cmd = cmd,
cmd = { 'lean-language-server', '--stdio', '--', '-M', '4096', '-T', '100000' },
filetypes = { 'lean3' },
offset_encoding = 'utf-32',
root_dir = function(fname)
fname = util.path.sanitize(fname)
-- check if inside elan stdlib
local stdlib_dir
do
local _, endpos = fname:find '/lean/library'
local _, endpos = fname:find(util.path.sep .. util.path.join('lean', 'library'))
if endpos then
stdlib_dir = fname:sub(1, endpos)
end
@ -48,7 +38,7 @@ that plugin fully handles the setup of the Lean language server,
and you shouldn't set up `lean3ls` both with it and `lspconfig`.
]],
default_config = {
root_dir = [[root_pattern("leanpkg.toml") or root_pattern(".git")]],
root_dir = [[root_pattern("leanpkg.toml") or root_pattern(".git") or path.dirname]],
},
},
}

View File

@ -2,20 +2,13 @@ local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'lake', 'serve', '--' },
cmd = { 'lean', '--server' },
filetypes = { 'lean' },
root_dir = function(fname)
-- check if inside elan stdlib
fname = util.path.sanitize(fname)
local stdlib_dir
do
local _, endpos = fname:find '/src/lean'
if endpos then
stdlib_dir = fname:sub(1, endpos)
end
end
if not stdlib_dir then
local _, endpos = fname:find '/lib/lean'
local _, endpos = fname:find(util.path.sep .. util.path.join('lib', 'lean'))
if endpos then
stdlib_dir = fname:sub(1, endpos)
end
@ -25,35 +18,6 @@ return {
or stdlib_dir
or util.find_git_ancestor(fname)
end,
options = {
-- Only Lake 3.0+ supports lake serve, so for old enough Lean 4,
-- or core Lean itself, this command (typically using the in-built
-- Lean 4 language server) will be used instead.
no_lake_lsp_cmd = { 'lean', '--server' },
},
on_new_config = function(config, root_dir)
local use_lake_serve = false
if util.path.exists(util.path.join(root_dir, 'lakefile.lean')) then
local lake_version = ''
local lake_job = vim.fn.jobstart({ 'lake', '--version' }, {
on_stdout = function(_, d, _)
lake_version = table.concat(d, '\n')
end,
stdout_buffered = true,
})
if lake_job > 0 and vim.fn.jobwait({ lake_job })[1] == 0 then
local major = lake_version:match 'Lake version (%d).'
if major and tonumber(major) >= 3 then
use_lake_serve = true
end
end
end
if not use_lake_serve then
config.cmd = config.options.no_lake_lsp_cmd
end
-- add root dir as command-line argument for `ps aux`
table.insert(config.cmd, root_dir)
end,
single_file_support = true,
},
docs = {

View File

@ -2,8 +2,7 @@ local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'lemminx' },
filetypes = { 'xml', 'xsd', 'xsl', 'xslt', 'svg' },
filetypes = { 'xml', 'xsd', 'svg' },
root_dir = util.find_git_ancestor,
single_file_support = true,
},
@ -11,9 +10,18 @@ return {
description = [[
https://github.com/eclipse/lemminx
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.
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.
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.
**By default, lemminx doesn't have a `cmd` set.** This is because nvim-lspconfig does not make assumptions about your path. You must add the following to your init.vim or init.lua to set `cmd` to the absolute path ($HOME and ~ are not expanded) of your unzipped lemminx.
```lua
require'lspconfig'.lemminx.setup{
cmd = { "/path/to/lemminx/lemminx" };
...
}
```
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.
]],
default_config = {

View File

@ -9,17 +9,11 @@ local language_id_mapping = {
xhtml = 'xhtml',
}
local bin_name = 'ltex-ls'
if vim.fn.has 'win32' == 1 then
bin_name = bin_name .. '.bat'
end
return {
default_config = {
cmd = { bin_name },
filetypes = { 'bib', 'gitcommit', 'markdown', 'org', 'plaintex', 'rst', 'rnoweb', 'tex' },
cmd = { 'ltex-ls' },
filetypes = { 'bib', 'markdown', 'org', 'plaintex', 'rst', 'rnoweb', 'tex' },
root_dir = util.find_git_ancestor,
single_file_support = true,
get_language_id = function(_, filetype)
local language_id = language_id_mapping[filetype]
if language_id then
@ -30,6 +24,7 @@ return {
end,
},
docs = {
package_json = 'https://raw.githubusercontent.com/valentjn/vscode-ltex/develop/package.json',
description = [=[
https://github.com/valentjn/ltex-ls

View File

@ -1,27 +0,0 @@
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

@ -1,36 +0,0 @@
local util = require 'lspconfig.util'
local bin_name = 'm68k-lsp-server'
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 = { 'asm68k' },
root_dir = util.root_pattern('Makefile', '.git'),
single_file_support = true,
},
docs = {
description = [[
https://github.com/grahambates/m68k-lsp
Language server for Motorola 68000 family assembly
`m68k-lsp-server` can be installed via `npm`:
```sh
npm install -g m68k-lsp-server
```
Ensure you are using the 68k asm syntax variant in Neovim.
```lua
vim.g.asmsyntax = 'asm68k'
```
]],
},
}

View File

@ -1,29 +0,0 @@
local util = require 'lspconfig.util'
local bin_name = 'marksman'
local cmd = { bin_name, 'server' }
return {
default_config = {
cmd = cmd,
filetypes = { 'markdown' },
root_dir = function(fname)
local root_files = { '.marksman.toml' }
return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname)
end,
},
docs = {
description = [[
https://github.com/artempyanykh/marksman
Marksman is a Markdown LSP server providing completion, cross-references, diagnostics, and more.
Marksman works on MacOS, Linux, and Windows and is distributed as a self-contained binary for each OS.
Pre-built binaries can be downloaded from https://github.com/artempyanykh/marksman/releases
]],
default_config = {
root_dir = [[root_pattern(".git", ".marksman.toml")]],
},
},
}

View File

@ -13,11 +13,6 @@ return {
snippetAutoIndent = false,
},
},
capabilities = {
workspace = {
configuration = false,
},
},
},
docs = {
description = [[
@ -27,11 +22,21 @@ Scala language server with rich IDE features.
See full instructions in the Metals documentation:
https://scalameta.org/metals/docs/editors/vim#using-an-alternative-lsp-client
https://scalameta.org/metals/docs/editors/vim.html#using-an-alternative-lsp-client
Note: that if you're using [nvim-metals](https://github.com/scalameta/nvim-metals), that plugin fully handles the setup and installation of Metals, and you shouldn't set up Metals both with it and `lspconfig`.
To install Metals, make sure to have [coursier](https://get-coursier.io/docs/cli-installation) installed, and once you do you can install the latest Metals with `cs install metals`.
To install Metals, make sure to have [coursier](https://get-coursier.io/docs/cli-installation) installed, and once you do you can install the latest Metals with `cs install metals`. You can also manually bootstrap Metals with the following command.
```bash
cs bootstrap \
--java-opt -Xss4m \
--java-opt -Xms100m \
org.scalameta:metals_2.12:<enter-version-here> \
-r bintray:scalacenter/releases \
-r sonatype:snapshots \
-o /usr/local/bin/metals -f
```
]],
default_config = {
root_dir = [[util.root_pattern("build.sbt", "build.sc", "build.gradle", "pom.xml")]],

View File

@ -1,19 +0,0 @@
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

@ -1,20 +0,0 @@
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

@ -1,20 +0,0 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'mm0-rs', 'server' },
root_dir = util.find_git_ancestor,
filetypes = { 'metamath-zero' },
single_file_support = true,
},
docs = {
description = [[
https://github.com/digama0/mm0
Language Server for the metamath-zero theorem prover.
Requires [mm0-rs](https://github.com/digama0/mm0/tree/master/mm0-rs) to be installed
and available on the `PATH`.
]],
},
}

View File

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

View File

@ -1,23 +0,0 @@
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")]],
},
},
}

Some files were not shown because too many files have changed in this diff Show More