Add nvim-lspconfig for Neovim

This commit is contained in:
Anthony Rose 2022-01-10 11:08:46 +00:00
parent a4ae701364
commit a93b5c270c
175 changed files with 26658 additions and 0 deletions

View file

@ -0,0 +1,3 @@
als
edn
esy

View file

@ -0,0 +1,17 @@
root = true
[*]
indent_style = space
indent_size = 2
tab_width = 8
end_of_line = lf
insert_final_newline = true
charset = utf-8
[*.lua]
indent_style = space
indent_size = 2
[{Makefile,**/Makefile,runtime/doc/*.txt}]
indent_style = tab
indent_size = 8

View file

@ -0,0 +1,77 @@
name: Bug report
description: Report a problem in nvim-lspconfig
labels: [bug]
body:
- type: markdown
attributes:
value: |
Before reporting: search existing issues and ensure you are running the latest nightly of neovim and the latest version of nvim-lspconfig. Note that this repository implements configuration and initialization of language servers. Implementation of the language server spec itself is located in the neovim core repository.
- type: textarea
attributes:
label: "Description"
description: "A short description of the problem you are reporting."
validations:
required: true
- type: textarea
attributes:
label: "Neovim version"
description: "Output of `nvim --version`"
placeholder: |
NVIM v0.6.0-dev+209-g0603eba6e
Build type: Release
LuaJIT 2.1.0-beta3
validations:
required: true
- type: input
attributes:
label: "Nvim-lspconfig version"
description: "Commit hash"
placeholder: 1344a859864d4e6d23d3f3adf56d49e6386ec0d2
- type: input
attributes:
label: "Operating system and version"
placeholder: "macOS 11.5"
validations:
required: true
- type: input
attributes:
label: "Affected language servers"
description: "If this issue is specific to one or more language servers, list them here. If not, write 'all'."
placeholder: "clangd"
validations:
required: true
- type: textarea
attributes:
label: "Steps to reproduce"
description: "Steps to reproduce using the minimal config provided below."
placeholder: |
1. `nvim -nu minimal.lua`
2. ...
validations:
required: true
- type: textarea
attributes:
label: "Actual behavior"
description: "Observed behavior."
validations:
required: true
- type: textarea
attributes:
label: "Expected behavior"
description: "A description of the behavior you expected."
- type: textarea
attributes:
label: "Minimal config"
render: Lua
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: input
attributes:
label: "LSP log"
description: "If not using the `minimal_init.lua`, add `vim.lsp.set_log_level('debug')` to your LSP setup, upload the log file at `$HOME/.cache/nvim/lsp.log` to https://gist.github.com, and paste the link here."
validations:
required: true

View file

@ -0,0 +1,6 @@
blank_issues_enabled: false
contact_links:
- name: Question
url: https://neovim.discourse.group/c/language-server-protocol-lsp/7
about: Usage questions and support requests are answered in the Neovim Discourse

View file

@ -0,0 +1,24 @@
name: Feature request
description: Request a feature in nvim-lspconfig
labels: [enhancement]
body:
- type: markdown
attributes:
value: |
Before requesting a new feature, search existing issues. Implementation of the language server protocol itself is located in the neovim core repository, and general feature requests may be better suited for core.
- type: input
attributes:
label: "Language server"
description: "Is the feature specific to a language server? If so, which one(s)?"
placeholder: "clangd"
- type: textarea
attributes:
label: "Requested feature"
validations:
required: true
- type: input
attributes:
label: "Other clients which have this feature"
description: "Is the feature already implemented in another LSP client for (Neo)Vim? If so, which one(s)?"
placeholder: "vim-lsp"

View file

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

@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e
REF_BRANCH="$1"
PR_BRANCH="$2"
# checks for added lines that contain search pattern and prints them
SEARCH_PATTERN="(dirname|fn\.cwd)"
if git diff --pickaxe-all -U0 -G "${SEARCH_PATTERN}" "${REF_BRANCH}" "${PR_BRANCH}" -- '*.lua' | grep -Ev '(configs|utils)\.lua$' | grep -E "^\+.*${SEARCH_PATTERN}" ; then
echo
echo 'String "dirname" found. There is a high risk that this might contradict the directive:'
echo '"Do not add vim.fn.cwd or util.path.dirname in root_dir".'
echo "see: https://github.com/neovim/nvim-lspconfig/blob/master/CONTRIBUTING.md#adding-a-server-to-lspconfig."
exit 1
fi

View file

@ -0,0 +1,21 @@
name: "Close changes to config"
on: [pull_request_target]
jobs:
close-changes:
runs-on: ubuntu-latest
permissions:
pull-requests: write
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- run: |
if ! git diff origin/$GITHUB_BASE_REF...$(git branch --show-current) --exit-code -- doc/server_configurations.md doc/server_configurations.txt; then
gh pr close $PR_NUMBER
gh pr comment $PR_NUMBER --body "This pull request has been automatically closed. Changes to server_configurations.md aren't allowed - edit the lua source file instead. Consult https://github.com/neovim/nvim-lspconfig/blob/master/CONTRIBUTING.md#generating-docs."
exit 1
fi

View file

@ -0,0 +1,21 @@
name: codespell
on: [pull_request]
jobs:
codespell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
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 || exit

View file

@ -0,0 +1,12 @@
on: [pull_request]
jobs:
lint-commits:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: npm install --save-dev @commitlint/{cli,config-conventional}
- run: |
echo "module.exports = { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
- run: npx commitlint --from HEAD~1 --to HEAD --verbose

View file

@ -0,0 +1,32 @@
name: docgen
on:
push:
branches:
- master
jobs:
docgen:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: nightly
- name: Run docgen
run: |
scripts/docgen.sh
- name: Commit changes
env:
COMMIT_MSG: |
docs: update server_configurations.md
skip-checks: true
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add doc/server_configurations.md doc/server_configurations.txt
# Only commit and push if we have changes
git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git push)

View file

@ -0,0 +1,28 @@
name: Close Non-Feature Branches
on:
pull_request_target:
branches:
- master
jobs:
close-master-branch:
runs-on: ubuntu-latest
permissions:
pull-requests: write
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Close if master branch
if: ${{ github.head_ref == 'master' }}
run: |
gh pr close $PR_NUMBER
gh pr comment $PR_NUMBER --body "This pull request has been automatically closed. Please develop on a feature branch. Thank you."
exit 1

View file

@ -0,0 +1,54 @@
name: lint
on:
pull_request:
branches:
- master
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
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
run: luacheck lua/* test/*
- name: Run selene
run: selene --display-style=quiet .
style-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Lint with stylua
uses: JohnnyMorganz/stylua-action@1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
# CLI arguments
args: --check .

View file

@ -0,0 +1,30 @@
{
"problemMatcher": [
{
"owner": "selene-error",
"severity": "error",
"pattern": [
{
"regexp": "^([^:]+):(\\d+):(\\d+):\\serror(.*)$",
"file": 1,
"line": 2,
"column": 3,
"message": 4
}
]
},
{
"owner": "selene-warning",
"severity": "warning",
"pattern": [
{
"regexp": "^([^:]+):(\\d+):(\\d+):\\swarning(.*)$",
"file": 1,
"line": 2,
"column": 3,
"message": 4
}
]
}
]
}

View file

@ -0,0 +1,15 @@
name: "Dirname Checker"
on: [pull_request]
jobs:
disallowed-root-checker:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: |
if ! bash .github/ci/run_sanitizer.sh ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}; then
exit 1
fi

View file

@ -0,0 +1,53 @@
name: test
on:
pull_request:
branches:
- master
jobs:
ubuntu:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Setup build dependencies
run: |
sudo apt update &&
sudo apt install -y ninja-build \
gettext \
libtool \
libtool-bin \
autoconf \
automake \
cmake \
g++ \
pkg-config \
unzip \
gperf \
libluajit-5.1-dev \
libunibilium-dev \
libmsgpack-dev \
libtermkey-dev \
libvterm-dev \
libjemalloc-dev \
lua5.1 \
lua-lpeg \
lua-mpack \
lua-bitop
- name: Run test with building Nvim
run: |
make test
macos:
runs-on: macos-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Setup build dependencies
run: |
/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
run: |
make test

View file

@ -0,0 +1,3 @@
.luacheckcache
neovim
doc/tags

View file

@ -0,0 +1,14 @@
-- vim: ft=lua tw=80
-- Rerun tests only if their modification time changed.
cache = true
ignore = {
"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
}
-- Global objects defined by the C code
read_globals = {
"vim",
}

View file

@ -0,0 +1,6 @@
column_width = 120
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferSingle"
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

@ -0,0 +1,109 @@
## Requirements
- [Neovim](https://neovim.io/) 0.6 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
## Scope of lspconfig
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.
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
```
* `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.
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.
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'
-- Having server name defined here is the convention, this is often times also the first entry in the `cmd` table.
local server_name = 'pyright'
configs[server_name] = {
default_config = {
-- 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' },
-- 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`
]],
},
}
```
## Commit style
lspconfig, like neovim core, follows the [conventional commit style](https://www.conventionalcommits.org/en/v1.0.0-beta.2/) please submit your commits accordingly. Generally commits will be of the form:
```
feat: add lua-language-server support
fix(lua-language-server): update root directory pattern
docs: update README.md
```
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:
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 (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):
nvim -R -Es +'set rtp+=$PWD' +'luafile scripts/docgen.lua'

View file

@ -0,0 +1,183 @@
Copyright Neovim contributors. All rights reserved.
nvim-lsp is licensed under the terms of the Apache 2.0 license.
nvim-lsp's license follows:
====
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View file

@ -0,0 +1,12 @@
test:
sh ./scripts/run_test.sh
lint:
@printf "\nRunning luacheck\n"
luacheck lua/* test/*
@printf "\nRunning selene\n"
selene --display-style=quiet .
@printf "\nRunning stylua\n"
stylua --check .
.PHONY: test lint

View file

@ -0,0 +1,209 @@
# lspconfig
A [collection of common configurations](doc/server_configurations.md) for Neovim's built-in [language server client](https://neovim.io/doc/user/lsp.html).
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).**
`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 v0.6.0](https://github.com/neovim/neovim/releases/tag/v0.6.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.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`.
```lua
lua << EOF
require'lspconfig'.pyright.setup{}
EOF
```
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
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>
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
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.diagnostic.open_float()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<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
EOF
```
The `on_attach` hook is used to only activate the bindings after the language server attaches to the current buffer.
## Debugging
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. '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:
```
:lua vim.cmd('e'..vim.lsp.get_log_path())
```
Most of the time, the reason for failure is present in the logs.
## 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.
## The wiki
Please see the [wiki](https://github.com/neovim/nvim-lspconfig/wiki) for additional topics, including:
* [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)
## 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 would be appreciated. You can follow these steps:
1. Read [CONTRIBUTING.md](CONTRIBUTING.md).
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/server_configurations/)
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).
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,648 @@
*lspconfig.txt* For Nvim version 0.5.1+ Last change: 2021 Nov 7
==============================================================================
TABLE OF CONTENTS *lspconfig-toc*
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*
`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
server
- a root directory resolver which attempts to detect the root of your project
- an autocommand mapping that either launches a new language server or
attempts to attach a language server to each opened buffer if it falls
under a tracked project
- utility commands such as LspInfo, LspStart, LspStop, and LspRestart for
managing language server instances
`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-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*
- ensure the server is installed and executable from the command line
- enable the server in your Neovim configuration (Lua example):
>
require'lspconfig'.clangd.setup{}
<
- create a new project, ensure that it contains a root marker which matches the
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-server-configurations|.
==============================================================================
THE SETUP METAMETHOD *lspconfig-setup*
`lspconfig` consists of a collection of language server configurations. Each
configuration exposes a `setup {}` metamethod which makes it easy to directly
use the default configuration or selectively override the defaults.
`setup {}` is the primary interface by which users interact with `lspconfig`.
Using the default configuration for a server is simple:
>
require'lspconfig'.clangd.setup{}
<
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
language server.
This autocommand calls `start_client()` or `vim.lsp.buf_attach_client()`
depending on whether the current file belongs to a project with a currently
running client. See |lspconfig-root-detection| for more details.
The `setup{}` function takes a table which contains a superset of the keys
listed in `:help vim.lsp.start_client()` with the following unique entries:
- {root_dir}
`function(filename, bufnr)`
Returns either a filepath (string) or nil. The language server will only
start if the function returns a filepath.
If a root directory (string) is returned which is unique from any
previously returned root_dir, a new server will be spawned with that
root directory. See |lspconfig-root-detection| for more details
- {name}
`string`
Defaults to the server's name (`clangd`, `pyright`, etc.).
- {filetypes}
`list[string] | nil`
Set of filetypes for which to attempt to resolve {root_dir}.
May be empty, or server may specify a default value.
- {autostart}
`bool` (default: true)
Controls if the `FileType` autocommand that launches a language server is
created. If `false`, allows for deferring language servers until manually
launched with `:LspStart` (|lspconfig-commands|).
- {single_file_support}
`bool` (default: nil)
Determines if a server is started without a matching root directory.
See |lspconfig-single-file-support|.
- {on_new_config}
`function(new_config, new_root_dir)`
Function executed after a root directory is detected. This is used to
modify the server configuration (including `cmd` itself). Most commonly,
this is used to inject additional arguments into `cmd`.
If overriding `on_new_config`, ensure that you read the
`on_new_config` defined in the source file of the default configuration
in `lspconfig`. The original `on_new_config` snippet for a given server
should likely be included in your new override. Some configurations
use `on_new_config` to dynamically set or modify `cmd`.
Note: all entries passed to `setup {}` override the entry in the default
configuration. There is no composition.
All `config` elements described in `:help vim.lsp.start_client()` can
additionally be overridden via the `setup {}` call. The most commonly
passed overrides to `setup {}` are:
- {capabilities} `table <string, string|table|bool|function>`
a table which represents the neovim client capabilities. Useful for
broadcasting to the server additional functionality (snippets, off-protocol
features) provided by plugins.
- {cmd} `list[string]`
a list where each entry corresponds to the blankspace delimited part of
the command that launches the server. The first entry is the binary used
to run the language server. Additional entries are passed as arguments.
The equivalent `cmd` for:
>
foo --bar baz
<
is:
>
{'foo', '--bar', 'baz}
<
- {handlers} `list[functions]`
a list of handlers which override the function used to process a response
from a given language server. Applied only to the server referenced by
setup. See |lsp-handler|.
- {init_options} `table <string, string|table|bool>`
a table passed during the initialization notification after launching
a language server. Equivalent to the `initializationOptions` field found
in `InitializeParams` in the LSP specification.
See upstream server documentation for available initialization
options.
- {on_attach} `function(client, bufnr)`
Callback invoked by Nvim's built-in client when attaching a buffer to a
language server. Often used to set Nvim (buffer or global) options or to
override the Nvim client properties (`resolved_capabilities`) after a
language server attaches. Most commonly used for settings buffer
local keybindings. See |lspconfig-keybindings| for a usage example.
- {settings} `table <string, string|table|bool>`
The `settings` table is sent in `on_init` via a
`workspace/didChangeConfiguration` notification from the Nvim client to
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:
`pyright.disableLanguageServices`: `boolean`
`pyright.disableOrganizeImports`: `boolean`
Nested keys need to be translated into a nested table and passed to
the settings field in `setup {}` as follows:
>
require('lspconfig').pyright.setup{
settings = {
pyright = {
disableLanguageServices = true,
disableOrganizeImports = true,
}
}
}
<
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*
The global defaults for all servers can be overridden by extending the
`default_config` table.
>
local lspconfig = require'lspconfig'
lspconfig.util.default_config = vim.tbl_extend(
"force",
lspconfig.util.default_config,
{
autostart = false,
handlers = {
["window/logMessage"] = function(err, method, params, client_id)
if params and params.type <= vim.lsp.protocol.MessageType.Log then
vim.lsp.handlers["window/logMessage"](err, method, params, client_id)
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;
}
}
)
<
`setup {}` can additionally override these defaults in subsequent calls.
==============================================================================
SERVER CONFIGURATIONS *lspconfig-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
configuration directly. This can be useful if there is an outstanding PR that
is in review, or when developing a language server that is unavailable
publicly. This can be done through the `configs` module.
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};
}
<
where the structure of the docs table is as follows:
>
docs = {
description = {'s', true};
default_config = {'t', true};
}
<
`commands` is a map of `name:definition` key:value pairs, where `definition`
is a list whose first value is a function implementing the command, and the
rest are either array values which will be formed into flags for the command,
or special keys like `description`. Example:
>
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:
>
require'lspconfig'.SERVER_NAME.setup{}
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-adding-servers*
The three steps for adding and enabling a new server configuration are:
- load the `lspconfig` module (note that this is a stylistic choice)
>
local lspconfig = require 'lspconfig'
<
- 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'};
root_dir = function(fname)
return lspconfig.util.find_git_ancestor(fname)
end;
settings = {};
};
}
end
- call `setup()` to enable the FileType autocmd
>
lspconfig.foo_lsp.setup{}
<
==============================================================================
ROOT DETECTION *lspconfig-root-detection*
*lspconfig-root-dir*
A project's `root_dir` is used by `lspconfig` to determine whether `lspconfig`
should start a new server, or attach a previous one, to the current file.
`lspconfig` automatically launches language servers by defining a filetype
autocommand based on the `filetypes` specified in the default configuration of
each server, optionally overridable by the `filetypes` table passed to
`setup`.
This autocommand triggers a search from the current file position in the
filesystem hierarchy up to the top level directory of your filesystem. The
`root_dir` entry of each configuration is a function that returns true if the
current directory in this traversal matches a given root pattern.
The following utility functions are provided by `lspconfig`. Each function call
below returns a function that takes as its argument the current buffer path.
- `util.root_pattern`: function which takes multiple arguments, each
corresponding to a different root pattern against which the contents of the
current directory are matched using |vim.fin.glob()| while traversing up the
filesystem.
>
root_dir = util.root_pattern('pyproject.toml', 'requirements.txt')
<
- `util.find_git_ancestor`: a function that locates the first parent directory
containing a `.git` directory.
>
root_dir = util.find_git_ancestor
- `util.find_node_modules_ancestor`: a function that locates the first parent
directory containing a `node_modules` directory.
>
root_dir = util.find_node_modules_ancestor
<
- `util.find_package_json_ancestor`: a function that locates the first parent
directory containing a `package.json`.
>
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*
The `root_dir` key in `config` and `setup` can hold any function of the form
>
function custom_root_dir(filename, bufnr)
returns nil | string
>
This allows for rich composition of root directory patterns which is necessary
for some project structures. Example (for Kotlin):
>
local root_files = {
'settings.gradle', -- Gradle (multi-project)
'settings.gradle.kts', -- Gradle (multi-project)
'build.xml', -- Ant
'pom.xml', -- Maven
}
local fallback_root_files = {
'build.gradle', -- Gradle
'build.gradle.kts', -- Gradle
}
root_dir = function(fname)
local primary = util.root_pattern(unpack(root_files))(fname)
local fallback = util.root_pattern(unpack(fallback_root_files))(fname)
return primary or fallback
end
<
Browsing the source of the default configurations is recommended.
==============================================================================
SINGLE FILE SUPPORT *lspconfig-single-file-support*
Language servers require each project to have a `root` in order to provide
features that require cross-file indexing.
Some servers support not passing a root directory as a proxy for single file
mode under which cross-file features may be degraded.
`lspconfig` offers limited support for an implicit single-file mode by:
- first trying to resolve the root directory pattern
- then, if `single_file_support` is enabled for a given language server
configuration, starting the server without sending `rootDirectory` or
`workspaceFolders` during initialization.
- attaching subsequent files in the parent directory to the same server
instance, depending on filetype.
Cross-file features (navigation, hover) may or may not work depending on the
language server. For a full feature-set, consider moving your files to a
directory with a project structure `lspconfig` can infer.
Note that in the event that the LSP specification is extended to support a
standard for single-file mode, lspconfig will adopt that standard.
==============================================================================
COMMANDS *lspconfig-commands*
- `:LspInfo` shows the status of active and configured language servers. Note
that client id refers to the Nvim RPC instance connected to a given
language server.
The following commands support tab-completion for all arguments. All commands
that require a client id can either leverage tab-completion or the info
contained in `:LspInfo`:
- `:LspStart <config_name>` launches the requested (configured) client, but only
if it successfully resolves a root directory. Note: Defaults to all
configured servers matching the current buffer filetype.
- `:LspStop <client_id>` stops the server with the given client id. Defaults to
stopping all servers active on the current buffer.
- `:LspRestart <client_id>` restarts the client with the given client id, and
will attempt to reattach to all previously attached buffers.
==============================================================================
EXAMPLE KEYBINDINGS *lspconfig-keybindings*
`lspconfig`, and the core client, do not map any keybindings by default. The
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.
>
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>
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
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.diagnostic.open_float()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<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 `:help omnifunc` for more details.
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*
While using language servers should be easy, debugging issues can be
challenging. First, it is important to identify the source of the issue, which
is typically (in rough order):
- the language server itself
- a plugin
- overrides in a user configuration
- the built-in client in Nvim core
- `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 `lspconfig`.
- The root directory inferred for your project is wrong, or it should be
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.
All bugs Nvim's built-in client should be reported to the Nvim core issue
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 `lspconfig` issues, the most common hurdles users face are:
- The language server is not installed or is otherwise not executable.
`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. `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
`handlers`. Ensure that you debug by using a stock configuration to ensure
your customizations are not introducing issues.
|LspInfo| provides an overview of your active and configured language servers
which can be useful for debugging.
Note that it will not report any configuration changes applied in
`on_new_config`.
==============================================================================
LOGGING *lspconfig-logging*
When debugging language servers, it is helpful to enable additional logging in
the built-in client, specifically considering the RPC logs. Example:
>
vim.lsp.set_log_level 'trace'
if vim.fn.has 'nvim-0.5.1' == 1 then
require('vim.lsp.log').set_format_func(vim.inspect)
end
<
Attempt to run the language server, and open the log with:
>
: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
via stderr.
==============================================================================
SCOPE *lspconfig-scope*
`lspconfig` is a community effort to create default configurations that fit
within the scope of an official plugin for Nvim. All features that are not
strictly providing default configurations for language servers will be removed
from `lspconfig` in time. The power of the Neovim LSP ecosystem is in the
composability and flexibility of integrating multiple plugins which maximizes
user choice and freedom.
`lspconfig` also opts to adhere strictly to the LSP specification, with some
small allowances when small modifications to a server configuration are
necessary to enable features critical to its usability. For more featureful
options, the `lspconfig` wiki lists community created plugins that build upon
the built-in client to provide functionality tailored to specific language
servers.
==============================================================================
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

@ -0,0 +1,41 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1634851050,
"narHash": "sha256-N83GlSGPJJdcqhUxSCS/WwW5pksYf3VP1M13cDRTSVA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c91f3de5adaf1de973b797ef7485e441a65b8935",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1626644568,
"narHash": "sha256-+WxW0u6AJUn/AzIxUuNKtEDxSRcUP0v/iZ/tRXhLGEc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d5bd34ebf2c2c2b380b76cb86bc68522bc6af4d7",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

View file

@ -0,0 +1,18 @@
{
description = "Quickstart configurations for the Nvim LSP client";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system}; in
rec {
devShell = pkgs.mkShell {
buildInputs = [
pkgs.stylua
pkgs.luaPackages.luacheck
];
};
}
);
}

View file

@ -0,0 +1,92 @@
local configs = require 'lspconfig.configs'
local M = {
util = require 'lspconfig.util',
}
M._root = {}
function M.available_servers()
return vim.tbl_keys(configs)
end
-- Called from plugin/lspconfig.vim because it requires knowing that the last
-- script in scriptnames to be executed is lspconfig.
function M._root._setup()
M._root.commands = {
LspInfo = {
function()
require 'lspconfig.ui.lspinfo'()
end,
'-nargs=0',
description = '`:LspInfo` Displays attached, active, and configured language servers',
},
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 = {}
function mt:__index(k)
if configs[k] == nil then
local success, config = pcall(require, 'lspconfig.server_configurations.' .. k)
if success then
configs[k] = config
else
vim.notify(
string.format(
'[lspconfig] Cannot access configuration for %s. Ensure this server is listed in '
.. '`server_configurations.md` or added as a custom server.',
k
),
vim.log.levels.WARN
)
-- Return a dummy function for compatibility with user configs
return { setup = function() end }
end
end
return configs[k]
end
return setmetatable(M, mt)

View file

@ -0,0 +1,299 @@
local util = require 'lspconfig.util'
local api, validate, lsp = vim.api, vim.validate, vim.lsp
local tbl_extend = vim.tbl_extend
local configs = {}
function configs.__newindex(t, config_name, config_def)
validate {
name = { config_name, 's' },
default_config = { config_def.default_config, 't' },
on_new_config = { config_def.on_new_config, 'f', true },
on_attach = { config_def.on_attach, 'f', true },
commands = { config_def.commands, 't', true },
}
if config_def.commands then
for k, v in pairs(config_def.commands) do
validate {
['command.name'] = { k, 's' },
['command.fn'] = { v[1], 'f' },
}
end
else
config_def.commands = {}
end
local M = {}
local default_config = tbl_extend('keep', config_def.default_config, util.default_config)
-- Force this part.
default_config.name = config_name
function M.setup(config)
validate {
cmd = { config.cmd, 't', true },
root_dir = { config.root_dir, 'f', true },
filetypes = { config.filetype, 't', true },
on_new_config = { config.on_new_config, 'f', true },
on_attach = { config.on_attach, 'f', true },
commands = { config.commands, 't', true },
}
if config.commands then
for k, v in pairs(config.commands) do
validate {
['command.name'] = { k, 's' },
['command.fn'] = { v[1], 'f' },
}
end
end
config = tbl_extend('keep', config, default_config)
if util.on_setup then
pcall(util.on_setup, config)
end
if config.autostart == true then
local event
local pattern
if config.filetypes then
event = 'FileType'
pattern = table.concat(config.filetypes, ',')
else
event = 'BufReadPost'
pattern = '*'
end
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
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)
end
if root_dir then
api.nvim_command(
string.format(
"autocmd BufReadPost %s/* unsilent lua require'lspconfig'[%q].manager.try_add_wrapper()",
vim.fn.fnameescape(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
end
end
elseif config.single_file_support then
-- This allows on_new_config to use the parent directory of the file
-- 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)
else
vim.notify(
string.format('[lspconfig] Autostart for %s failed: matching root directory not detected.', config_name)
)
end
end
-- Used by :LspInfo
M.get_root_dir = get_root_dir
M.filetypes = config.filetypes
M.handlers = config.handlers
M.cmd = config.cmd
M.autostart = config.autostart
-- In the case of a reload, close existing things.
local reload = false
if M.manager then
for _, client in ipairs(M.manager.clients()) do
client.stop(true)
end
reload = true
M.manager = nil
end
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)
end
if config.on_new_config then
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)
-- Handle offset encoding by default
if result.offsetEncoding then
client.offset_encoding = result.offsetEncoding
end
-- Send `settings to server via workspace/didChangeConfiguration
function client.workspace_did_change_configuration(settings)
if not settings then
return
end
if vim.tbl_isempty(settings) then
settings = { [vim.type_idx] = vim.types.dictionary }
end
return client.notify('workspace/didChangeConfiguration', {
settings = settings,
})
end
if not vim.tbl_isempty(new_config.settings) then
client.workspace_did_change_configuration(new_config.settings)
end
end)
-- Save the old _on_attach so that we can reference it via the BufEnter.
new_config._on_attach = new_config.on_attach
new_config.on_attach = vim.schedule_wrap(function(client, bufnr)
if bufnr == api.nvim_get_current_buf() then
M._setup_buffer(client.id, bufnr)
else
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.workspace_folders = {
{
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)
end)
function manager.try_add(bufnr)
bufnr = bufnr or api.nvim_get_current_buf()
if vim.api.nvim_buf_get_option(bufnr, 'buftype') == 'nofile' then
return
end
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)
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)
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
lsp.buf_attach_client(bufnr, id)
end
end
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')
for _, filetype in ipairs(config.filetypes) do
if buf_filetype == filetype then
manager.try_add(bufnr)
return
end
end
end
M.manager = manager
M.make_config = make_config
if reload and not (config.autostart == false) then
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
manager.try_add_wrapper(bufnr)
end
end
end
function M._setup_buffer(client_id, bufnr)
local client = lsp.get_client_by_id(client_id)
if not client then
return
end
if client.config._on_attach then
client.config._on_attach(client, bufnr)
end
if client.config.commands and not vim.tbl_isempty(client.config.commands) then
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
rawset(t, config_name, M)
return M
end
return setmetatable({}, configs)

View file

@ -0,0 +1,38 @@
local util = require 'lspconfig.util'
local bin_name = 'ada_language_server'
if vim.fn.has 'win32' == 1 then
bin_name = 'ada_language_server.exe'
end
return {
default_config = {
cmd = { bin_name },
filetypes = { 'ada' },
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
Installation instructions can be found [here](https://github.com/AdaCore/ada_language_server#Install).
Can be configured by passing a "settings" object to `als.setup{}`:
```lua
require('lspconfig').als.setup{
settings = {
ada = {
projectFile = "project.gpr";
scenarioVariables = { ... };
}
}
}
```
]],
default_config = {
root_dir = [[util.root_pattern("Makefile", ".git", "*.gpr", "*.adc")]],
},
},
}

View file

@ -0,0 +1,75 @@
local util = require 'lspconfig.util'
-- Angular requires a node_modules directory to probe for @angular/language-service and typescript
-- in order to use your projects configured versions.
-- This defaults to the vim cwd, but will get overwritten by the resolved root of the file.
local function get_probe_dir(root_dir)
local project_root = util.find_node_modules_ancestor(root_dir)
return project_root and (project_root .. '/node_modules') or ''
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,
filetypes = { 'typescript', 'html', 'typescriptreact', 'typescript.tsx' },
-- 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', '.git'),
},
on_new_config = function(new_config, new_root_dir)
local new_probe_dir = get_probe_dir(new_root_dir)
-- We need to check our probe directories because they may have changed.
new_config.cmd = {
'ngserver',
'--stdio',
'--tsProbeLocations',
new_probe_dir,
'--ngProbeLocations',
new_probe_dir,
}
end,
docs = {
description = [[
https://github.com/angular/vscode-ng-language-service
`angular-language-server` can be installed via npm `npm install -g @angular/language-server`.
Note, that if you override the default `cmd`, you must also update `on_new_config` to set `new_config.cmd` during startup.
```lua
local project_library_path = "/path/to/project/lib"
local cmd = {"ngserver", "--stdio", "--tsProbeLocations", project_library_path , "--ngProbeLocations", project_library_path}
require'lspconfig'.angularls.setup{
cmd = cmd,
on_new_config = function(new_config,new_root_dir)
new_config.cmd = cmd
end,
}
```
]],
default_config = {
root_dir = [[root_pattern("angular.json", ".git")]],
},
},
}

View file

@ -0,0 +1,46 @@
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,
settings = {
ansible = {
python = {
interpreterPath = 'python',
},
ansibleLint = {
path = 'ansible-lint',
enabled = true,
},
ansible = {
path = 'ansible',
},
executionEnvironment = {
enabled = false,
},
},
},
filetypes = { 'yaml', 'yaml.ansible' },
root_dir = util.root_pattern('ansible.cfg', '.ansible-lint'),
single_file_support = true,
},
docs = {
description = [[
https://github.com/ansible/ansible-language-server
Language server for the ansible configuration management tool.
`ansible-language-server` can be installed via `yarn`:
```sh
yarn global add ansible-language-server
```
]],
},
}

View file

@ -0,0 +1,50 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'arduino-language-server' },
filetypes = { 'arduino' },
root_dir = util.root_pattern '*.ino',
},
docs = {
description = [[
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
The `arduino-cli` tools must also be installed. Follow these instructions for your distro:
https://arduino.github.io/arduino-cli/latest/installation/
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
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.
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
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

@ -0,0 +1,34 @@
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_env = {
-- Prevent recursive scanning which will cause issues when opening a file
-- directly in the home directory (e.g. ~/foo.sh).
--
-- Default upstream pattern is "**/*@(.sh|.inc|.bash|.command)".
GLOB_PATTERN = vim.env.GLOB_PATTERN or '*@(.sh|.inc|.bash|.command)',
},
filetypes = { 'sh' },
root_dir = util.find_git_ancestor,
single_file_support = true,
},
docs = {
description = [[
https://github.com/mads-hartmann/bash-language-server
Language server for bash, written using tree sitter in typescript.
]],
default_config = {
root_dir = [[util.find_git_ancestor]],
},
},
}

View file

@ -0,0 +1,26 @@
local util = require 'lspconfig.util'
return {
default_config = {
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 = {
description = [[
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("elm.json")]],
},
},
}

View file

@ -0,0 +1,47 @@
local util = require 'lspconfig.util'
return {
default_config = {
filetypes = { 'bicep' },
root_dir = util.find_git_ancestor,
init_options = {},
},
docs = {
description = [=[
https://github.com/azure/bicep
Bicep language server
Bicep language server can be installed by downloading and extracting a release of bicep-langserver.zip from [Bicep GitHub releases](https://github.com/Azure/bicep/releases).
Bicep language server requires the [dotnet-sdk](https://dotnet.microsoft.com/download) to be installed.
Neovim does not have built-in support for the bicep filetype which is required for lspconfig to automatically launch the language server.
Filetype detection can be added via an autocmd:
```lua
vim.cmd [[ autocmd BufNewFile,BufRead *.bicep set filetype=bicep ]]
```
**By default, bicep language server does not 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 the unzipped run script or binary.
```lua
local bicep_lsp_bin = "/path/to/bicep-langserver/Bicep.LangServer.dll"
require'lspconfig'.bicep.setup{
cmd = { "dotnet", bicep_lsp_bin };
...
}
```
To download the latest release and place in /usr/local/bin/bicep-langserver:
```bash
(cd $(mktemp -d) \
&& curl -fLO https://github.com/Azure/bicep/releases/latest/download/bicep-langserver.zip \
&& rm -rf /usr/local/bin/bicep-langserver \
&& unzip -d /usr/local/bin/bicep-langserver bicep-langserver.zip)
```
]=],
default_config = {
root_dir = [[util.find_git_ancestor]],
},
},
}

View file

@ -0,0 +1,19 @@
local util = require 'lspconfig.util'
return {
default_config = {
filetypes = { 'bsl', 'os' },
root_dir = util.find_git_ancestor,
},
docs = {
description = [[
https://github.com/1c-syntax/bsl-language-server
Language Server Protocol implementation for 1C (BSL) - 1C:Enterprise 8 and OneScript languages.
]],
default_config = {
root_dir = [[root_pattern(".git")]],
},
},
}

View file

@ -0,0 +1,42 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'ccls' },
filetypes = { 'c', 'cpp', 'objc', 'objcpp' },
root_dir = util.root_pattern('compile_commands.json', '.ccls', '.git'),
-- ccls does not support sending a null root directory
single_file_support = false,
},
docs = {
description = [[
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.
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:
```lua
local lspconfig = require'lspconfig'
lspconfig.ccls.setup {
init_options = {
compilationDatabaseDirectory = "build";
index = {
threads = 0;
};
clang = {
excludeArgs = { "-frounding-math"} ;
};
}
}
```
]],
default_config = {
root_dir = [[root_pattern("compile_commands.json", ".ccls", ".git")]],
},
},
}

View file

@ -0,0 +1,73 @@
local util = require 'lspconfig.util'
-- https://clangd.llvm.org/extensions.html#switch-between-sourceheader
local function switch_source_header(bufnr)
bufnr = util.validate_bufnr(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)
else
print 'method textDocument/switchSourceHeader is not supported by any servers active on the current buffer'
end
end
local root_pattern = util.root_pattern('compile_commands.json', 'compile_flags.txt', '.git')
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' },
}
)
return {
default_config = {
cmd = { 'clangd' },
filetypes = { 'c', 'cpp', 'objc', 'objcpp' },
root_dir = function(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,
},
commands = {
ClangdSwitchSourceHeader = {
function()
switch_source_header(0)
end,
description = 'Switch between source/header',
},
},
docs = {
description = [[
https://clangd.llvm.org/installation.html
**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("compile_commands.json", "compile_flags.txt", ".git") or dirname]],
capabilities = [[default capabilities, with offsetEncoding utf-8]],
},
},
}

View file

@ -0,0 +1,19 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'clojure-lsp' },
filetypes = { 'clojure', 'edn' },
root_dir = util.root_pattern('project.clj', 'deps.edn', 'build.boot', 'shadow-cljs.edn', '.git'),
},
docs = {
description = [[
https://github.com/snoe/clojure-lsp
Clojure Language Server
]],
default_config = {
root_dir = [[root_pattern("project.clj", "deps.edn", "build.boot", "shadow-cljs.edn", ".git")]],
},
},
}

View file

@ -0,0 +1,23 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'cmake-language-server' },
filetypes = { 'cmake' },
root_dir = util.root_pattern('.git', 'compile_commands.json', 'build'),
single_file_support = true,
init_options = {
buildDirectory = 'build',
},
},
docs = {
description = [[
https://github.com/regen100/cmake-language-server
CMake LSP Implementation
]],
default_config = {
root_dir = [[root_pattern(".git", "compile_commands.json", "build") or dirname]],
},
},
}

View file

@ -0,0 +1,46 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'codeql', 'execute', 'language-server', '--check-errors', 'ON_CHANGE', '-q' },
filetypes = { 'ql' },
root_dir = util.root_pattern 'qlpack.yml',
log_level = vim.lsp.protocol.MessageType.Warning,
before_init = function(initialize_params)
initialize_params['workspaceFolders'] = {
{
name = 'workspace',
uri = initialize_params['rootUri'],
},
}
end,
settings = {
search_path = vim.empty_dict(),
},
},
docs = {
description = [[
Reference:
https://help.semmle.com/codeql/codeql-cli.html
Binaries:
https://github.com/github/codeql-cli-binaries
]],
default_config = {
settings = {
search_path = [[list containing all search paths, eg: '~/codeql-home/codeql-repo']],
},
},
},
on_new_config = function(config)
if type(config.settings.search_path) == 'table' and not vim.tbl_isempty(config.settings.search_path) then
local search_path = '--search-path='
for _, path in ipairs(config.settings.search_path) do
search_path = search_path .. vim.fn.expand(path) .. ':'
end
config.cmd = { 'codeql', 'execute', 'language-server', '--check-errors', 'ON_CHANGE', '-q', search_path }
else
config.cmd = { 'codeql', 'execute', 'language-server', '--check-errors', 'ON_CHANGE', '-q' }
end
end,
}

View file

@ -0,0 +1,20 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'crystalline' },
filetypes = { 'crystal' },
root_dir = util.root_pattern 'shard.yml' or util.find_git_ancestor,
single_file_support = true,
},
docs = {
description = [[
https://github.com/elbywan/crystalline
Crystal language server.
]],
default_config = {
root_dir = [[root_pattern('shard.yml', '.git') or dirname]],
},
},
}

View file

@ -0,0 +1,23 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'csharp-ls' },
root_dir = util.root_pattern('*.sln', '*.csproj', '.git'),
filetypes = { 'cs' },
init_options = {
AutomaticWorkspaceInit = true,
},
},
docs = {
description = [[
https://github.com/razzmatazz/csharp-language-server
Language Server for C#.
csharp-ls requires the [dotnet-sdk](https://dotnet.microsoft.com/download) to be installed.
The preferred way to install csharp-ls is with `dotnet tool install --global csharp-ls`.
]],
},
}

View file

@ -0,0 +1,49 @@
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,
filetypes = { 'css', 'scss', 'less' },
root_dir = util.root_pattern('package.json', '.git'),
single_file_support = true,
settings = {
css = { validate = true },
scss = { validate = true },
less = { validate = true },
},
},
docs = {
description = [[
https://github.com/hrsh7th/vscode-langservers-extracted
`css-languageserver` can be installed via `npm`:
```sh
npm i -g vscode-langservers-extracted
```
Neovim does not currently include built-in snippets. `vscode-css-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
--Enable (broadcasting) snippet capability for completion
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
require'lspconfig'.cssls.setup {
capabilities = capabilities,
}
```
]],
default_config = {
root_dir = [[root_pattern("package.json", ".git") or bufdir]],
},
},
}

View file

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

@ -0,0 +1,33 @@
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,
filetypes = { 'cucumber' },
root_dir = util.find_git_ancestor,
},
docs = {
description = [[
https://cucumber.io
https://github.com/cucumber/common
https://www.npmjs.com/package/@cucumber/language-server
Language server for Cucumber.
`cucumber-language-server` can be installed via `npm`:
```sh
npm install -g @cucumber/language-server
```
]],
default_config = {
root_dir = [[util.find_git_ancestor]],
},
},
}

View file

@ -0,0 +1,61 @@
local util = require 'lspconfig.util'
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 = { bin_name, analysis_server_snapshot_path(), '--lsp' },
filetypes = { 'dart' },
root_dir = util.root_pattern 'pubspec.yaml',
init_options = {
onlyAnalyzeProjectsWithOpenFiles = true,
suggestFromUnimportedLibraries = true,
closingLabels = true,
outline = true,
flutterOutline = true,
},
settings = {
dart = {
completeFunctionCalls = true,
showTodos = true,
},
},
},
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
Language server for dart.
]],
default_config = {
root_dir = [[root_pattern("pubspec.yaml")]],
},
},
}

View file

@ -0,0 +1,115 @@
local util = require 'lspconfig.util'
local lsp = vim.lsp
local function buf_cache(bufnr)
local params = {}
params['referrer'] = { uri = vim.uri_from_bufnr(bufnr) }
params['uris'] = {}
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, result)
if not result then
return nil
end
for client_id, res in pairs(result) do
local lines = vim.split(res.result, '\n')
local bufnr = vim.uri_to_bufnr(uri)
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
end
local function virtual_text_document(uri)
local params = {
textDocument = {
uri = uri,
},
}
local result = lsp.buf_request_sync(0, 'deno/virtualTextDocument', params)
virtual_text_document_handler(uri, result)
end
local function denols_handler(err, result, ctx)
if not result or vim.tbl_isempty(result) then
return nil
end
for _, res in pairs(result) do
local uri = res.uri or res.targetUri
if uri:match '^deno:' then
virtual_text_document(uri)
res['uri'] = uri
res['targetUri'] = uri
end
end
lsp.handlers[ctx.method](err, result, ctx)
end
return {
default_config = {
cmd = { 'deno', 'lsp' },
filetypes = {
'javascript',
'javascriptreact',
'javascript.jsx',
'typescript',
'typescriptreact',
'typescript.tsx',
},
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,
},
},
commands = {
DenolsCache = {
function()
buf_cache(0)
end,
description = 'Cache a module and all of its dependencies.',
},
},
docs = {
package_json = 'https://raw.githubusercontent.com/denoland/vscode_deno/main/package.json',
description = [[
https://github.com/denoland/deno
Deno's built-in language server
To approrpiately highlight codefences returned from denols, you will need to augment vim.g.markdown_fenced languages
in your init.lua. Example:
```lua
vim.g.markdown_fenced_languages = {
"ts=typescript"
}
```
]],
default_config = {
root_dir = [[root_pattern("deno.json", "deno.jsonc", "tsconfig.json", ".git")]],
},
},
}

View file

@ -0,0 +1,26 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'dhall-lsp-server' },
filetypes = { 'dhall' },
root_dir = util.find_git_ancestor,
single_file_support = true,
},
docs = {
description = [[
https://github.com/dhall-lang/dhall-haskell/tree/master/dhall-lsp-server
language server for dhall
`dhall-lsp-server` can be installed via cabal:
```sh
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") or dirname]],
},
},
}

View file

@ -0,0 +1,29 @@
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' }
end
return {
default_config = {
cmd = cmd,
root_dir = util.find_git_ancestor,
single_file_support = true,
filetypes = {},
},
docs = {
description = [[
https://github.com/iamcco/diagnostic-languageserver
Diagnostic language server integrate with linters.
]],
default_config = {
filetypes = 'Empty by default, override to add filetypes',
root_dir = "Vim's starting directory",
init_options = 'Configuration from https://github.com/iamcco/diagnostic-languageserver#config--document',
},
},
}

View file

@ -0,0 +1,30 @@
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,
filetypes = { 'dockerfile' },
root_dir = util.root_pattern 'Dockerfile',
single_file_support = true,
},
docs = {
description = [[
https://github.com/rcjsuen/dockerfile-language-server-nodejs
`docker-langserver` can be installed via `npm`:
```sh
npm install -g dockerfile-language-server-nodejs
```
]],
default_config = {
root_dir = [[root_pattern("Dockerfile")]],
},
},
}

View file

@ -0,0 +1,27 @@
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,
filetypes = { 'dot' },
root_dir = util.find_git_ancestor,
single_file_support = true,
},
docs = {
description = [[
https://github.com/nikeee/dot-language-server
`dot-language-server` can be installed via `npm`:
```sh
npm install -g dot-language-server
```
]],
},
}

View file

@ -0,0 +1,43 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'efm-langserver' },
root_dir = util.find_git_ancestor,
single_file_support = true,
},
docs = {
description = [[
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.
```lua
require('lspconfig')['efm'].setup{
settings = ..., -- You must populate this according to the EFM readme
filetypes = { 'python','cpp','lua' }
}
```
]],
default_config = {
root_dir = [[util.root_pattern(".git")]],
},
},
}

View file

@ -0,0 +1,40 @@
local util = require 'lspconfig.util'
return {
default_config = {
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
`elixir-ls` can be installed by following the instructions [here](https://github.com/elixir-lsp/elixir-ls#building-and-running).
```bash
curl -fLO https://github.com/elixir-lsp/elixir-ls/releases/latest/download/elixir-ls.zip
unzip elixir-ls.zip -d /path/to/elixir-ls
# Unix
chmod +x /path/to/elixir-ls/language_server.sh
```
**By default, elixir-ls 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 elixir-ls.
```lua
require'lspconfig'.elixirls.setup{
-- Unix
cmd = { "/path/to/elixir-ls/language_server.sh" };
-- Windows
cmd = { "/path/to/elixir-ls/language_server.bat" };
...
}
```
]],
default_config = {
root_dir = [[root_pattern("mix.exs", ".git") or vim.loop.os_homedir()]],
},
},
}

View file

@ -0,0 +1,48 @@
local util = require 'lspconfig.util'
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' }
local elm_root_pattern = util.root_pattern 'elm.json'
return {
default_config = {
cmd = cmd,
-- 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)
local filetype = api.nvim_buf_get_option(0, 'filetype')
if filetype == 'elm' or (filetype == 'json' and fname:match 'elm%.json$') then
return elm_root_pattern(fname)
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
If you don't want to use Nvim to install it, then you can use:
```sh
npm install -g elm elm-test elm-format @elm-tooling/elm-language-server
```
]],
default_config = {
root_dir = [[root_pattern("elm.json")]],
},
},
}

View file

@ -0,0 +1,30 @@
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,
filetypes = { 'handlebars', 'typescript', 'javascript' },
root_dir = util.root_pattern('ember-cli-build.js', '.git'),
},
docs = {
description = [[
https://github.com/lifeart/ember-language-server
`ember-language-server` can be installed via `npm`:
```sh
npm install -g @lifeart/ember-language-server
```
]],
default_config = {
root_dir = [[root_pattern("ember-cli-build.js", ".git")]],
},
},
}

View file

@ -0,0 +1,31 @@
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', 'css' },
root_dir = util.find_git_ancestor,
single_file_support = true,
},
docs = {
description = [[
https://github.com/aca/emmet-ls
Package can be installed via `npm`:
```sh
npm install -g emmet-ls
```
]],
default_config = {
root_dir = 'git root',
single_file_support = true,
},
},
}

View file

@ -0,0 +1,34 @@
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,
filetypes = { 'erlang' },
root_dir = util.root_pattern('rebar.config', 'erlang.mk', '.git'),
single_file_support = true,
},
docs = {
description = [[
https://erlang-ls.github.io
Language Server for Erlang.
Clone [erlang_ls](https://github.com/erlang-ls/erlang_ls)
Compile the project with `make` and copy resulting binaries somewhere in your $PATH eg. `cp _build/*/bin/* ~/local/bin`
Installation instruction can be found [here](https://github.com/erlang-ls/erlang_ls).
Installation requirements:
- [Erlang OTP 21+](https://github.com/erlang/otp)
- [rebar3 3.9.1+](https://github.com/erlang/rebar3)
]],
default_config = {
root_dir = [[root_pattern('rebar.config', 'erlang.mk', '.git')]],
},
},
}

View file

@ -0,0 +1,55 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'python3', '-m', 'esbonio' },
filetypes = { 'rst' },
root_dir = util.find_git_ancestor,
},
docs = {
description = [[
https://github.com/swyddfa/esbonio
Esbonio is a language server for [Sphinx](https://www.sphinx-doc.org/en/master/) documentation projects.
The language server can be installed via pip
```
pip install esbonio
```
Since Sphinx is highly extensible you will get best results if you install the language server in the same
Python environment as the one used to build your documentation. To ensure that the correct Python environment
is picked up, you can either launch `nvim` with the correct environment activated.
```
source env/bin/activate
nvim
```
Or you can modify the default `cmd` to include the full path to the Python interpreter.
```lua
require'lspconfig'.esbonio.setup {
cmd = { '/path/to/virtualenv/bin/python', '-m', 'esbonio' }
}
```
Esbonio supports a number of config values passed as `init_options` on startup, for example.
```lua
require'lspconfig'.esbonio.setup {
init_options = {
server = {
logLevel = "debug"
},
sphinx = {
confDir = "/path/to/docs",
srcDir = "${confDir}/../docs-src"
}
}
```
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

@ -0,0 +1,172 @@
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 = get_eslint_client()
if eslint_lsp_client == nil then
return
end
local request
if opts.sync then
request = function(bufnr, method, params)
eslint_lsp_client.request_sync(method, params, nil, bufnr)
end
else
request = function(bufnr, method, params)
eslint_lsp_client.request(method, params, nil, bufnr)
end
end
local bufnr = util.validate_bufnr(opts.bufnr or 0)
request(0, 'workspace/executeCommand', {
command = 'eslint.applyAllFixes',
arguments = {
{
uri = vim.uri_from_bufnr(bufnr),
version = lsp.util.buf_versions[bufnr],
},
},
})
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,
filetypes = {
'javascript',
'javascriptreact',
'javascript.jsx',
'typescript',
'typescriptreact',
'typescript.tsx',
'vue',
},
-- https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats
root_dir = util.root_pattern(
'.eslintrc.js',
'.eslintrc.cjs',
'.eslintrc.yaml',
'.eslintrc.yml',
'.eslintrc.json',
'package.json'
),
-- Refer to https://github.com/Microsoft/vscode-eslint#settings-options for documentation.
settings = {
validate = 'on',
packageManager = 'npm',
useESLintClass = false,
codeActionOnSave = {
enable = false,
mode = 'all',
},
format = true,
quiet = false,
onIgnoredFiles = 'off',
rulesCustomizations = {},
run = 'onType',
-- nodePath configures the directory in which the eslint server should start its node_modules resolution.
-- This path is relative to the workspace folder (root dir) of the server instance.
nodePath = '',
-- use the workspace folder location or the file location (if no workspace folder is open) as the working directory
workingDirectory = { mode = 'location' },
codeAction = {
disableRuleComment = {
enable = true,
location = 'separateLine',
},
showDocumentation = {
enable = true,
},
},
},
on_new_config = function(config, new_root_dir)
-- The "workspaceFolder" is a VSCode concept. It limits how far the
-- server will traverse the file system when locating the ESLint config
-- file (e.g., .eslintrc).
config.settings.workspaceFolder = {
uri = new_root_dir,
name = vim.fn.fnamemodify(new_root_dir, ':t'),
}
end,
handlers = {
['eslint/openDoc'] = function(_, result)
if not result then
return
end
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
return {}
end,
['eslint/confirmESLintExecution'] = function(_, result)
if not result then
return
end
return 4 -- approved
end,
['eslint/probeFailed'] = function()
vim.notify('[lspconfig] ESLint probe failed.', vim.log.levels.WARN)
return {}
end,
['eslint/noLibrary'] = function()
vim.notify('[lspconfig] Unable to find ESLint library.', vim.log.levels.WARN)
return {}
end,
},
},
commands = {
EslintFixAll = {
function()
fix_all { sync = true, bufnr = 0 }
end,
description = 'Fix all eslint problems for this buffer',
},
},
docs = {
description = [[
https://github.com/hrsh7th/vscode-langservers-extracted
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 document on save
```vim
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.
Additional messages you can handle: eslint/noConfig
Messages already handled in lspconfig: eslint/openDoc, eslint/confirmESLintExecution, eslint/probeFailed, eslint/noLibrary
]],
},
}

View file

@ -0,0 +1,28 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'npx', '--no-install', 'flow', 'lsp' },
filetypes = { 'javascript', 'javascriptreact', 'javascript.jsx' },
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
See below for how to setup Flow itself.
https://flow.org/en/docs/install/
See below for lsp command options.
```sh
npx flow lsp --help
```
]],
default_config = {
root_dir = [[root_pattern(".flowconfig")]],
},
},
}

View file

@ -0,0 +1,22 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'flux-lsp' },
filetypes = { 'flux' },
root_dir = util.find_git_ancestor,
single_file_support = true,
},
docs = {
description = [[
https://github.com/influxdata/flux-lsp
`flux-lsp` can be installed via `cargo`:
```sh
cargo install --git https://github.com/influxdata/flux-lsp
```
]],
default_config = {
root_dir = [[util.find_git_ancestor]],
},
},
}

View file

@ -0,0 +1,32 @@
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 = {
package_json = 'https://raw.githubusercontent.com/FoamScience/foam-language-server/master/package.json',
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

@ -0,0 +1,25 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'fortls' },
filetypes = { 'fortran' },
root_dir = function(fname)
return util.root_pattern '.fortls'(fname) or util.find_git_ancestor(fname)
end,
settings = {
nthreads = 1,
},
},
docs = {
package_json = 'https://raw.githubusercontent.com/hansec/vscode-fortran-ls/master/package.json',
description = [[
https://github.com/hansec/fortran-language-server
Fortran Language Server for the Language Server Protocol
]],
default_config = {
root_dir = [[root_pattern(".fortls")]],
},
},
}

View file

@ -0,0 +1,32 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'fsautocomplete', '--background-service-enabled' },
root_dir = util.root_pattern('*.sln', '*.fsproj', '.git'),
filetypes = { 'fsharp' },
init_options = {
AutomaticWorkspaceInit = true,
},
},
docs = {
description = [[
https://github.com/fsharp/FsAutoComplete
Language Server for F# provided by FsAutoComplete (FSAC).
FsAutoComplete requires the [dotnet-sdk](https://dotnet.microsoft.com/download) to be installed.
The preferred way to install FsAutoComplete is with `dotnet tool install --global fsautocomplete`.
Instructions to compile from source are found on the main [repository](https://github.com/fsharp/FsAutoComplete).
You may also need to configure the filetype as Vim defaults to Forth for `*.fs` files:
`autocmd BufNewFile,BufRead *.fs,*.fsx,*.fsi set filetype=fsharp`
This is automatically done by plugins such as [PhilT/vim-fsharp](https://github.com/PhilT/vim-fsharp), [fsharp/vim-fsharp](https://github.com/fsharp/vim-fsharp), and [adelarsq/neofsharp.vim](https://github.com/adelarsq/neofsharp.vim).
]],
},
}

View file

@ -0,0 +1,19 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'fstar.exe', '--lsp' },
filetypes = { 'fstar' },
root_dir = util.find_git_ancestor,
},
docs = {
description = [[
https://github.com/FStarLang/FStar
LSP support is included in FStar. Make sure `fstar.exe` is in your PATH.
]],
default_config = {
root_dir = [[util.find_git_ancestor]],
},
},
}

View file

@ -0,0 +1,19 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'nc', 'localhost', '6008' },
filetypes = { 'gd', 'gdscript', 'gdscript3' },
root_dir = util.root_pattern('project.godot', '.git'),
},
docs = {
description = [[
https://github.com/godotengine/godot
Language server for GDScript, used by Godot Engine.
]],
default_config = {
root_dir = [[util.root_pattern("project.godot", ".git")]],
},
},
}

View file

@ -0,0 +1,21 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'ghcide', '--lsp' },
filetypes = { 'haskell', 'lhaskell' },
root_dir = util.root_pattern('stack.yaml', 'hie-bios', 'BUILD.bazel', 'cabal.config', 'package.yaml'),
},
docs = {
description = [[
https://github.com/digital-asset/ghcide
A library for building Haskell IDE tooling.
"ghcide" isn't for end users now. Use "haskell-language-server" instead of "ghcide".
]],
default_config = {
root_dir = [[root_pattern("stack.yaml", "hie-bios", "BUILD.bazel", "cabal.config", "package.yaml")]],
},
},
}

View file

@ -0,0 +1,34 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'golangci-lint-langserver' },
filetypes = { 'go', 'gomod' },
init_options = {
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', '.git')(fname)
end,
},
docs = {
description = [[
Combination of both lint server and client
https://github.com/nametake/golangci-lint-langserver
https://github.com/golangci/golangci-lint
Installation of binaries needed is done via
```
go install github.com/nametake/golangci-lint-langserver@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.42.1
```
]],
default_config = {
root_dir = [[root_pattern('go.mod', '.git')]],
},
},
}

View file

@ -0,0 +1,21 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'gopls' },
filetypes = { 'go', 'gomod', 'gotmpl' },
root_dir = function(fname)
return util.root_pattern 'go.work'(fname) or util.root_pattern('go.mod', '.git')(fname)
end,
},
docs = {
description = [[
https://github.com/golang/tools/tree/master/gopls
Google's lsp server for golang.
]],
default_config = {
root_dir = [[root_pattern("go.mod", ".git")]],
},
},
}

View file

@ -0,0 +1,31 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'unofficial-grammarly-language-server', '--stdio' },
filetypes = { 'markdown' },
root_dir = util.find_git_ancestor,
single_file_support = true,
handlers = {
['$/updateDocumentState'] = function()
return ''
end,
},
},
docs = {
description = [[
https://github.com/emacs-grammarly/unofficial-grammarly-language-server
`unofficial-grammarly-language-server` can be installed via `npm`:
```sh
npm i -g @emacs-grammarly/unofficial-grammarly-language-server
```
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

@ -0,0 +1,31 @@
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' },
root_dir = util.root_pattern('.git', '.graphqlrc*', '.graphql.config.*', 'graphql.config.*'),
},
docs = {
description = [[
https://github.com/graphql/graphiql/tree/main/packages/graphql-language-service-cli
`graphql-lsp` can be installed via `npm`:
```sh
npm install -g graphql-language-service-cli
```
]],
default_config = {
root_dir = [[root_pattern('.git', '.graphqlrc*', '.graphql.config.*')]],
},
},
}

View file

@ -0,0 +1,36 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = {
'java',
'-jar',
'groovy-language-server-all.jar',
},
filetypes = { 'groovy' },
root_dir = function(fname)
return util.root_pattern 'Jenkinsfile'(fname) or util.find_git_ancestor(fname)
end,
},
docs = {
description = [[
https://github.com/prominic/groovy-language-server.git
Requirements:
- Linux/macOS (for now)
- Java 11+
`groovyls` can be installed by following the instructions [here](https://github.com/prominic/groovy-language-server.git#build).
If you have installed groovy language server, you can set the `cmd` custom path as follow:
```lua
require'lspconfig'.groovyls.setup{
-- Unix
cmd = { "java", "-jar", "path/to/groovyls/groovy-language-server-all.jar" },
...
}
```
]],
},
}

View file

@ -0,0 +1,47 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'haxe-language-server' },
filetypes = { 'haxe' },
root_dir = util.root_pattern '*.hxml',
settings = {
haxe = {
executable = 'haxe',
},
},
init_options = {
displayArguments = { 'build.hxml' },
},
},
docs = {
description = [[
https://github.com/vshaxe/haxe-language-server
The Haxe language server can be built by running the following commands from
the project's root directory:
npm install
npx lix run vshaxe-build -t language-server
This will create `bin/server.js`. Note that the server requires Haxe 3.4.0 or
higher.
After building the language server, set the `cmd` setting in your setup
function:
```lua
lspconfig.haxe_language_server.setup({
cmd = {"node", "path/to/bin/server.js"},
})
```
By default, an HXML compiler arguments file named `build.hxml` is expected in
your project's root directory. If your file is named something different,
specify it using the `init_options.displayArguments` setting.
]],
default_config = {
root_dir = [[root_pattern("*.hxml")]],
},
},
}

View file

@ -0,0 +1,35 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'hie-wrapper', '--lsp' },
filetypes = { 'haskell' },
root_dir = util.root_pattern('stack.yaml', 'package.yaml', '.git'),
},
docs = {
package_json = 'https://raw.githubusercontent.com/alanz/vscode-hie-server/master/package.json',
description = [[
https://github.com/haskell/haskell-ide-engine
the following init_options are supported (see https://github.com/haskell/haskell-ide-engine#configuration):
```lua
init_options = {
languageServerHaskell = {
hlintOn = bool;
maxNumberOfProblems = number;
diagnosticsDebounceDuration = number;
liquidOn = bool (default false);
completionSnippetsOn = bool (default true);
formatOnImportOn = bool (default true);
formattingProvider = string (default "brittany", alternate "floskell");
}
}
```
]],
default_config = {
root_dir = [[root_pattern("stack.yaml", "package.yaml", ".git")]],
},
},
}

View file

@ -0,0 +1,42 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'haskell-language-server-wrapper', '--lsp' },
filetypes = { 'haskell', 'lhaskell' },
root_dir = util.root_pattern('*.cabal', 'stack.yaml', 'cabal.project', 'package.yaml', 'hie.yaml'),
settings = {
haskell = {
formattingProvider = 'ormolu',
},
},
lspinfo = function(cfg)
local extra = {}
local function on_stdout(_, data, _)
local version = data[1]
table.insert(extra, 'version: ' .. version)
end
local opts = {
cwd = cfg.cwd,
stdout_buffered = true,
on_stdout = on_stdout,
}
local chanid = vim.fn.jobstart({ cfg.cmd[1], '--version' }, opts)
vim.fn.jobwait { chanid }
return extra
end,
},
docs = {
description = [[
https://github.com/haskell/haskell-language-server
Haskell Language Server
]],
default_config = {
root_dir = [[root_pattern("*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml")]],
},
},
}

View file

@ -0,0 +1,45 @@
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,
filetypes = { 'html' },
root_dir = util.root_pattern('package.json', '.git'),
single_file_support = true,
settings = {},
init_options = {
embeddedLanguages = { css = true, javascript = true },
configurationSection = { 'html', 'css', 'javascript' },
},
},
docs = {
description = [[
https://github.com/hrsh7th/vscode-langservers-extracted
`vscode-html-language-server` can be installed via `npm`:
```sh
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.
```lua
--Enable (broadcasting) snippet capability for completion
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
require'lspconfig'.html.setup {
capabilities = capabilities,
}
```
]],
},
}

View file

@ -0,0 +1,41 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'idris2-lsp' },
filetypes = { 'idris2' },
root_dir = util.root_pattern '*.ipkg',
},
docs = {
description = [[
https://github.com/idris-community/idris2-lsp
The Idris 2 language server.
Plugins for the Idris 2 filetype include
[Idris2-Vim](https://github.com/edwinb/idris2-vim) (fewer features, stable) and
[Nvim-Idris2](https://github.com/ShinKage/nvim-idris2) (cutting-edge,
experimental).
Idris2-Lsp requires a build of Idris 2 that includes the "Idris 2 API" package.
Package managers with known support for this build include the
[AUR](https://aur.archlinux.org/packages/idris2-api-git/) and
[Homebrew](https://formulae.brew.sh/formula/idris2#default).
If your package manager does not support the Idris 2 API, you will need to build
Idris 2 from source. Refer to the
[the Idris 2 installation instructions](https://github.com/idris-lang/Idris2/blob/main/INSTALL.md)
for details. Steps 5 and 8 are listed as "optional" in that guide, but they are
necessary in order to make the Idris 2 API available.
You need to install a version of Idris2-Lsp that is compatible with your
version of Idris 2. There should be a branch corresponding to every released
Idris 2 version after v0.4.0. Use the latest commit on that branch. For example,
if you have Idris v0.5.1, you should use the v0.5.1 branch of Idris2-Lsp.
If your Idris 2 version is newer than the newest Idris2-Lsp branch, use the
latest commit on the `master` branch, and set a reminder to check the Idris2-Lsp
repo for the release of a compatible versioned branch.
]],
},
}

View file

@ -0,0 +1,51 @@
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,
filetypes = { 'php' },
root_dir = function(pattern)
local cwd = vim.loop.cwd()
local root = util.root_pattern('composer.json', '.git')(pattern)
-- prefer cwd if root is a descendant
return util.path.is_descendant(cwd, root) and cwd or root
end,
},
docs = {
description = [[
https://intelephense.com/
`intelephense` can be installed via `npm`:
```sh
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().
globalStoragePath = Optional absolute path to a global storage dir. Defaults to os.homedir().
licenceKey = Optional licence key or absolute path to a text file containing the licence key.
clearCache = Optional flag to clear server state. State can also be cleared by deleting {storagePath}/intelephense
-- See https://github.com/bmewburn/intelephense-docs/blob/master/installation.md#initialisation-options
}]],
settings = [[{
intelephense = {
files = {
maxSize = 1000000;
};
};
-- See https://github.com/bmewburn/intelephense-docs
}]],
},
},
}

View file

@ -0,0 +1,19 @@
local util = require 'lspconfig.util'
return {
default_config = {
filetypes = { 'java' },
root_dir = util.root_pattern('build.gradle', 'pom.xml', '.git'),
settings = {},
},
docs = {
package_json = 'https://raw.githubusercontent.com/georgewfraser/java-language-server/master/package.json',
description = [[
https://github.com/georgewfraser/java-language-server
Java language server
Point `cmd` to `lang_server_linux.sh` or the equivalent script for macOS/Windows provided by java-language-server
]],
},
}

View file

@ -0,0 +1,194 @@
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(),
JAVA_HOME = os.getenv 'JAVA_HOME',
JDTLS_HOME = os.getenv 'JDTLS_HOME',
WORKSPACE = os.getenv 'WORKSPACE',
}
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_workspace_dir()
return env.WORKSPACE and env.WORKSPACE or util.path.join(env.HOME, 'workspace')
end
local function get_jdtls_jar()
return vim.fn.expand '$JDTLS_HOME/plugins/org.eclipse.equinox.launcher_*.jar'
end
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
end
-- TextDocument version is reported as 0, override with nil so that
-- the client doesn't think the document is newer and refuses to update
-- See: https://github.com/eclipse/eclipse.jdt.ls/issues/1695
local function fix_zero_version(workspace_edit)
if workspace_edit and workspace_edit.documentChanges then
for _, change in pairs(workspace_edit.documentChanges) do
local text_document = change.textDocument
if text_document and text_document.version and text_document.version == 0 then
text_document.version = nil
end
end
end
return workspace_edit
end
local function on_textdocument_codeaction(err, actions, ctx)
for _, action in ipairs(actions) do
-- TODO: (steelsojka) Handle more than one edit?
if action.command == 'java.apply.workspaceEdit' then -- 'action' is Command in java format
action.edit = fix_zero_version(action.edit or action.arguments[1])
elseif type(action.command) == 'table' and action.command.command == 'java.apply.workspaceEdit' then -- 'action' is CodeAction in java format
action.edit = fix_zero_version(action.edit or action.command.arguments[1])
end
end
handlers[ctx.method](err, actions, ctx)
end
local function on_textdocument_rename(err, workspace_edit, ctx)
handlers[ctx.method](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)
end
-- Non-standard notification that can be used to display progress
local function on_language_status(_, result)
local command = vim.api.nvim_command
command 'echohl ModeMsg'
command(string.format('echo "%s"', result.message))
command 'echohl None'
end
local root_files = {
-- Single-module projects
{
'build.xml', -- Ant
'pom.xml', -- Maven
'settings.gradle', -- Gradle
'settings.gradle.kts', -- Gradle
},
-- Multi-module projects
{ 'build.gradle', 'build.gradle.kts' },
}
return {
default_config = {
cmd = {
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(),
'-data',
get_workspace_dir(),
},
filetypes = { 'java' },
root_dir = function(fname)
for _, patterns in ipairs(root_files) do
local root = util.root_pattern(unpack(patterns))(fname)
if root then
return root
end
end
end,
single_file_support = true,
init_options = {
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),
},
},
docs = {
package_json = 'https://raw.githubusercontent.com/redhat-developer/vscode-java/master/package.json',
description = [[
https://projects.eclipse.org/projects/eclipse.jdt.ls
Language server for Java.
IMPORTANT: If you want all the features jdtls has to offer, [nvim-jdtls](https://github.com/mfussenegger/nvim-jdtls)
is highly recommended. If all you need is diagnostics, completion, imports, gotos and formatting and some code actions
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)
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{}
```
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
-- init.lua
require'lspconfig'.jdtls.setup{ cmd = { 'jdtls' } }
```
]],
default_config = {
root_dir = [[{
-- Single-module projects
{
'build.xml', -- Ant
'pom.xml', -- Maven
'settings.gradle', -- Gradle
'settings.gradle.kts', -- Gradle
},
-- Multi-module projects
{ 'build.gradle', 'build.gradle.kts' },
} or vim.fn.getcwd()]],
},
},
}

View file

@ -0,0 +1,28 @@
local util = require 'lspconfig.util'
local root_files = {
'pyproject.toml',
'setup.py',
'setup.cfg',
'requirements.txt',
'Pipfile',
}
return {
default_config = {
cmd = { 'jedi-language-server' },
filetypes = { 'python' },
root_dir = util.root_pattern(unpack(root_files)),
single_file_support = true,
},
docs = {
description = [[
https://github.com/pappasam/jedi-language-server
`jedi-language-server`, a language server for Python, built on top of jedi
]],
default_config = {
root_dir = "vim's starting directory",
},
},
}

View file

@ -0,0 +1,49 @@
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' },
init_options = {
provideFormatter = true,
},
root_dir = util.find_git_ancestor,
single_file_support = true,
},
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
vscode-json-language-server, a language server for JSON and JSON schema
`vscode-json-language-server` can be installed via `npm`:
```sh
npm i -g vscode-langservers-extracted
```
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
--Enable (broadcasting) snippet capability for completion
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
require'lspconfig'.jsonls.setup {
capabilities = capabilities,
}
```
]],
default_config = {
root_dir = [[util.find_git_ancestor]],
},
},
}

View file

@ -0,0 +1,35 @@
local util = require 'lspconfig.util'
-- common jsonnet library paths
local function jsonnet_path(root_dir)
local paths = {
util.path.join(root_dir, 'lib'),
util.path.join(root_dir, 'vendor'),
}
return table.concat(paths, ':')
end
return {
default_config = {
cmd = { 'jsonnet-language-server' },
filetypes = { 'jsonnet', 'libsonnet' },
root_dir = function(fname)
return util.root_pattern 'jsonnetfile.json'(fname) or util.find_git_ancestor(fname)
end,
on_new_config = function(new_config, root_dir)
new_config.cmd_env = {
JSONNET_PATH = jsonnet_path(root_dir),
}
end,
},
docs = {
description = [[
https://github.com/jdbaldry/jsonnet-language-server
A Language Server Protocol (LSP) server for Jsonnet.
]],
default_config = {
root_dir = [[root_pattern("jsonnetfile.json")]],
},
},
}

View file

@ -0,0 +1,76 @@
local util = require 'lspconfig.util'
local cmd = {
'julia',
'--startup-file=no',
'--history-file=no',
'-e',
[[
# Load LanguageServer.jl: attempt to load from ~/.julia/environments/nvim-lspconfig
# with the regular load path as a fallback
ls_install_path = joinpath(
get(DEPOT_PATH, 1, joinpath(homedir(), ".julia")),
"environments", "nvim-lspconfig"
)
pushfirst!(LOAD_PATH, ls_install_path)
using LanguageServer
popfirst!(LOAD_PATH)
depot_path = get(ENV, "JULIA_DEPOT_PATH", "")
project_path = let
dirname(something(
## 1. Finds an explicitly set project (JULIA_PROJECT)
Base.load_path_expand((
p = get(ENV, "JULIA_PROJECT", nothing);
p === nothing ? nothing : isempty(p) ? nothing : p
)),
## 2. Look for a Project.toml file in the current working directory,
## or parent directories, with $HOME as an upper boundary
Base.current_project(),
## 3. First entry in the load path
get(Base.load_path(), 1, nothing),
## 4. Fallback to default global environment,
## this is more or less unreachable
Base.load_path_expand("@v#.#"),
))
end
@info "Running language server" VERSION pwd() project_path depot_path
server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path)
server.runlinter = true
run(server)
]],
}
return {
default_config = {
cmd = cmd,
filetypes = { 'julia' },
root_dir = function(fname)
return util.root_pattern 'Project.toml'(fname) or util.find_git_ancestor(fname)
end,
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
LanguageServer.jl can be installed with `julia` and `Pkg`:
```sh
julia --project=~/.julia/environments/nvim-lspconfig -e 'using Pkg; Pkg.add("LanguageServer")'
```
where `~/.julia/environments/nvim-lspconfig` is the location where
the default configuration expects LanguageServer.jl to be installed.
To update an existing install, use the following command:
```sh
julia --project=~/.julia/environments/nvim-lspconfig -e 'using Pkg; Pkg.update()'
```
Note: In order to have LanguageServer.jl pick up installed packages or dependencies in a
Julia project, you must make sure that the project is instantiated:
```sh
julia --project=/path/to/my/project -e 'using Pkg; Pkg.instantiate()'
```
]],
},
}

View file

@ -0,0 +1,72 @@
local util = require 'lspconfig.util'
local bin_name = 'kotlin-language-server'
if vim.fn.has 'win32' == 1 then
bin_name = bin_name .. '.bat'
end
--- The presence of one of these files indicates a project root directory
--
-- These are configuration files for the various build systems supported by
-- Kotlin. I am not sure whether the language server supports Ant projects,
-- but I'm keeping it here as well since Ant does support Kotlin.
local root_files = {
'settings.gradle', -- Gradle (multi-project)
'settings.gradle.kts', -- Gradle (multi-project)
'build.xml', -- Ant
'pom.xml', -- Maven
}
local fallback_root_files = {
'build.gradle', -- Gradle
'build.gradle.kts', -- Gradle
}
return {
default_config = {
filetypes = { 'kotlin' },
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 },
},
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,
but by fwcd.
It is built via gradle and developed on github.
Source and additional description:
https://github.com/fwcd/kotlin-language-server
This server requires vim to be aware of the kotlin-filetype.
You could refer for this capability to:
https://github.com/udalov/kotlin-vim (recommended)
Note that there is no LICENSE specified yet.
]],
default_config = {
root_dir = [[root_pattern("settings.gradle")]],
cmd = { 'kotlin-language-server' },
capabilities = [[
smart code completion,
diagnostics,
hover,
document symbols,
definition lookup,
method signature help,
dependency resolution,
additional plugins from: https://github.com/fwcd
Snipped of License (refer to source for full License):
The MIT License (MIT)
Copyright (c) 2016 George Fraser
Copyright (c) 2018 fwcd
]],
},
},
}

View file

@ -0,0 +1,54 @@
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,
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'
if endpos then
stdlib_dir = fname:sub(1, endpos)
end
end
return util.root_pattern 'leanpkg.toml'(fname)
or util.root_pattern 'leanpkg.path'(fname)
or stdlib_dir
or util.find_git_ancestor(fname)
end,
single_file_support = true,
},
docs = {
description = [[
https://github.com/leanprover/lean-client-js/tree/master/lean-language-server
Lean installation instructions can be found
[here](https://leanprover-community.github.io/get_started.html#regular-install).
Once Lean is installed, you can install the Lean 3 language server by running
```sh
npm install -g lean-language-server
```
Note: that if you're using [lean.nvim](https://github.com/Julian/lean.nvim),
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") or path.dirname]],
},
},
}

View file

@ -0,0 +1,46 @@
local util = require 'lspconfig.util'
return {
default_config = {
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 '/lib/lean'
if endpos then
stdlib_dir = fname:sub(1, endpos)
end
end
return util.root_pattern('lakefile.lean', 'lean-toolchain', 'leanpkg.toml')(fname)
or stdlib_dir
or util.find_git_ancestor(fname)
end,
on_new_config = function(config, root_dir)
-- add root dir as command-line argument for `ps aux`
table.insert(config.cmd, root_dir)
end,
single_file_support = true,
},
docs = {
description = [[
https://github.com/leanprover/lean4
Lean installation instructions can be found
[here](https://leanprover-community.github.io/get_started.html#regular-install).
The Lean 4 language server is built-in with a Lean 4 install
(and can be manually run with, e.g., `lean --server`).
Note: that if you're using [lean.nvim](https://github.com/Julian/lean.nvim),
that plugin fully handles the setup of the Lean language server,
and you shouldn't set up `leanls` both with it and `lspconfig`.
]],
default_config = {
root_dir = [[root_pattern("lakefile.lean", "lean-toolchain", "leanpkg.toml", ".git")]],
},
},
}

View file

@ -0,0 +1,21 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'lelwel-ls' },
filetypes = { 'llw' },
root_dir = util.find_git_ancestor,
},
docs = {
description = [[
https://github.com/0x2a-42/lelwel
Language server for lelwel grammars.
You can install `lelwel-ls` via cargo:
```sh
cargo install --features="lsp" lelwel
```
]],
},
}

View file

@ -0,0 +1,23 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'lemminx' },
filetypes = { 'xml', 'xsd', 'svg' },
root_dir = util.find_git_ancestor,
single_file_support = true,
},
docs = {
description = [[
https://github.com/eclipse/lemminx
The easiest way to install the server is to get a binary at https://download.jboss.org/jbosstools/vscode/stable/lemminx-binary/ and place it in your PATH.
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 = {
root_dir = [[util.find_git_ancestor]],
},
},
}

View file

@ -0,0 +1,48 @@
local util = require 'lspconfig.util'
local language_id_mapping = {
bib = 'bibtex',
plaintex = 'tex',
rnoweb = 'sweave',
rst = 'restructuredtext',
tex = 'latex',
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' },
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
return language_id
else
return filetype
end
end,
},
docs = {
package_json = 'https://raw.githubusercontent.com/valentjn/vscode-ltex/develop/package.json',
description = [=[
https://github.com/valentjn/ltex-ls
LTeX Language Server: LSP language server for LanguageTool 🔍 with support for LaTeX 🎓, Markdown 📝, and others
To install, download the latest [release](https://github.com/valentjn/ltex-ls/releases) and ensure `ltex-ls` is on your path.
To support org files or R sweave, users can define a custom filetype autocommand (or use a plugin which defines these filetypes):
```lua
vim.cmd [[ autocmd BufRead,BufNewFile *.org set filetype=org ]]
```
]=],
},
}

View file

@ -0,0 +1,45 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'metals' },
filetypes = { 'scala' },
root_dir = util.root_pattern('build.sbt', 'build.sc', 'build.gradle', 'pom.xml'),
message_level = vim.lsp.protocol.MessageType.Log,
init_options = {
statusBarProvider = 'show-message',
isHttpEnabled = true,
compilerOptions = {
snippetAutoIndent = false,
},
},
},
docs = {
description = [[
https://scalameta.org/metals/
Scala language server with rich IDE features.
See full instructions in the Metals documentation:
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`. 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

@ -0,0 +1,20 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'mint', 'ls' },
filetypes = { 'mint' },
root_dir = function(fname)
return util.root_pattern 'mint.json'(fname) or util.find_git_ancestor(fname)
end,
single_file_support = true,
},
docs = {
description = [[
https://www.mint-lang.com
Install Mint using the [instructions](https://www.mint-lang.com/install).
The language server is included since version 0.12.0.
]],
},
}

View file

@ -0,0 +1,37 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'nls' },
filetypes = { 'ncl', 'nickel' },
root_dir = util.find_git_ancestor,
},
docs = {
description = [[
Nickel Language Server
https://github.com/tweag/nickel
`nls` can be installed with nix, or cargo, from the Nickel repository.
```sh
git clone https://github.com/tweag/nickel.git
```
Nix:
```sh
cd nickel
nix-env -f . -i
```
cargo:
```sh
cd nickel/lsp/nls
cargo install --path .
```
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

@ -0,0 +1,21 @@
local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'nimlsp' },
filetypes = { 'nim' },
root_dir = function(fname)
return util.root_pattern '*.nimble'(fname) or util.find_git_ancestor(fname)
end,
single_file_support = true,
},
docs = {
description = [[
https://github.com/PMunch/nimlsp
`nimlsp` can be installed via the `nimble` package manager:
```sh
nimble install nimlsp
```
]],
},
}

View file

@ -0,0 +1,28 @@
local util = require 'lspconfig.util'
local bin_name = 'ocaml-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 = { 'ocaml', 'reason' },
root_dir = util.root_pattern('*.opam', 'esy.json', 'package.json'),
},
docs = {
description = [[
https://github.com/ocaml-lsp/ocaml-language-server
`ocaml-language-server` can be installed via `npm`
```sh
npm install -g ocaml-language-server
```
]],
default_config = {
root_dir = [[root_pattern("*.opam", "esy.json", "package.json")]],
},
},
}

View file

@ -0,0 +1,38 @@
local util = require 'lspconfig.util'
local language_id_of = {
menhir = 'ocaml.menhir',
ocaml = 'ocaml',
ocamlinterface = 'ocaml.interface',
ocamllex = 'ocaml.ocamllex',
reason = 'reason',
}
local get_language_id = function(_, ftype)
return language_id_of[ftype]
end
return {
default_config = {
cmd = { 'ocamllsp' },
filetypes = { 'ocaml', 'ocaml.menhir', 'ocaml.interface', 'ocaml.ocamllex', 'reason' },
root_dir = util.root_pattern('*.opam', 'esy.json', 'package.json', '.git'),
get_language_id = get_language_id,
},
docs = {
description = [[
https://github.com/ocaml/ocaml-lsp
`ocaml-lsp` can be installed as described in [installation guide](https://github.com/ocaml/ocaml-lsp#installation).
To install the lsp server in a particular opam switch:
```sh
opam pin add ocaml-lsp-server https://github.com/ocaml/ocaml-lsp.git
opam install ocaml-lsp-server
```
]],
default_config = {
root_dir = [[root_pattern("*.opam", "esy.json", "package.json", ".git")]],
},
},
}

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