feat(lsp): update lspconfig, add root lsp directory

This commit is contained in:
Simon Lasbrugnas 2025-09-22 16:07:34 +02:00
parent 94e348249d
commit 6340aae11b
Signed by untrusted user who does not match committer: simon
GPG key ID: 86039876BA6ED8DE
375 changed files with 10769 additions and 39 deletions

View file

@ -1,6 +1,6 @@
{
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"LuaSnip": { "branch": "master", "commit": "21f74f7ba8c49f95f9d7c8293b147c2901dd2d3a" },
"LuaSnip": { "branch": "master", "commit": "b3104910bb5ebf40492aadffae18f2528fa757d9" },
"adwaita.nvim": { "branch": "main", "commit": "334d918d5241262816624e8c80410574ccdb25dc" },
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
"cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" },
@ -12,20 +12,20 @@
"format-ts-errors.nvim": { "branch": "main", "commit": "4b7418d6689bc0fd3c1db0500c67133422522384" },
"github-nvim-theme": { "branch": "main", "commit": "c106c9472154d6b2c74b74565616b877ae8ed31d" },
"gitsigns.nvim": { "branch": "main", "commit": "f780609807eca1f783a36a8a31c30a48fbe150c5" },
"go.nvim": { "branch": "master", "commit": "2f7cd3a20a2940320d5cad338722601ffa3ce31b" },
"go.nvim": { "branch": "master", "commit": "bfd135469297f7eec50b444c8a10e098ae170f00" },
"gruvbox": { "branch": "master", "commit": "697c00291db857ca0af00ec154e5bd514a79191f" },
"hybrid.nvim": { "branch": "master", "commit": "74dfee0d5084a3db5e2ad0a78a67ee45e93a64bf" },
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
"kanagawa-paper.nvim": { "branch": "master", "commit": "9161cb185fd7f45d3e9d26118d2ce274c690d5fe" },
"kanagawa-paper.nvim": { "branch": "master", "commit": "ec8af01c782e4d2664bea953b2d14ba5b7d34b6b" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" },
"lazydev.nvim": { "branch": "main", "commit": "258d2a5ef4a3e3d6d9ba9da72c9725c53e9afcbd" },
"lsp-zero.nvim": { "branch": "v4.x", "commit": "d388e2b71834c826e61a3eba48caec53d7602510" },
"lsp_signature.nvim": { "branch": "master", "commit": "62cadce83aaceed677ffe7a2d6a57141af7131ea" },
"lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" },
"lspkind.nvim": { "branch": "master", "commit": "3ddd1b4edefa425fda5a9f95a4f25578727c0bb3" },
"lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" },
"lush.nvim": { "branch": "main", "commit": "9c60ec2279d62487d942ce095e49006af28eed6e" },
"luvit-meta": { "branch": "main", "commit": "1df30b60b1b4aecfebc785aa98943db6c6989716" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "7f9a39fcd2ac6e979001f857727d606888f5909c" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "a1067cf84b4ff81b66d2bf4d01f4cbdb5de40bd0" },
"mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" },
"mellow.nvim": { "branch": "main", "commit": "5cd188489bcc7eb512f0a30581ad972070f8e5cd" },
"neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" },
@ -37,7 +37,7 @@
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
"nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
"nvim-lint": { "branch": "master", "commit": "0864f81c681e15d9bdc1156fe3a17bd07db5a3ed" },
"nvim-lspconfig": { "branch": "master", "commit": "d9879110d0422a566fa01d732556f4d5515e1738" },
"nvim-lspconfig": { "branch": "master", "commit": "ef73a4f2a1ddf0439eb97b46de2aab265ddba1cd" },
"nvim-tree.lua": { "branch": "master", "commit": "e179ad2f83b5955ab0af653069a493a1828c2697" },
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
"nvim-treesitter-context": { "branch": "master", "commit": "41847d3dafb5004464708a3db06b14f12bde548a" },
@ -48,7 +48,7 @@
"supermaven-nvim": { "branch": "main", "commit": "07d20fce48a5629686aefb0a7cd4b25e33947d50" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" },
"telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" },
"trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" },
"trouble.nvim": { "branch": "main", "commit": "f176232e7759c4f8abd923c21e3e5a5c76cd6837" },
"typescript-tools.nvim": { "branch": "master", "commit": "bf11d98ad5736e1cbc1082ca9a03196d45c701f1" },
"vague.nvim": { "branch": "main", "commit": "e3d316dc1b84bc759b4cf31619595a9ed7b3ee19" },
"vim-bujo": { "branch": "master", "commit": "ee3fecb5b3206b8073ac3fe4153391f320c99197" },

31
lsp/ada_ls.lua Normal file
View file

@ -0,0 +1,31 @@
---@brief
---
--- https://github.com/AdaCore/ada_language_server
---
--- Installation instructions can be found [here](https://github.com/AdaCore/ada_language_server#Install).
---
--- Workspace-specific [settings](https://github.com/AdaCore/ada_language_server/blob/master/doc/settings.md) such as `projectFile` can be provided in a `.als.json` file at the root of the workspace.
--- Alternatively, configuration may be passed as a "settings" object to `vim.lsp.config('ada_ls', {})`:
---
--- ```lua
--- vim.lsp.config('ada_ls', {
--- settings = {
--- ada = {
--- projectFile = "project.gpr";
--- scenarioVariables = { ... };
--- }
--- }
--- })
--- ```
local util = require 'lspconfig.util'
---@type vim.lsp.Config
return {
cmd = { 'ada_language_server' },
filetypes = { 'ada' },
root_dir = function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
on_dir(util.root_pattern('Makefile', '.git', 'alire.toml', '*.gpr', '*.adc')(fname))
end,
}

17
lsp/agda_ls.lua Normal file
View file

@ -0,0 +1,17 @@
---@brief
---
--- https://github.com/agda/agda-language-server
---
--- Language Server for Agda.
local util = require 'lspconfig.util'
---@type vim.lsp.Config
return {
cmd = { 'als' },
filetypes = { 'agda' },
root_dir = function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
on_dir(util.root_pattern('.git', '*.agda-lib')(fname))
end,
}

15
lsp/aiken.lua Normal file
View file

@ -0,0 +1,15 @@
---@brief
---
--- https://github.com/aiken-lang/aiken
---
--- A language server for Aiken Programming Language.
--- [Installation](https://aiken-lang.org/installation-instructions)
---
--- It can be i
---@type vim.lsp.Config
return {
cmd = { 'aiken', 'lsp' },
filetypes = { 'aiken' },
root_markers = { 'aiken.toml', '.git' },
}

14
lsp/air.lua Normal file
View file

@ -0,0 +1,14 @@
---@brief
---
--- https://github.com/posit-dev/air
---
--- Air is an R formatter and language server, written in Rust.
---
--- Refer to the [documentation](https://posit-dev.github.io/air/editors.html) for more details.
---@type vim.lsp.Config
return {
cmd = { 'air', 'language-server' },
filetypes = { 'r' },
root_markers = { 'air.toml', '.air.toml', '.git' },
}

30
lsp/alloy_ls.lua Normal file
View file

@ -0,0 +1,30 @@
---@brief
---
--- https://github.com/AlloyTools/org.alloytools.alloy
---
--- Alloy is a formal specification language for describing structures and a tool for exploring them.
---
--- You may also need to configure the filetype for Alloy (*.als) files:
---
--- ```
--- autocmd BufNewFile,BufRead *.als set filetype=alloy
--- ```
---
--- or
---
--- ```lua
--- vim.filetype.add({
--- pattern = {
--- ['.*/*.als'] = 'alloy',
--- },
--- })
--- ```
---
--- Alternatively, you may use a syntax plugin like https://github.com/runoshun/vim-alloy.
---@type vim.lsp.Config
return {
cmd = { 'alloy', 'lsp' },
filetypes = { 'alloy' },
root_markers = { '.git' },
}

View file

@ -0,0 +1,71 @@
---@brief
---
--- https://pypi.org/project/anakin-language-server/
---
--- `anakin-language-server` is yet another Jedi Python language server.
---
--- Available options:
---
--- * Initialization: https://github.com/muffinmad/anakin-language-server#initialization-option
--- * Configuration: https://github.com/muffinmad/anakin-language-server#configuration-options
---@type vim.lsp.Config
return {
cmd = { 'anakinls' },
filetypes = { 'python' },
root_markers = {
'pyproject.toml',
'setup.py',
'setup.cfg',
'requirements.txt',
'Pipfile',
'.git',
},
settings = {
anakinls = {
pyflakes_errors = {
-- Full list: https://github.com/PyCQA/pyflakes/blob/master/pyflakes/messages.py
'ImportStarNotPermitted',
'UndefinedExport',
'UndefinedLocal',
'UndefinedName',
'DuplicateArgument',
'MultiValueRepeatedKeyLiteral',
'MultiValueRepeatedKeyVariable',
'FutureFeatureNotDefined',
'LateFutureImport',
'ReturnOutsideFunction',
'YieldOutsideFunction',
'ContinueOutsideLoop',
'BreakOutsideLoop',
'TwoStarredExpressions',
'TooManyExpressionsInStarredAssignment',
'ForwardAnnotationSyntaxError',
'RaiseNotImplemented',
'StringDotFormatExtraPositionalArguments',
'StringDotFormatExtraNamedArguments',
'StringDotFormatMissingArgument',
'StringDotFormatMixingAutomatic',
'StringDotFormatInvalidFormat',
'PercentFormatInvalidFormat',
'PercentFormatMixedPositionalAndNamed',
'PercentFormatUnsupportedFormat',
'PercentFormatPositionalCountMismatch',
'PercentFormatExtraNamedArguments',
'PercentFormatMissingArgument',
'PercentFormatExpectedMapping',
'PercentFormatExpectedSequence',
'PercentFormatStarRequiresSequence',
},
},
},
}

85
lsp/angularls.lua Normal file
View file

@ -0,0 +1,85 @@
---@brief
---
--- https://github.com/angular/vscode-ng-language-service
--- `angular-language-server` can be installed via npm `npm install -g @angular/language-server`.
---
--- ```lua
--- local project_library_path = "/path/to/project/lib"
--- local cmd = {"ngserver", "--stdio", "--tsProbeLocations", project_library_path , "--ngProbeLocations", project_library_path}
---
--- vim.lsp.config('angularls', {
--- cmd = cmd,
--- })
--- ```
-- Angular requires a node_modules directory to probe for @angular/language-service and typescript
-- in order to use your projects configured versions.
local root_dir = vim.fn.getcwd()
local node_modules_dir = vim.fs.find('node_modules', { path = root_dir, upward = true })[1]
local project_root = node_modules_dir and vim.fs.dirname(node_modules_dir) or '?'
local function get_probe_dir()
return project_root and (project_root .. '/node_modules') or ''
end
local function get_angular_core_version()
if not project_root then
return ''
end
local package_json = project_root .. '/package.json'
if not vim.uv.fs_stat(package_json) then
return ''
end
local contents = io.open(package_json):read '*a'
local json = vim.json.decode(contents)
if not json.dependencies then
return ''
end
local angular_core_version = json.dependencies['@angular/core']
angular_core_version = angular_core_version and angular_core_version:match('%d+%.%d+%.%d+')
return angular_core_version
end
local default_probe_dir = get_probe_dir()
local default_angular_core_version = get_angular_core_version()
-- structure should be like
-- - $EXTENSION_PATH
-- - @angular
-- - language-server
-- - bin
-- - ngserver
-- - typescript
local ngserver_exe = vim.fn.exepath('ngserver')
local ngserver_path = #(ngserver_exe or '') > 0 and vim.fs.dirname(vim.uv.fs_realpath(ngserver_exe)) or '?'
local extension_path = vim.fs.normalize(vim.fs.joinpath(ngserver_path, '../../../'))
-- angularls will get module by `require.resolve(PROBE_PATH, MODULE_NAME)` of nodejs
local ts_probe_dirs = vim.iter({ extension_path, default_probe_dir }):join(',')
local ng_probe_dirs = vim
.iter({ extension_path, default_probe_dir })
:map(function(p)
return vim.fs.joinpath(p, '/@angular/language-server/node_modules')
end)
:join(',')
---@type vim.lsp.Config
return {
cmd = {
'ngserver',
'--stdio',
'--tsProbeLocations',
ts_probe_dirs,
'--ngProbeLocations',
ng_probe_dirs,
'--angularCoreVersion',
default_angular_core_version,
},
filetypes = { 'typescript', 'html', 'typescriptreact', 'typescript.tsx', 'htmlangular' },
root_markers = { 'angular.json', 'nx.json' },
}

38
lsp/ansiblels.lua Normal file
View file

@ -0,0 +1,38 @@
---@brief
---
--- https://github.com/ansible/vscode-ansible
---
--- Language server for the ansible configuration management tool.
---
--- `ansible-language-server` can be installed via `npm`:
---
--- ```sh
--- npm install -g @ansible/ansible-language-server
--- ```
---@type vim.lsp.Config
return {
cmd = { 'ansible-language-server', '--stdio' },
settings = {
ansible = {
python = {
interpreterPath = 'python',
},
ansible = {
path = 'ansible',
},
executionEnvironment = {
enabled = false,
},
validation = {
enabled = true,
lint = {
enabled = true,
path = 'ansible-lint',
},
},
},
},
filetypes = { 'yaml.ansible' },
root_markers = { 'ansible.cfg', '.ansible-lint' },
}

15
lsp/antlersls.lua Normal file
View file

@ -0,0 +1,15 @@
---@brief
---
--- https://www.npmjs.com/package/antlers-language-server
---
--- `antlersls` can be installed via `npm`:
--- ```sh
--- npm install -g antlers-language-server
--- ```
---@type vim.lsp.Config
return {
cmd = { 'antlersls', '--stdio' },
filetypes = { 'html', 'antlers' },
root_markers = { 'composer.json' },
}

59
lsp/apex_ls.lua Normal file
View file

@ -0,0 +1,59 @@
--- @brief
---
--- https://github.com/forcedotcom/salesforcedx-vscode
---
--- Language server for Apex.
---
--- For manual installation, download the JAR file from the [VSCode
--- extension](https://github.com/forcedotcom/salesforcedx-vscode/tree/develop/packages/salesforcedx-vscode-apex) and adjust the `apex_jar_path` appropriately.
---
--- ```lua
--- vim.lsp.config('apex_ls', {
--- apex_jar_path = '/path/to/apex-jorje-lsp.jar',
--- apex_enable_semantic_errors = false, -- Whether to allow Apex Language Server to surface semantic errors
--- apex_enable_completion_statistics = false, -- Whether to allow Apex Language Server to collect telemetry on code completion usage
--- }
---```
---
--- Example configuration using Mason:
---
---```lua
--- vim.lsp.config('apex_ls', {
--- apex_jar_path = vim.fn.stdpath('data') .. '/mason/share/apex-language-server/apex-jorje-lsp.jar',
--- }
---```
---
--- For a complete experience, you may need to ensure the treesitter parsers for 'apex' are installed (:TSInstall apex) as well as configure the filetype for apex (*.cls) files:
---
--- ```lua
--- vim.filetype.add({
--- pattern = {
--- ['.*/*.cls'] = 'apex',
--- },
--- })
--- ```
---@type vim.lsp.Config
return {
cmd = function(dispatchers, config)
local local_cmd = {
vim.env.JAVA_HOME and (vim.env.JAVA_HOME .. '/bin/java') or 'java',
'-cp',
config.apex_jar_path,
'-Ddebug.internal.errors=true',
'-Ddebug.semantic.errors=' .. tostring(config.apex_enable_semantic_errors or false),
'-Ddebug.completion.statistics=' .. tostring(config.apex_enable_completion_statistics or false),
'-Dlwc.typegeneration.disabled=true',
}
if config.apex_jvm_max_heap then
table.insert(local_cmd, '-Xmx' .. config.apex_jvm_max_heap)
end
table.insert(local_cmd, 'apex.jorje.lsp.ApexLanguageServerLauncher')
return vim.lsp.rpc.start(local_cmd, dispatchers)
end,
filetypes = { 'apex', 'apexcode' },
root_markers = {
'sfdx-project.json',
},
}

View file

@ -0,0 +1,91 @@
---@brief
---
--- https://github.com/arduino/arduino-language-server
---
--- Language server for Arduino
---
--- The `arduino-language-server` can be installed by running:
---
--- ```
--- go install github.com/arduino/arduino-language-server@latest
--- ```
---
--- The `arduino-cli` tool must also be installed. Follow [these
--- installation instructions](https://arduino.github.io/arduino-cli/latest/installation/) for
--- your platform.
---
--- After installing `arduino-cli`, follow [these
--- instructions](https://arduino.github.io/arduino-cli/latest/getting-started/#create-a-configuration-file)
--- for generating a configuration file if you haven't done so already, and make
--- sure you [install any relevant platforms
--- libraries](https://arduino.github.io/arduino-cli/latest/getting-started/#install-the-core-for-your-board).
---
--- The language server also requires `clangd` to be installed. Follow [these
--- installation instructions](https://clangd.llvm.org/installation) for your
--- platform.
---
--- If you don't have a sketch yet create one.
---
--- ```sh
--- $ arduino-cli sketch new test
--- $ cd test
--- ```
---
--- You will need a `sketch.yaml` file in order for the language server to understand your project. It will also save you passing options to `arduino-cli` each time you compile or upload a file. You can generate the file by using the following commands.
---
---
--- First gather some information about your board. Make sure your board is connected and run the following:
---
--- ```sh
--- $ arduino-cli board list
--- Port Protocol Type Board Name FQBN Core
--- /dev/ttyACM0 serial Serial Port (USB) Arduino Uno arduino:avr:uno arduino:avr
--- ```
---
--- Then generate the file:
---
--- ```sh
--- arduino-cli board attach -p /dev/ttyACM0 -b arduino:avr:uno test.ino
--- ```
---
--- The resulting file should look like this:
---
--- ```yaml
--- default_fqbn: arduino:avr:uno
--- default_port: /dev/ttyACM0
--- ```
---
--- Your folder structure should look like this:
---
--- ```
--- .
--- ├── test.ino
--- └── sketch.yaml
--- ```
---
--- For further instructions about configuration options, run `arduino-language-server --help`.
---
--- Note that an upstream bug makes keywords in some cases become undefined by the language server.
--- Ref: https://github.com/arduino/arduino-ide/issues/159
local util = require 'lspconfig.util'
---@type vim.lsp.Config
return {
filetypes = { 'arduino' },
root_dir = function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
on_dir(util.root_pattern('*.ino')(fname))
end,
cmd = {
'arduino-language-server',
},
capabilities = {
textDocument = {
semanticTokens = vim.NIL,
},
workspace = {
semanticTokens = vim.NIL,
},
},
}

15
lsp/asm_lsp.lua Normal file
View file

@ -0,0 +1,15 @@
---@brief
---
--- https://github.com/bergercookie/asm-lsp
---
--- Language Server for NASM/GAS/GO Assembly
---
--- `asm-lsp` can be installed via cargo:
--- cargo install asm-lsp
---@type vim.lsp.Config
return {
cmd = { 'asm-lsp' },
filetypes = { 'asm', 'vmasm' },
root_markers = { '.asm-lsp.toml', '.git' },
}

39
lsp/ast_grep.lua Normal file
View file

@ -0,0 +1,39 @@
---@brief
---
--- https://ast-grep.github.io/
---
--- ast-grep(sg) is a fast and polyglot tool for code structural search, lint, rewriting at large scale.
--- ast-grep LSP only works in projects that have `sgconfig.y[a]ml` in their root directories.
--- ```sh
--- npm install [-g] @ast-grep/cli
--- ```
---@type vim.lsp.Config
return {
cmd = { 'ast-grep', 'lsp' },
workspace_required = true,
reuse_client = function(client, config)
config.cmd_cwd = config.root_dir
return client.config.cmd_cwd == config.cmd_cwd
end,
filetypes = { -- https://ast-grep.github.io/reference/languages.html
'c',
'cpp',
'rust',
'go',
'java',
'python',
'javascript',
'javascriptreact',
'javascript.jsx',
'typescript',
'typescriptreact',
'typescript.tsx',
'html',
'css',
'kotlin',
'dart',
'lua',
},
root_markers = { 'sgconfig.yaml', 'sgconfig.yml' },
}

25
lsp/astro.lua Normal file
View file

@ -0,0 +1,25 @@
---@brief
---
--- https://github.com/withastro/language-tools/tree/main/packages/language-server
---
--- `astro-ls` can be installed via `npm`:
--- ```sh
--- npm install -g @astrojs/language-server
--- ```
local util = require 'lspconfig.util'
---@type vim.lsp.Config
return {
cmd = { 'astro-ls', '--stdio' },
filetypes = { 'astro' },
root_markers = { 'package.json', 'tsconfig.json', 'jsconfig.json', '.git' },
init_options = {
typescript = {},
},
before_init = function(_, config)
if config.init_options and config.init_options.typescript and not config.init_options.typescript.tsdk then
config.init_options.typescript.tsdk = util.get_typescript_server_path(config.root_dir)
end
end,
}

66
lsp/atlas.lua Normal file
View file

@ -0,0 +1,66 @@
---@brief
---
--- https://github.com/ariga/atlas
---
--- Language server for Atlas config and schema files.
---
--- You may also need to configure the filetype for *.hcl files:
---
--- ```vim
--- autocmd BufNewFile,BufRead atlas.hcl set filetype=atlas-config
--- autocmd BufNewFile,BufRead *.my.hcl set filetype=atlas-schema-mysql
--- autocmd BufNewFile,BufRead *.pg.hcl set filetype=atlas-schema-postgresql
--- autocmd BufNewFile,BufRead *.lt.hcl set filetype=atlas-schema-sqlite
--- autocmd BufNewFile,BufRead *.ch.hcl set filetype=atlas-schema-clickhouse
--- autocmd BufNewFile,BufRead *.ms.hcl set filetype=atlas-schema-mssql
--- autocmd BufNewFile,BufRead *.rs.hcl set filetype=atlas-schema-redshift
--- autocmd BufNewFile,BufRead *.test.hcl set filetype=atlas-test
--- autocmd BufNewFile,BufRead *.plan.hcl set filetype=atlas-plan
--- autocmd BufNewFile,BufRead *.rule.hcl set filetype=atlas-rule
--- ```
---
--- or
---
--- ```lua
--- vim.filetype.add({
--- filename = {
--- ['atlas.hcl'] = 'atlas-config',
--- },
--- pattern = {
--- ['.*/*.my.hcl'] = 'atlas-schema-mysql',
--- ['.*/*.pg.hcl'] = 'atlas-schema-postgresql',
--- ['.*/*.lt.hcl'] = 'atlas-schema-sqlite',
--- ['.*/*.ch.hcl'] = 'atlas-schema-clickhouse',
--- ['.*/*.ms.hcl'] = 'atlas-schema-mssql',
--- ['.*/*.rs.hcl'] = 'atlas-schema-redshift',
--- ['.*/*.test.hcl'] = 'atlas-test',
--- ['.*/*.plan.hcl'] = 'atlas-plan',
--- ['.*/*.rule.hcl'] = 'atlas-rule',
--- },
--- })
--- ```
---
--- Optionally, tell treesitter to treat Atlas filetypes as HCL for better syntax highlighting:
---
--- ```lua
--- vim.treesitter.language.register('hcl', 'atlas-config')
--- vim.treesitter.language.register('hcl', 'atlas-schema-mysql')
--- vim.treesitter.language.register('hcl', 'atlas-schema-postgresql')
--- vim.treesitter.language.register('hcl', 'atlas-schema-sqlite')
--- vim.treesitter.language.register('hcl', 'atlas-schema-clickhouse')
--- vim.treesitter.language.register('hcl', 'atlas-schema-mssql')
--- vim.treesitter.language.register('hcl', 'atlas-schema-redshift')
--- vim.treesitter.language.register('hcl', 'atlas-test')
--- vim.treesitter.language.register('hcl', 'atlas-plan')
--- vim.treesitter.language.register('hcl', 'atlas-rule')
--- ```
---
---@type vim.lsp.Config
return {
cmd = { 'atlas', 'tool', 'lsp', '--stdio' },
filetypes = {
'atlas-*',
},
root_markers = { 'atlas.hcl' },
}

14
lsp/atopile.lua Normal file
View file

@ -0,0 +1,14 @@
---@brief
---
--- https://atopile.io/
---
--- A language server for atopile Programming Language.
---
--- It comes with the atopile compiler, for installation see: [Installing atopile](https://docs.atopile.io/atopile/guides/install)
---@type vim.lsp.Config
return {
cmd = { 'ato', 'lsp', 'start' },
filetypes = { 'ato' },
root_markers = { 'ato.yaml', '.ato', '.git' },
}

51
lsp/autohotkey_lsp.lua Normal file
View file

@ -0,0 +1,51 @@
---@brief
---
--- https://github.com/thqby/vscode-autohotkey2-lsp
---
--- AutoHotkey v2.0 LSP implementation
---
--- NOTE: AutoHotkey is Windows-only.
local function get_autohotkey_path()
local path = vim.fn.exepath('autohotkey.exe')
return #path > 0 and path or ''
end
---@type vim.lsp.Config
return {
cmd = { 'autohotkey_lsp', '--stdio' },
filetypes = { 'autohotkey' },
root_markers = { 'package.json' },
flags = { debounce_text_changes = 500 },
--capabilities = capabilities,
--on_attach = custom_attach,
init_options = {
locale = 'en-us',
InterpreterPath = get_autohotkey_path(),
AutoLibInclude = 'All',
CommentTags = '^;;\\s*(?<tag>.+)',
CompleteFunctionParens = false,
SymbolFoldinFromOpenBrace = false,
Diagnostics = {
ClassStaticMemberCheck = true,
ParamsCheck = true,
},
ActionWhenV1IsDetected = 'Continue',
FormatOptions = {
array_style = 'expand',
break_chained_methods = false,
ignore_comment = false,
indent_string = '\t',
max_preserve_newlines = 2,
brace_style = 'One True Brace',
object_style = 'none',
preserve_newlines = true,
space_after_double_colon = true,
space_before_conditional = true,
space_in_empty_paren = false,
space_in_other = true,
space_in_paren = false,
wrap_line_length = 0,
},
},
}

24
lsp/autotools_ls.lua Normal file
View file

@ -0,0 +1,24 @@
---@brief
---
--- https://github.com/Freed-Wu/autotools-language-server
---
--- `autotools-language-server` can be installed via `pip`:
--- ```sh
--- pip install autotools-language-server
--- ```
---
--- Language server for autoconf, automake and make using tree sitter in python.
local util = require 'lspconfig.util'
local root_files = { 'configure.ac', 'Makefile', 'Makefile.am', '*.mk' }
---@type vim.lsp.Config
return {
cmd = { 'autotools-language-server' },
filetypes = { 'config', 'automake', 'make' },
root_dir = function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
on_dir(util.root_pattern(unpack(root_files))(fname))
end,
}

14
lsp/awk_ls.lua Normal file
View file

@ -0,0 +1,14 @@
---@brief
---
--- https://github.com/Beaglefoot/awk-language-server/
---
--- `awk-language-server` can be installed via `npm`:
--- ```sh
--- npm install -g awk-language-server
--- ```
---@type vim.lsp.Config
return {
cmd = { 'awk-language-server' },
filetypes = { 'awk' },
}

View file

@ -0,0 +1,39 @@
---@brief
---
--- https://github.com/microsoft/azure-pipelines-language-server
---
--- An Azure Pipelines language server
---
--- `azure-pipelines-ls` can be installed via `npm`:
---
--- ```sh
--- npm install -g azure-pipelines-language-server
--- ```
---
--- By default `azure-pipelines-ls` will only work in files named `azure-pipelines.yml`, this can be changed by providing additional settings like so:
--- ```lua
--- vim.lsp.config('azure_pipelines_ls', {
--- ... -- other configuration
--- settings = {
--- yaml = {
--- schemas = {
--- ["https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json"] = {
--- "/azure-pipeline*.y*l",
--- "/*.azure*",
--- "Azure-Pipelines/**/*.y*l",
--- "Pipelines/*.y*l",
--- },
--- },
--- },
--- },
--- })
--- ```
--- The Azure Pipelines LSP is a fork of `yaml-language-server` and as such the same settings can be passed to it as `yaml-language-server`.
---@type vim.lsp.Config
return {
cmd = { 'azure-pipelines-language-server', '--stdio' },
filetypes = { 'yaml' },
root_markers = { 'azure-pipelines.yml' },
settings = {},
}

47
lsp/bacon_ls.lua Normal file
View file

@ -0,0 +1,47 @@
---@brief
---
--- https://github.com/crisidev/bacon-ls
---
--- A Language Server Protocol wrapper for [bacon](https://dystroy.org/bacon/).
--- It offers textDocument/diagnostic and workspace/diagnostic capabilities for Rust
--- workspaces using the Bacon export locations file.
---
--- It requires `bacon` and `bacon-ls` to be installed on the system using
--- [mason.nvim](https://github.com/williamboman/mason.nvim) or manually
---
--- ```sh
--- $ cargo install --locked bacon bacon-ls
--- ```
---
--- Settings can be changed using the `init_options` dictionary:util
---
--- ```lua
--- init_options = {
--- -- Bacon export filename (default: .bacon-locations).
--- locationsFile = ".bacon-locations",
--- -- Try to update diagnostics every time the file is saved (default: true).
--- updateOnSave = true,
--- -- How many milliseconds to wait before updating diagnostics after a save (default: 1000).
--- updateOnSaveWaitMillis = 1000,
--- -- Try to update diagnostics every time the file changes (default: true).
--- updateOnChange = true,
--- -- Try to validate that bacon preferences are setup correctly to work with bacon-ls (default: true).
--- validateBaconPreferences = true,
--- -- f no bacon preferences file is found, create a new preferences file with the bacon-ls job definition (default: true).
--- createBaconPreferencesFile = true,
--- -- Run bacon in background for the bacon-ls job (default: true)
--- runBaconInBackground = true,
--- -- Command line arguments to pass to bacon running in background (default "--headless -j bacon-ls")
--- runBaconInBackgroundCommandArguments = "--headless -j bacon-ls",
--- -- How many milliseconds to wait between background diagnostics check to synchronize all open files (default: 2000).
--- synchronizeAllOpenFilesWaitMillis = 2000,
--- }
--- ```
---@type vim.lsp.Config
return {
cmd = { 'bacon-ls' },
filetypes = { 'rust' },
root_markers = { '.bacon-locations', 'Cargo.toml' },
init_options = {},
}

13
lsp/ballerina.lua Normal file
View file

@ -0,0 +1,13 @@
---@brief
---
--- Ballerina language server
---
--- The Ballerina language's CLI tool comes with its own language server implementation.
--- The `bal` command line tool must be installed and available in your system's PATH.
---@type vim.lsp.Config
return {
cmd = { 'bal', 'start-language-server' },
filetypes = { 'ballerina' },
root_markers = { 'Ballerina.toml' },
}

66
lsp/basedpyright.lua Normal file
View file

@ -0,0 +1,66 @@
---@brief
---
--- https://detachhead.github.io/basedpyright
---
--- `basedpyright`, a static type checker and language server for python
local function set_python_path(command)
local path = command.args
local clients = vim.lsp.get_clients {
bufnr = vim.api.nvim_get_current_buf(),
name = 'basedpyright',
}
for _, client in ipairs(clients) do
if client.settings then
client.settings.python = vim.tbl_deep_extend('force', client.settings.python or {}, { pythonPath = path })
else
client.config.settings = vim.tbl_deep_extend('force', client.config.settings, { python = { pythonPath = path } })
end
client:notify('workspace/didChangeConfiguration', { settings = nil })
end
end
---@type vim.lsp.Config
return {
cmd = { 'basedpyright-langserver', '--stdio' },
filetypes = { 'python' },
root_markers = {
'pyproject.toml',
'setup.py',
'setup.cfg',
'requirements.txt',
'Pipfile',
'pyrightconfig.json',
'.git',
},
settings = {
basedpyright = {
analysis = {
autoSearchPaths = true,
useLibraryCodeForTypes = true,
diagnosticMode = 'openFilesOnly',
},
},
},
on_attach = function(client, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, 'LspPyrightOrganizeImports', function()
local params = {
command = 'basedpyright.organizeimports',
arguments = { vim.uri_from_bufnr(bufnr) },
}
-- Using client.request() directly because "basedpyright.organizeimports" is private
-- (not advertised via capabilities), which client:exec_cmd() refuses to call.
-- https://github.com/neovim/neovim/blob/c333d64663d3b6e0dd9aa440e433d346af4a3d81/runtime/lua/vim/lsp/client.lua#L1024-L1030
client.request('workspace/executeCommand', params, nil, bufnr)
end, {
desc = 'Organize Imports',
})
vim.api.nvim_buf_create_user_command(bufnr, 'LspPyrightSetPythonPath', set_python_path, {
desc = 'Reconfigure basedpyright with the provided python path',
nargs = 1,
complete = 'file',
})
end,
}

29
lsp/bashls.lua Normal file
View file

@ -0,0 +1,29 @@
---@brief
---
--- https://github.com/bash-lsp/bash-language-server
---
--- `bash-language-server` can be installed via `npm`:
--- ```sh
--- npm i -g bash-language-server
--- ```
---
--- Language server for bash, written using tree sitter in typescript.
---@type vim.lsp.Config
return {
cmd = { 'bash-language-server', 'start' },
settings = {
bashIde = {
-- Glob pattern for finding and parsing shell script files in the workspace.
-- Used by the background analysis features across files.
-- 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)".
globPattern = vim.env.GLOB_PATTERN or '*@(.sh|.inc|.bash|.command)',
},
},
filetypes = { 'bash', 'sh' },
root_markers = { '.git' },
}

27
lsp/basics_ls.lua Normal file
View file

@ -0,0 +1,27 @@
---@brief
---
--- https://github.com/antonk52/basics-language-server/
---
--- Buffer, path, and snippet completion
---
--- ```sh
--- npm install -g basics-language-server
--- ```
---@type vim.lsp.Config
return {
cmd = { 'basics-language-server' },
settings = {
buffer = {
enable = true,
minCompletionLength = 4,
},
path = {
enable = true,
},
snippet = {
enable = false,
sources = {},
},
},
}

22
lsp/bazelrc_lsp.lua Normal file
View file

@ -0,0 +1,22 @@
---@brief
---
--- https://github.com/salesforce-misc/bazelrc-lsp
---
--- `bazelrc-lsp` is a LSP for `.bazelrc` configuration files.
---
--- The `.bazelrc` file type is not detected automatically, you can register it manually (see below) or override the filetypes:
---
--- ```lua
--- vim.filetype.add {
--- pattern = {
--- ['.*.bazelrc'] = 'bazelrc',
--- },
--- }
--- ```
---@type vim.lsp.Config
return {
cmd = { 'bazelrc-lsp', 'lsp' },
filetypes = { 'bazelrc' },
root_markers = { 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel' },
}

13
lsp/beancount.lua Normal file
View file

@ -0,0 +1,13 @@
---@brief
---
--- https://github.com/polarmutex/beancount-language-server#installation
---
--- See https://github.com/polarmutex/beancount-language-server#configuration for configuration options
---@type vim.lsp.Config
return {
cmd = { 'beancount-language-server', '--stdio' },
filetypes = { 'beancount', 'bean' },
root_markers = { '.git' },
init_options = {},
}

40
lsp/bicep.lua Normal file
View file

@ -0,0 +1,40 @@
---@brief
---
--- 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"
--- vim.lsp.config('bicep', {
--- 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)
--- ```
---@type vim.lsp.Config
return {
filetypes = { 'bicep', 'bicep-params' },
root_markers = { '.git' },
init_options = {},
}

72
lsp/biome.lua Normal file
View file

@ -0,0 +1,72 @@
---@brief
--- https://biomejs.dev
---
--- Toolchain of the web. [Successor of Rome](https://biomejs.dev/blog/annoucing-biome).
---
--- ```sh
--- npm install [-g] @biomejs/biome
--- ```
---
--- ### Monorepo support
---
--- `biome` supports monorepos by default. It will automatically find the `biome.json` corresponding to the package you are working on, as described in the [documentation](https://biomejs.dev/guides/big-projects/#monorepo). This works without the need of spawning multiple instances of `biome`, saving memory.
local util = require 'lspconfig.util'
---@type vim.lsp.Config
return {
cmd = function(dispatchers, config)
local cmd = 'biome'
local local_cmd = (config or {}).root_dir and config.root_dir .. '/node_modules/.bin/biome'
if local_cmd and vim.fn.executable(local_cmd) == 1 then
cmd = local_cmd
end
return vim.lsp.rpc.start({ cmd, 'lsp-proxy' }, dispatchers)
end,
filetypes = {
'astro',
'css',
'graphql',
'html',
'javascript',
'javascriptreact',
'json',
'jsonc',
'svelte',
'typescript',
'typescript.tsx',
'typescriptreact',
'vue',
},
workspace_required = true,
root_dir = function(bufnr, on_dir)
-- The project root is where the LSP can be started from
-- As stated in the documentation above, this LSP supports monorepos and simple projects.
-- We select then from the project root, which is identified by the presence of a package
-- manager lock file.
local root_markers = { 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb', 'bun.lock' }
-- Give the root markers equal priority by wrapping them in a table
root_markers = vim.fn.has('nvim-0.11.3') == 1 and { root_markers, { '.git' } }
or vim.list_extend(root_markers, { '.git' })
-- We fallback to the current working directory if no project root is found
local project_root = vim.fs.root(bufnr, root_markers) or vim.fn.getcwd()
-- We know that the buffer is using Biome if it has a config file
-- in its directory tree.
local filename = vim.api.nvim_buf_get_name(bufnr)
local biome_config_files = { 'biome.json', 'biome.jsonc' }
biome_config_files = util.insert_package_json(biome_config_files, 'biome', filename)
local is_buffer_using_biome = vim.fs.find(biome_config_files, {
path = filename,
type = 'file',
limit = 1,
upward = true,
stop = vim.fs.dirname(project_root),
})[1]
if not is_buffer_using_biome then
return
end
on_dir(project_root)
end,
}

View file

@ -0,0 +1,10 @@
---@brief
---
--- 🛠️ bitbake language server
---@type vim.lsp.Config
return {
cmd = { 'bitbake-language-server' },
filetypes = { 'bitbake' },
root_markers = { '.git' },
}

22
lsp/blueprint_ls.lua Normal file
View file

@ -0,0 +1,22 @@
---@brief
---
--- https://gitlab.gnome.org/jwestman/blueprint-compiler
---
--- `blueprint-compiler` can be installed via your system package manager.
---
--- Language server for the blueprint markup language, written in python and part
--- of the blueprint-compiler.
---@type vim.lsp.Config
return {
cmd = { 'blueprint-compiler', 'lsp' },
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 '*@(.blp)',
},
filetypes = { 'blueprint' },
root_markers = { '.git' },
}

17
lsp/bqls.lua Normal file
View file

@ -0,0 +1,17 @@
---@brief
---
--- https://github.com/kitagry/bqls
---
--- The `bqls` BigQuery language server can be installed by running:
---
--- ```sh
--- $ go install github.com/kitagry/bqls@latest
--- ```
---@type vim.lsp.Config
return {
cmd = { 'bqls' },
filetypes = { 'sql' },
root_markers = { '.git' },
settings = {},
}

15
lsp/bright_script.lua Normal file
View file

@ -0,0 +1,15 @@
---@brief
---
--- https://github.com/RokuCommunity/brighterscript
---
--- `brightscript` can be installed via `npm`:
--- ```sh
--- npm install -g brighterscript
--- ```
---@type vim.lsp.Config
return {
cmd = { 'bsc', '--lsp', '--stdio' },
filetypes = { 'brs' },
root_markers = { 'makefile', 'Makefile', '.git' },
}

11
lsp/bsl_ls.lua Normal file
View file

@ -0,0 +1,11 @@
---@brief
---
--- https://github.com/1c-syntax/bsl-language-server
---
--- Language Server Protocol implementation for 1C (BSL) - 1C:Enterprise 8 and OneScript languages.
---@type vim.lsp.Config
return {
filetypes = { 'bsl', 'os' },
root_markers = { '.git' },
}

18
lsp/buck2.lua Normal file
View file

@ -0,0 +1,18 @@
---@brief
---
--- https://github.com/facebook/buck2
---
--- Build system, successor to Buck
---
--- To better detect Buck2 project files, the following can be added:
---
--- ```
--- vim.cmd [[ autocmd BufRead,BufNewFile *.bxl,BUCK,TARGETS set filetype=bzl ]]
--- ```
---@type vim.lsp.Config
return {
cmd = { 'buck2', 'lsp' },
filetypes = { 'bzl' },
root_markers = { '.buckconfig' },
}

13
lsp/buddy_ls.lua Normal file
View file

@ -0,0 +1,13 @@
---@brief
---
--- https://github.com/buddy-compiler/buddy-mlir#buddy-lsp-server
--- The Language Server for the buddy-mlir, a drop-in replacement for mlir-lsp-server,
--- supporting new dialects defined in buddy-mlir.
--- `buddy-lsp-server` can be installed at the buddy-mlir repository (buddy-compiler/buddy-mlir)
---@type vim.lsp.Config
return {
cmd = { 'buddy-lsp-server' },
filetypes = { 'mlir' },
root_markers = { '.git' },
}

13
lsp/buf_ls.lua Normal file
View file

@ -0,0 +1,13 @@
--- @brief
--- https://github.com/bufbuild/buf
---
--- buf beta lsp included in the cli itself
---
--- buf beta lsp is a Protobuf language server compatible with Buf modules and workspaces
---@type vim.lsp.Config
return {
cmd = { 'buf', 'beta', 'lsp', '--timeout=0', '--log-format=text' },
filetypes = { 'proto' },
root_markers = { 'buf.yaml', '.git' },
}

17
lsp/bufls.lua Normal file
View file

@ -0,0 +1,17 @@
---@brief
---
--- https://github.com/bufbuild/buf-language-server
---
--- `buf-language-server` can be installed via `go install`:
--- ```sh
--- go install github.com/bufbuild/buf-language-server/cmd/bufls@latest
--- ```
---
--- bufls is a Protobuf language server compatible with Buf modules and workspaces
---@type vim.lsp.Config
return {
cmd = { 'bufls', 'serve' },
filetypes = { 'proto' },
root_markers = { 'buf.work.yaml', '.git' },
}

15
lsp/bzl.lua Normal file
View file

@ -0,0 +1,15 @@
---@brief
---
--- https://bzl.io/
---
--- https://docs.stack.build/docs/cli/installation
---
--- https://docs.stack.build/docs/vscode/starlark-language-server
---@type vim.lsp.Config
return {
cmd = { 'bzl', 'lsp', 'serve' },
filetypes = { 'bzl' },
-- https://docs.bazel.build/versions/5.4.1/build-ref.html#workspace
root_markers = { 'WORKSPACE', 'WORKSPACE.bazel' },
}

12
lsp/c3_lsp.lua Normal file
View file

@ -0,0 +1,12 @@
---@brief
---
--- https://github.com/pherrymason/c3-lsp
---
--- Language Server for c3.
---@type vim.lsp.Config
return {
cmd = { 'c3lsp' },
root_markers = { 'project.json', 'manifest.json', '.git' },
filetypes = { 'c3', 'c3i' },
}

20
lsp/cairo_ls.lua Normal file
View file

@ -0,0 +1,20 @@
---@brief
---
--- [Cairo Language Server](https://github.com/starkware-libs/cairo/tree/main/crates/cairo-lang-language-server)
---
--- First, install Cairo following [this tutorial](https://book.cairo-lang.org/ch01-01-installation.html)
---
--- Then enable Cairo Language Server in your Lua configuration.
--- ```lua
--- vim.lsp.enable('cairo_ls')
--- ```
---
--- *cairo-language-server is still under active development, some features might not work yet !*
---@type vim.lsp.Config
return {
init_options = { hostInfo = 'neovim' },
cmd = { 'scarb', 'cairo-language-server', '/C', '--node-ipc' },
filetypes = { 'cairo' },
root_markers = { 'Scarb.toml', 'cairo_project.toml', '.git' },
}

53
lsp/ccls.lua Normal file
View file

@ -0,0 +1,53 @@
---@brief
---
--- 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
--- vim.lsp.config("ccls", {
--- init_options = {
--- compilationDatabaseDirectory = "build";
--- index = {
--- threads = 0;
--- };
--- clang = {
--- excludeArgs = { "-frounding-math"} ;
--- };
--- }
--- })
--- ```
local function switch_source_header(client, bufnr)
local method_name = 'textDocument/switchSourceHeader'
local params = vim.lsp.util.make_text_document_params(bufnr)
client:request(method_name, params, function(err, result)
if err then
error(tostring(err))
end
if not result then
vim.notify('corresponding file cannot be determined')
return
end
vim.cmd.edit(vim.uri_to_fname(result))
end, bufnr)
end
---@type vim.lsp.Config
return {
cmd = { 'ccls' },
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' },
root_markers = { 'compile_commands.json', '.ccls', '.git' },
offset_encoding = 'utf-32',
-- ccls does not support sending a null root directory
workspace_required = true,
on_attach = function(client, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, 'LspCclsSwitchSourceHeader', function()
switch_source_header(client, bufnr)
end, { desc = 'Switch between source/header' })
end,
}

20
lsp/cds_lsp.lua Normal file
View file

@ -0,0 +1,20 @@
---@brief
---
--- https://cap.cloud.sap/docs/
---
--- `cds-lsp` can be installed via `npm`:
---
--- ```sh
--- npm i -g @sap/cds-lsp
--- ```
---@type vim.lsp.Config
return {
cmd = { 'cds-lsp', '--stdio' },
filetypes = { 'cds' },
-- init_options = { provideFormatter = true }, -- needed to enable formatting capabilities
root_markers = { 'package.json', 'db', 'srv' },
settings = {
cds = { validate = true },
},
}

14
lsp/cir_lsp_server.lua Normal file
View file

@ -0,0 +1,14 @@
---@brief
---
--- https://llvm.github.io/clangir
---
--- The Language Server for the LLVM ClangIR language
---
--- `cir-lsp-server` can be installed at the llvm-project repository (https://github.com/llvm/llvm-project)
---@type vim.lsp.Config
return {
cmd = { 'cir-lsp-server' },
filetypes = { 'cir' },
root_markers = { '.git' },
}

12
lsp/circom-lsp.lua Normal file
View file

@ -0,0 +1,12 @@
---@brief
---
--- [Circom Language Server](https://github.com/rubydusa/circom-lsp)
---
--- `circom-lsp`, the language server for the Circom language.
---@type vim.lsp.Config
return {
cmd = { 'circom-lsp' },
filetypes = { 'circom' },
root_markers = { '.git' },
}

100
lsp/clangd.lua Normal file
View file

@ -0,0 +1,100 @@
---@brief
---
--- https://clangd.llvm.org/installation.html
---
--- - **NOTE:** Clang >= 11 is recommended! See [#23](https://github.com/neovim/nvim-lspconfig/issues/23).
--- - If `compile_commands.json` lives in a build directory, you should
--- symlink it to the root of your source tree.
--- ```
--- ln -s /path/to/myproject/build/compile_commands.json /path/to/myproject/
--- ```
--- - clangd relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html)
--- specified as compile_commands.json, see https://clangd.llvm.org/installation#compile_commandsjson
-- https://clangd.llvm.org/extensions.html#switch-between-sourceheader
local function switch_source_header(bufnr, client)
local method_name = 'textDocument/switchSourceHeader'
---@diagnostic disable-next-line:param-type-mismatch
if not client or not client:supports_method(method_name) then
return vim.notify(('method %s is not supported by any servers active on the current buffer'):format(method_name))
end
local params = vim.lsp.util.make_text_document_params(bufnr)
---@diagnostic disable-next-line:param-type-mismatch
client:request(method_name, params, function(err, result)
if err then
error(tostring(err))
end
if not result then
vim.notify('corresponding file cannot be determined')
return
end
vim.cmd.edit(vim.uri_to_fname(result))
end, bufnr)
end
local function symbol_info(bufnr, client)
local method_name = 'textDocument/symbolInfo'
---@diagnostic disable-next-line:param-type-mismatch
if not client or not client:supports_method(method_name) then
return vim.notify('Clangd client not found', vim.log.levels.ERROR)
end
local win = vim.api.nvim_get_current_win()
local params = vim.lsp.util.make_position_params(win, client.offset_encoding)
---@diagnostic disable-next-line:param-type-mismatch
client:request(method_name, params, function(err, res)
if err or #res == 0 then
-- Clangd always returns an error, there is no reason to parse it
return
end
local container = string.format('container: %s', res[1].containerName) ---@type string
local name = string.format('name: %s', res[1].name) ---@type string
vim.lsp.util.open_floating_preview({ name, container }, '', {
height = 2,
width = math.max(string.len(name), string.len(container)),
focusable = false,
focus = false,
title = 'Symbol Info',
})
end, bufnr)
end
---@class ClangdInitializeResult: lsp.InitializeResult
---@field offsetEncoding? string
---@type vim.lsp.Config
return {
cmd = { 'clangd' },
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' },
root_markers = {
'.clangd',
'.clang-tidy',
'.clang-format',
'compile_commands.json',
'compile_flags.txt',
'configure.ac', -- AutoTools
'.git',
},
capabilities = {
textDocument = {
completion = {
editsNearCursor = true,
},
},
offsetEncoding = { 'utf-8', 'utf-16' },
},
---@param init_result ClangdInitializeResult
on_init = function(client, init_result)
if init_result.offsetEncoding then
client.offset_encoding = init_result.offsetEncoding
end
end,
on_attach = function(client, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, 'LspClangdSwitchSourceHeader', function()
switch_source_header(bufnr, client)
end, { desc = 'Switch between source/header' })
vim.api.nvim_buf_create_user_command(bufnr, 'LspClangdShowSymbolInfo', function()
symbol_info(bufnr, client)
end, { desc = 'Show symbol info' })
end,
}

11
lsp/clarinet.lua Normal file
View file

@ -0,0 +1,11 @@
---@brief
--- https://github.com/hirosystems/clarinet
---
--- Clarinet is the fastest way to build, test, and deploy smart contracts on the Stacks blockchain.
---@type vim.lsp.Config
return {
cmd = { 'clarinet', 'lsp' },
filetypes = { 'clar', 'clarity' },
root_markers = { 'Clarinet.toml' },
}

12
lsp/clojure_lsp.lua Normal file
View file

@ -0,0 +1,12 @@
---@brief
---
--- https://github.com/clojure-lsp/clojure-lsp
---
--- Clojure Language Server
---@type vim.lsp.Config
return {
cmd = { 'clojure-lsp' },
filetypes = { 'clojure', 'edn' },
root_markers = { 'project.clj', 'deps.edn', 'build.boot', 'shadow-cljs.edn', '.git', 'bb.edn' },
}

15
lsp/cmake.lua Normal file
View file

@ -0,0 +1,15 @@
---@brief
---
--- https://github.com/regen100/cmake-language-server
---
--- CMake LSP Implementation
---@type vim.lsp.Config
return {
cmd = { 'cmake-language-server' },
filetypes = { 'cmake' },
root_markers = { 'CMakePresets.json', 'CTestConfig.cmake', '.git', 'build', 'cmake' },
init_options = {
buildDirectory = 'build',
},
}

10
lsp/cobol_ls.lua Normal file
View file

@ -0,0 +1,10 @@
---@brief
---
--- Cobol language support
---@type vim.lsp.Config
return {
cmd = { 'cobol-language-support' },
filetypes = { 'cobol' },
root_markers = { '.git' },
}

37
lsp/codebook.lua Normal file
View file

@ -0,0 +1,37 @@
---@brief
---
--- https://github.com/blopker/codebook
---
--- An unholy spell checker for code.
---
--- `codebook-lsp` can be installed by following the instructions [here](https://github.com/blopker/codebook/blob/main/README.md#installation).
---
--- The default `cmd` assumes that the `codebook-lsp` binary can be found in `$PATH`.
---
---@type vim.lsp.Config
return {
cmd = { 'codebook-lsp', 'serve' },
filetypes = {
'c',
'css',
'gitcommit',
'go',
'haskell',
'html',
'java',
'javascript',
'javascriptreact',
'lua',
'markdown',
'php',
'python',
'ruby',
'rust',
'toml',
'text',
'typescript',
'typescriptreact',
},
root_markers = { '.git', 'codebook.toml', '.codebook.toml' },
}

16
lsp/coffeesense.lua Normal file
View file

@ -0,0 +1,16 @@
---@brief
---
--- https://github.com/phil294/coffeesense
---
--- CoffeeSense Language Server
--- `coffeesense-language-server` can be installed via `npm`:
--- ```sh
--- npm install -g coffeesense-language-server
--- ```
---@type vim.lsp.Config
return {
cmd = { 'coffeesense-language-server', '--stdio' },
filetypes = { 'coffee' },
root_markers = { 'package.json' },
}

17
lsp/contextive.lua Normal file
View file

@ -0,0 +1,17 @@
---@brief
---
--- https://github.com/dev-cycles/contextive
---
--- Language Server for Contextive.
---
--- Contextive allows you to define terms in a central file and provides auto-completion suggestions and hover panels for these terms wherever they're used.
---
--- To install the language server, you need to download the appropriate [GitHub release asset](https://github.com/dev-cycles/contextive/releases/) for your operating system and architecture.
---
--- After the download unzip the Contextive.LanguageServer binary and copy the file into a folder that is included in your system's PATH.
---@type vim.lsp.Config
return {
cmd = { 'Contextive.LanguageServer' },
root_markers = { '.contextive', '.git' },
}

108
lsp/copilot.lua Normal file
View file

@ -0,0 +1,108 @@
---@brief
---
--- https://www.npmjs.com/package/@github/copilot-language-server
---
--- The Copilot Language Server enables any editor or IDE
--- to integrate with GitHub Copilot via
--- [the language server protocol](https://microsoft.github.io/language-server-protocol/).
---
--- **[GitHub Copilot](https://github.com/features/copilot)**
--- is an AI pair programmer tool that helps you write code faster and smarter.
---
--- **Sign up for [GitHub Copilot Free](https://github.com/settings/copilot)!**
---
--- Please see [terms of use for GitHub Copilot](https://docs.github.com/en/site-policy/github-terms/github-terms-for-additional-products-and-features#github-copilot)
---
---@param bufnr integer,
---@param client vim.lsp.Client
local function sign_in(bufnr, client)
client:request(
---@diagnostic disable-next-line: param-type-mismatch
'signIn',
vim.empty_dict(),
function(err, result)
if err then
vim.notify(err.message, vim.log.levels.ERROR)
return
end
if result.command then
local code = result.userCode
local command = result.command
vim.fn.setreg('+', code)
vim.fn.setreg('*', code)
local continue = vim.fn.confirm(
'Copied your one-time code to clipboard.\n' .. 'Open the browser to complete the sign-in process?',
'&Yes\n&No'
)
if continue == 1 then
client:exec_cmd(command, { bufnr = bufnr }, function(cmd_err, cmd_result)
if cmd_err then
vim.notify(err.message, vim.log.levels.ERROR)
return
end
if cmd_result.status == 'OK' then
vim.notify('Signed in as ' .. cmd_result.user .. '.')
end
end)
end
end
if result.status == 'PromptUserDeviceFlow' then
vim.notify('Enter your one-time code ' .. result.userCode .. ' in ' .. result.verificationUri)
elseif result.status == 'AlreadySignedIn' then
vim.notify('Already signed in as ' .. result.user .. '.')
end
end
)
end
---@param client vim.lsp.Client
local function sign_out(_, client)
client:request(
---@diagnostic disable-next-line: param-type-mismatch
'signOut',
vim.empty_dict(),
function(err, result)
if err then
vim.notify(err.message, vim.log.levels.ERROR)
return
end
if result.status == 'NotSignedIn' then
vim.notify('Not signed in.')
end
end
)
end
---@type vim.lsp.Config
return {
cmd = {
'copilot-language-server',
'--stdio',
},
root_markers = { '.git' },
init_options = {
editorInfo = {
name = 'Neovim',
version = tostring(vim.version()),
},
editorPluginInfo = {
name = 'Neovim',
version = tostring(vim.version()),
},
},
settings = {
telemetry = {
telemetryLevel = 'all',
},
},
on_attach = function(client, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, 'LspCopilotSignIn', function()
sign_in(bufnr, client)
end, { desc = 'Sign in Copilot with GitHub' })
vim.api.nvim_buf_create_user_command(bufnr, 'LspCopilotSignOut', function()
sign_out(bufnr, client)
end, { desc = 'Sign out Copilot with GitHub' })
end,
}

10
lsp/coq_lsp.lua Normal file
View file

@ -0,0 +1,10 @@
---@brief
---
--- https://github.com/ejgallego/coq-lsp/
---@type vim.lsp.Config
return {
cmd = { 'coq-lsp' },
filetypes = { 'coq' },
root_markers = { '_CoqProject', '.git' },
}

12
lsp/crystalline.lua Normal file
View file

@ -0,0 +1,12 @@
---@brief
---
--- https://github.com/elbywan/crystalline
---
--- Crystal language server.
---@type vim.lsp.Config
return {
cmd = { 'crystalline' },
filetypes = { 'crystal' },
root_markers = { 'shard.yml', '.git' },
}

24
lsp/csharp_ls.lua Normal file
View file

@ -0,0 +1,24 @@
---@brief
---
--- 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`.
local util = require 'lspconfig.util'
---@type vim.lsp.Config
return {
cmd = { 'csharp-ls' },
root_dir = function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
on_dir(util.root_pattern '*.sln'(fname) or util.root_pattern '*.slnx'(fname) or util.root_pattern '*.csproj'(fname))
end,
filetypes = { 'cs' },
init_options = {
AutomaticWorkspaceInit = true,
},
}

24
lsp/cspell_ls.lua Normal file
View file

@ -0,0 +1,24 @@
---@brief
---
--- [cspell language server](https://github.com/vlabo/cspell-lsp)
---
---@type vim.lsp.Config
return {
cmd = { 'cspell-lsp', '--stdio' },
root_markers = {
'.git',
'cspell.json',
'.cspell.json',
'cspell.json',
'.cSpell.json',
'cSpell.json',
'cspell.config.js',
'cspell.config.cjs',
'cspell.config.json',
'cspell.config.yaml',
'cspell.config.yml',
'cspell.yaml',
'cspell.yml',
},
}

39
lsp/css_variables.lua Normal file
View file

@ -0,0 +1,39 @@
---@brief
---
--- https://github.com/vunguyentuan/vscode-css-variables/tree/master/packages/css-variables-language-server
---
--- CSS variables autocompletion and go-to-definition
---
--- `css-variables-language-server` can be installed via `npm`:
---
--- ```sh
--- npm i -g css-variables-language-server
--- ```
---@type vim.lsp.Config
return {
cmd = { 'css-variables-language-server', '--stdio' },
filetypes = { 'css', 'scss', 'less' },
root_markers = { 'package.json', '.git' },
-- Same as inlined defaults that don't seem to work without hardcoding them in the lua config
-- https://github.com/vunguyentuan/vscode-css-variables/blob/763a564df763f17aceb5f3d6070e0b444a2f47ff/packages/css-variables-language-server/src/CSSVariableManager.ts#L31-L50
settings = {
cssVariables = {
lookupFiles = { '**/*.less', '**/*.scss', '**/*.sass', '**/*.css' },
blacklistFolders = {
'**/.cache',
'**/.DS_Store',
'**/.git',
'**/.hg',
'**/.next',
'**/.svn',
'**/bower_components',
'**/CVS',
'**/dist',
'**/node_modules',
'**/tests',
'**/tmp',
},
},
},
}

34
lsp/cssls.lua Normal file
View file

@ -0,0 +1,34 @@
---@brief
---
--- 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
---
--- vim.lsp.config('cssls', {
--- capabilities = capabilities,
--- })
--- ```
---@type vim.lsp.Config
return {
cmd = { 'vscode-css-language-server', '--stdio' },
filetypes = { 'css', 'scss', 'less' },
init_options = { provideFormatter = true }, -- needed to enable formatting capabilities
root_markers = { 'package.json', '.git' },
settings = {
css = { validate = true },
scss = { validate = true },
less = { validate = true },
},
}

17
lsp/cssmodules_ls.lua Normal file
View file

@ -0,0 +1,17 @@
---@brief
---
--- 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
--- ```
---@type vim.lsp.Config
return {
cmd = { 'cssmodules-language-server' },
filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact' },
root_markers = { 'package.json' },
}

View file

@ -0,0 +1,19 @@
---@brief
---
--- 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
--- ```
---@type vim.lsp.Config
return {
cmd = { 'cucumber-language-server', '--stdio' },
filetypes = { 'cucumber' },
root_markers = { '.git' },
}

12
lsp/cue.lua Normal file
View file

@ -0,0 +1,12 @@
---@brief
---
--- https://github.com/cue-lang/cue
---
--- CUE makes it easy to validate data, write schemas, and ensure configurations align with policies.
---@type vim.lsp.Config
return {
cmd = { 'cue', 'lsp' },
filetypes = { 'cue' },
root_markers = { 'cue.mod', '.git' },
}

View file

@ -0,0 +1,32 @@
---@brief
---
--- https://github.com/Matsuuu/custom-elements-language-server
---
--- `custom-elements-languageserver` depends on `typescript`. Both packages can be installed via `npm`:
--- ```sh
--- npm install -g typescript custom-elements-languageserver
--- ```
--- To configure typescript language server, add a
--- [`tsconfig.json`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) or
--- [`jsconfig.json`](https://code.visualstudio.com/docs/languages/jsconfig) to the root of your
--- project.
--- Here's an example that disables type checking in JavaScript files.
--- ```json
--- {
--- "compilerOptions": {
--- "module": "commonjs",
--- "target": "es6",
--- "checkJs": false
--- },
--- "exclude": [
--- "node_modules"
--- ]
--- }
--- ```
---@type vim.lsp.Config
return {
init_options = { hostInfo = 'neovim' },
cmd = { 'custom-elements-languageserver', '--stdio' },
root_markers = { 'tsconfig.json', 'package.json', 'jsconfig.json', '.git' },
}

18
lsp/cypher_ls.lua Normal file
View file

@ -0,0 +1,18 @@
---@brief
---
--- https://github.com/neo4j/cypher-language-support/tree/main/packages/language-server
---
--- `cypher-language-server`, language server for Cypher query language.
--- Part of the umbrella project cypher-language-support: https://github.com/neo4j/cypher-language-support
---
--- `cypher-language-server` can be installed via `npm`:
--- ```sh
--- npm i -g @neo4j-cypher/language-server
--- ```
---@type vim.lsp.Config
return {
cmd = { 'cypher-language-server', '--stdio' },
filetypes = { 'cypher' },
root_markers = { '.git' },
}

27
lsp/daedalus_ls.lua Normal file
View file

@ -0,0 +1,27 @@
--- @brief
---
--- DaedalusLanguageServer
---@type vim.lsp.Config
return {
cmd = { 'DaedalusLanguageServer' },
filetypes = { 'd' },
root_markers = {
'Gothic.src',
'Camera.src',
'Menu.src',
'Music.src',
'ParticleFX.src',
'SFX.src',
'VisualFX.src',
},
settings = {
DaedalusLanguageServer = {
loglevel = 'debug',
inlayHints = { constants = true },
numParserThreads = 16,
fileEncoding = 'Windows-1252',
srcFileEncoding = 'Windows-1252',
},
},
}

15
lsp/dafny.lua Normal file
View file

@ -0,0 +1,15 @@
---@brief
---
--- Support for the Dafny language server.
-- The default `cmd` uses "dafny server", which works on Dafny 4.0.0+. For
-- older versions of Dafny, you can compile the language server from source at
-- [dafny-lang/language-server-csharp](https://github.com/dafny-lang/language-server-csharp)
-- and set `cmd = {"dotnet", "<Path to your language server>"}`.
---@type vim.lsp.Config
return {
cmd = { 'dafny', 'server' },
filetypes = { 'dfy', 'dafny' },
root_markers = { '.git' },
}

12
lsp/dagger.lua Normal file
View file

@ -0,0 +1,12 @@
---@brief
---
--- https://github.com/dagger/cuelsp
---
--- Dagger's lsp server for cuelang.
---@type vim.lsp.Config
return {
cmd = { 'cuelsp' },
filetypes = { 'cue' },
root_markers = { 'cue.mod', '.git' },
}

25
lsp/dartls.lua Normal file
View file

@ -0,0 +1,25 @@
---@brief
---
--- https://github.com/dart-lang/sdk/tree/master/pkg/analysis_server/tool/lsp_spec
---
--- Language server for dart.
---@type vim.lsp.Config
return {
cmd = { 'dart', 'language-server', '--protocol=lsp' },
filetypes = { 'dart' },
root_markers = { 'pubspec.yaml' },
init_options = {
onlyAnalyzeProjectsWithOpenFiles = true,
suggestFromUnimportedLibraries = true,
closingLabels = true,
outline = true,
flutterOutline = true,
},
settings = {
dart = {
completeFunctionCalls = true,
showTodos = true,
},
},
}

12
lsp/dcmls.lua Normal file
View file

@ -0,0 +1,12 @@
---@brief
---
--- https://dcm.dev/
---
--- Language server for DCM analyzer.
---@type vim.lsp.Config
return {
cmd = { 'dcm', 'start-server', '--client=neovim' },
filetypes = { 'dart' },
root_markers = { 'pubspec.yaml' },
}

12
lsp/debputy.lua Normal file
View file

@ -0,0 +1,12 @@
---@brief
---
--- https://salsa.debian.org/debian/debputy
---
--- Language Server for Debian packages.
---@type vim.lsp.Config
return {
cmd = { 'debputy', 'lsp', 'server' },
filetypes = { 'debcontrol', 'debcopyright', 'debchangelog', 'autopkgtest', 'make', 'yaml' },
root_markers = { 'debian' },
}

111
lsp/denols.lua Normal file
View file

@ -0,0 +1,111 @@
---@brief
---
--- https://github.com/denoland/deno
---
--- Deno's built-in language server
---
--- To appropriately highlight codefences returned from denols, you will need to augment vim.g.markdown_fenced languages
--- in your init.lua. Example:
---
--- ```lua
--- vim.g.markdown_fenced_languages = {
--- "ts=typescript"
--- }
--- ```
local lsp = vim.lsp
local function virtual_text_document_handler(uri, res, client)
if not res then
return nil
end
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, false, lines)
vim.api.nvim_set_option_value('readonly', true, { buf = bufnr })
vim.api.nvim_set_option_value('modified', false, { buf = bufnr })
vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr })
lsp.buf_attach_client(bufnr, client.id)
end
local function virtual_text_document(uri, client)
local params = {
textDocument = {
uri = uri,
},
}
local result = client:request_sync('deno/virtualTextDocument', params)
virtual_text_document_handler(uri, result, client)
end
local function denols_handler(err, result, ctx, config)
if not result or vim.tbl_isempty(result) then
return nil
end
local client = vim.lsp.get_client_by_id(ctx.client_id)
for _, res in pairs(result) do
local uri = res.uri or res.targetUri
if uri:match '^deno:' then
virtual_text_document(uri, client)
res['uri'] = uri
res['targetUri'] = uri
end
end
lsp.handlers[ctx.method](err, result, ctx, config)
end
---@type vim.lsp.Config
return {
cmd = { 'deno', 'lsp' },
cmd_env = { NO_COLOR = true },
filetypes = {
'javascript',
'javascriptreact',
'javascript.jsx',
'typescript',
'typescriptreact',
'typescript.tsx',
},
root_markers = { 'deno.json', 'deno.jsonc', '.git' },
settings = {
deno = {
enable = true,
suggest = {
imports = {
hosts = {
['https://deno.land'] = true,
},
},
},
},
},
handlers = {
['textDocument/definition'] = denols_handler,
['textDocument/typeDefinition'] = denols_handler,
['textDocument/references'] = denols_handler,
},
on_attach = function(client, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, 'LspDenolsCache', function()
client:exec_cmd({
command = 'deno.cache',
arguments = { {}, vim.uri_from_bufnr(bufnr) },
}, { bufnr = bufnr }, function(err, _, ctx)
if err then
local uri = ctx.params.arguments[2]
vim.notify('cache command failed for' .. vim.uri_to_fname(uri), vim.log.levels.ERROR)
end
end)
end, {
desc = 'Cache a module and all of its dependencies.',
})
end,
}

18
lsp/dhall_lsp_server.lua Normal file
View file

@ -0,0 +1,18 @@
---@brief
---
--- 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).
---@type vim.lsp.Config
return {
cmd = { 'dhall-lsp-server' },
filetypes = { 'dhall' },
root_markers = { '.git' },
}

14
lsp/diagnosticls.lua Normal file
View file

@ -0,0 +1,14 @@
---@brief
---
--- https://github.com/iamcco/diagnostic-languageserver
---
--- Diagnostic language server integrate with linters.
---@type vim.lsp.Config
return {
-- Configuration from https://github.com/iamcco/diagnostic-languageserver#config--document
cmd = { 'diagnostic-languageserver', '--stdio' },
root_markers = { '.git' },
-- Empty by default, override to add filetypes.
filetypes = {},
}

16
lsp/digestif.lua Normal file
View file

@ -0,0 +1,16 @@
---@brief
---
--- https://github.com/astoff/digestif
---
--- Digestif is a code analyzer, and a language server, for LaTeX, ConTeXt et caterva. It provides
---
--- context-sensitive completion, documentation, code navigation, and related functionality to any
---
--- text editor that speaks the LSP protocol.
---@type vim.lsp.Config
return {
cmd = { 'digestif' },
filetypes = { 'tex', 'plaintex', 'context' },
root_markers = { '.git' },
}

13
lsp/djlsp.lua Normal file
View file

@ -0,0 +1,13 @@
---@brief
---
--- https://github.com/fourdigits/django-template-lsp
---
--- `djlsp`, a language server for Django templates.
---@type vim.lsp.Config
return {
cmd = { 'djlsp' },
filetypes = { 'html', 'htmldjango' },
root_markers = { '.git' },
settings = {},
}

View file

@ -0,0 +1,19 @@
---@brief
---
--- https://github.com/microsoft/compose-language-service
--- This project contains a language service for Docker Compose.
---
--- `compose-language-service` can be installed via `npm`:
---
--- ```sh
--- npm install @microsoft/compose-language-service
--- ```
---
--- Note: If the docker-compose-langserver doesn't startup when entering a `docker-compose.yaml` file, make sure that the filetype is `yaml.docker-compose`. You can set with: `:set filetype=yaml.docker-compose`.
---@type vim.lsp.Config
return {
cmd = { 'docker-compose-langserver', '--stdio' },
filetypes = { 'yaml.docker-compose' },
root_markers = { 'docker-compose.yaml', 'docker-compose.yml', 'compose.yaml', 'compose.yml' },
}

View file

@ -0,0 +1,32 @@
---@brief
---
--- https://github.com/docker/docker-language-server
---
--- `docker-langserver-server` can be installed via `go`:
--- ```sh
--- go install github.com/docker/docker-language-server/cmd/docker-language-server@latest
--- ```
---@type vim.lsp.Config
return {
cmd = { 'docker-language-server', 'start', '--stdio' },
filetypes = { 'dockerfile', 'yaml.docker-compose' },
get_language_id = function(_, ftype)
if ftype == 'yaml.docker-compose' or ftype:lower():find('ya?ml') then
return 'dockercompose'
else
return ftype
end
end,
root_markers = {
'Dockerfile',
'docker-compose.yaml',
'docker-compose.yml',
'compose.yaml',
'compose.yml',
'docker-bake.json',
'docker-bake.hcl',
'docker-bake.override.json',
'docker-bake.override.hcl',
},
}

30
lsp/dockerls.lua Normal file
View file

@ -0,0 +1,30 @@
---@brief
---
--- https://github.com/rcjsuen/dockerfile-language-server-nodejs
---
--- `docker-langserver` can be installed via `npm`:
--- ```sh
--- npm install -g dockerfile-language-server-nodejs
--- ```
---
--- Additional configuration can be applied in the following way:
--- ```lua
--- vim.lsp.config('dockerls', {
--- settings = {
--- docker = {
--- languageserver = {
--- formatter = {
--- ignoreMultilineInstructions = true,
--- },
--- },
--- }
--- }
--- })
--- ```
---@type vim.lsp.Config
return {
cmd = { 'docker-langserver', '--stdio' },
filetypes = { 'dockerfile' },
root_markers = { 'Dockerfile' },
}

15
lsp/dolmenls.lua Normal file
View file

@ -0,0 +1,15 @@
---@brief
---
--- https://github.com/Gbury/dolmen/blob/master/doc/lsp.md
---
--- `dolmenls` can be installed via `opam`
--- ```sh
--- opam install dolmen_lsp
--- ```
---@type vim.lsp.Config
return {
cmd = { 'dolmenls' },
filetypes = { 'smt2', 'tptp', 'p', 'cnf', 'icnf', 'zf' },
root_markers = { '.git' },
}

15
lsp/dotls.lua Normal file
View file

@ -0,0 +1,15 @@
---@brief
---
--- https://github.com/nikeee/dot-language-server
---
--- `dot-language-server` can be installed via `npm`:
--- ```sh
--- npm install -g dot-language-server
--- ```
---@type vim.lsp.Config
return {
cmd = { 'dot-language-server', '--stdio' },
filetypes = { 'dot' },
root_markers = { '.git' },
}

26
lsp/dprint.lua Normal file
View file

@ -0,0 +1,26 @@
---@brief
---
--- https://github.com/dprint/dprint
---
--- Pluggable and configurable code formatting platform written in Rust.
---@type vim.lsp.Config
return {
cmd = { 'dprint', 'lsp' },
filetypes = {
'javascript',
'javascriptreact',
'typescript',
'typescriptreact',
'json',
'jsonc',
'markdown',
'python',
'toml',
'rust',
'roslyn',
'graphql',
},
root_markers = { 'dprint.json', '.dprint.json', 'dprint.jsonc', '.dprint.jsonc' },
settings = {},
}

67
lsp/ds_pinyin_lsp.lua Normal file
View file

@ -0,0 +1,67 @@
---@brief
---
--- https://github.com/iamcco/ds-pinyin-lsp
--- Dead simple Pinyin language server for input Chinese without IME(input method).
--- To install, download the latest [release](https://github.com/iamcco/ds-pinyin-lsp/releases) and ensure `ds-pinyin-lsp` is on your path.
--- And make ensure the database file `dict.db3` is also downloaded. And put the path to `dict.dbs` in the following code.
---
--- ```lua
---
--- vim.lsp.config('ds_pinyin_lsp', {
--- init_options = {
--- db_path = "your_path_to_database"
--- }
--- })
---
--- ```
local bin_name = 'ds-pinyin-lsp'
if vim.fn.has 'win32' == 1 then
bin_name = bin_name .. '.exe'
end
local function ds_pinyin_lsp_off(bufnr)
local ds_pinyin_lsp_client = vim.lsp.get_clients({ bufnr = bufnr, name = 'ds_pinyin_lsp' })[1]
if ds_pinyin_lsp_client then
ds_pinyin_lsp_client:notify('$/turn/completion', {
['completion_on'] = false,
})
else
vim.notify 'notification $/turn/completion is not supported by any servers active on the current buffer'
end
end
local function ds_pinyin_lsp_on(bufnr)
local ds_pinyin_lsp_client = vim.lsp.get_clients({ bufnr = bufnr, name = 'ds_pinyin_lsp' })[1]
if ds_pinyin_lsp_client then
ds_pinyin_lsp_client:notify('$/turn/completion', {
['completion_on'] = true,
})
else
vim.notify 'notification $/turn/completion is not supported by any servers active on the current buffer'
end
end
---@type vim.lsp.Config
return {
cmd = { bin_name },
filetypes = { 'markdown', 'org' },
root_markers = { '.git' },
init_options = {
completion_on = true,
show_symbols = true,
show_symbols_only_follow_by_hanzi = false,
show_symbols_by_n_times = 0,
match_as_same_as_input = true,
match_long_input = true,
max_suggest = 15,
},
on_attach = function(_, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, 'LspDsPinyinCompletionOff', function()
ds_pinyin_lsp_off(bufnr)
end, { desc = 'Turn off the ds-pinyin-lsp completion' })
vim.api.nvim_buf_create_user_command(bufnr, 'LspDsPinyinCompletionOn', function()
ds_pinyin_lsp_on(bufnr)
end, { desc = 'Turn on the ds-pinyin-lsp completion' })
end,
}

22
lsp/dts_lsp.lua Normal file
View file

@ -0,0 +1,22 @@
---@brief
---
--- `dts-lsp` is an LSP for Devicetree files built on top of tree-sitter-devicetree grammar.
--- Language servers can be used in many editors, such as Visual Studio Code, Emacs
--- or Vim
---
--- Install `dts-lsp` from https://github.com/igor-prusov/dts-lsp and add it to path
---
--- `dts-lsp` doesn't require any configuration.
---
--- More about Devicetree:
--- https://www.devicetree.org/
--- https://docs.zephyrproject.org/latest/build/dts/index.html
---@type vim.lsp.Config
return {
name = 'dts_lsp',
cmd = { 'dts-lsp' },
filetypes = { 'dts', 'dtsi', 'overlay' },
root_markers = { '.git' },
settings = {},
}

12
lsp/earthlyls.lua Normal file
View file

@ -0,0 +1,12 @@
---@brief
---
--- https://github.com/glehmann/earthlyls
---
--- A fast language server for earthly.
---@type vim.lsp.Config
return {
cmd = { 'earthlyls' },
filetypes = { 'earthfile' },
root_markers = { 'Earthfile' },
}

15
lsp/ecsact.lua Normal file
View file

@ -0,0 +1,15 @@
---@brief
---
--- https://github.com/ecsact-dev/ecsact_lsp_server
---
--- Language server for Ecsact.
---
--- The default cmd assumes `ecsact_lsp_server` is in your PATH. Typically from the
--- Ecsact SDK: https://ecsact.dev/start
---@type vim.lsp.Config
return {
cmd = { 'ecsact_lsp_server', '--stdio' },
filetypes = { 'ecsact' },
root_markers = { '.git' },
}

25
lsp/efm.lua Normal file
View file

@ -0,0 +1,25 @@
--- @brief
---
--- 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.
---
--- 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 `vim.lsp.config`**. Otherwise the server will be launch on the `BufEnter` instead
--- of the `FileType` autocommand, and the `filetype` variable used to populate the `languageId` will not yet be set.
---
--- ```lua
--- vim.lsp.config('efm', {
--- filetypes = { 'python','cpp','lua' }
--- settings = ..., -- You must populate this according to the EFM readme
--- })
--- ```
---@type vim.lsp.Config
return {
cmd = { 'efm-langserver' },
root_markers = { '.git' },
}

46
lsp/elixirls.lua Normal file
View file

@ -0,0 +1,46 @@
---@brief
---
--- 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).
---
--- 1. Download the zip from https://github.com/elixir-lsp/elixir-ls/releases/latest/
--- 2. Unzip it and make it executable.
--- ```bash
--- 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
--- vim.lsp.config('elixirls', {
--- -- Unix
--- cmd = { "/path/to/elixir-ls/language_server.sh" };
--- -- Windows
--- cmd = { "/path/to/elixir-ls/language_server.bat" };
--- ...
--- })
--- ```
---
--- 'root_dir' is chosen like this: if two or more directories containing `mix.exs` were found when searching
--- directories upward, the second one (higher up) is chosen, with the assumption that it is the root of an umbrella
--- app. Otherwise the directory containing the single mix.exs that was found is chosen.
---@type vim.lsp.Config
return {
filetypes = { 'elixir', 'eelixir', 'heex', 'surface' },
root_dir = function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
--- Elixir workspaces may have multiple `mix.exs` files, for an "umbrella" layout or monorepo.
--- So we specify `limit=2` and treat the highest one (if any) as the root of an umbrella app.
local matches = vim.fs.find({ 'mix.exs' }, { upward = true, limit = 2, path = fname })
local child_or_root_path, maybe_umbrella_path = unpack(matches)
local root_dir = vim.fs.dirname(maybe_umbrella_path or child_or_root_path)
on_dir(root_dir)
end,
}

35
lsp/elmls.lua Normal file
View file

@ -0,0 +1,35 @@
---@brief
---
--- 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
--- ```
local api = vim.api
---@type vim.lsp.Config
return {
cmd = { 'elm-language-server' },
-- 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(bufnr, on_dir)
local fname = api.nvim_buf_get_name(bufnr)
local filetype = vim.bo[bufnr].filetype
if filetype == 'elm' or (filetype == 'json' and fname:match 'elm%.json$') then
on_dir(vim.fs.root(fname, 'elm.json'))
return
end
on_dir(nil)
end,
init_options = {
elmReviewDiagnostics = 'off', -- 'off' | 'warning' | 'error'
skipInstallPackageConfirmation = false,
disableElmLSDiagnostics = false,
onlyUpdateDiagnosticsOnSave = false,
},
capabilities = {
offsetEncoding = { 'utf-8', 'utf-16' },
},
}

13
lsp/elp.lua Normal file
View file

@ -0,0 +1,13 @@
---@brief
---
--- https://whatsapp.github.io/erlang-language-platform
---
--- ELP integrates Erlang into modern IDEs via the language server protocol and was
--- inspired by rust-analyzer.
---@type vim.lsp.Config
return {
cmd = { 'elp', 'server' },
filetypes = { 'erlang' },
root_markers = { 'rebar.config', 'erlang.mk', '.git' },
}

16
lsp/ember.lua Normal file
View file

@ -0,0 +1,16 @@
---@brief
---
--- https://github.com/ember-tooling/ember-language-server
---
--- `ember-language-server` can be installed via `npm`:
---
--- ```sh
--- npm install -g @ember-tooling/ember-language-server
--- ```
---@type vim.lsp.Config
return {
cmd = { 'ember-language-server', '--stdio' },
filetypes = { 'handlebars', 'typescript', 'javascript', 'typescript.glimmer', 'javascript.glimmer' },
root_markers = { 'ember-cli-build.js', '.git' },
}

View file

@ -0,0 +1,31 @@
---@brief
---
--- https://github.com/olrtg/emmet-language-server
---
--- Package can be installed via `npm`:
--- ```sh
--- npm install -g @olrtg/emmet-language-server
--- ```
---@type vim.lsp.Config
return {
cmd = { 'emmet-language-server', '--stdio' },
filetypes = {
'astro',
'css',
'eruby',
'html',
'htmlangular',
'htmldjango',
'javascriptreact',
'less',
'pug',
'sass',
'scss',
'svelte',
'templ',
'typescriptreact',
'vue',
},
root_markers = { '.git' },
}

31
lsp/emmet_ls.lua Normal file
View file

@ -0,0 +1,31 @@
---@brief
---
--- https://github.com/aca/emmet-ls
---
--- Package can be installed via `npm`:
--- ```sh
--- npm install -g emmet-ls
--- ```
---@type vim.lsp.Config
return {
cmd = { 'emmet-ls', '--stdio' },
filetypes = {
'astro',
'css',
'eruby',
'html',
'htmlangular',
'htmldjango',
'javascriptreact',
'less',
'pug',
'sass',
'scss',
'svelte',
'templ',
'typescriptreact',
'vue',
},
root_markers = { '.git' },
}

24
lsp/emmylua_ls.lua Normal file
View file

@ -0,0 +1,24 @@
---@brief
---
--- https://github.com/EmmyLuaLs/emmylua-analyzer-rust
---
--- Emmylua Analyzer Rust. Language Server for Lua.
---
--- `emmylua_ls` can be installed using `cargo` by following the instructions[here]
--- (https://github.com/EmmyLuaLs/emmylua-analyzer-rust?tab=readme-ov-file#install).
---
--- The default `cmd` assumes that the `emmylua_ls` binary can be found in `$PATH`.
--- It might require you to provide cargo binaries installation path in it.
---@type vim.lsp.Config
return {
cmd = { 'emmylua_ls' },
filetypes = { 'lua' },
root_markers = {
'.luarc.json',
'.emmyrc.json',
'.luacheckrc',
'.git',
},
workspace_required = false,
}

View file

@ -0,0 +1,19 @@
---@brief
---
--- https://github.com/erg-lang/erg#flags ELS
---
--- ELS (erg-language-server) is a language server for the Erg programming language.
---
--- erg-language-server can be installed via `cargo` and used as follows:
---
--- ```sh
--- cargo install erg --features els
--- erg --language-server
--- ```
---@type vim.lsp.Config
return {
cmd = { 'erg', '--language-server' },
filetypes = { 'erg' },
root_markers = { 'package.er', '.git' },
}

21
lsp/erlangls.lua Normal file
View file

@ -0,0 +1,21 @@
---@brief
---
--- 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)
---@type vim.lsp.Config
return {
cmd = { 'erlang_ls' },
filetypes = { 'erlang' },
root_markers = { 'rebar.config', 'erlang.mk', '.git' },
}

51
lsp/esbonio.lua Normal file
View file

@ -0,0 +1,51 @@
---@brief
---
--- 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
--- vim.lsp.config('esbonio', {
--- cmd = { '/path/to/virtualenv/bin/python', '-m', 'esbonio' }
--- })
--- ```
---
--- Esbonio supports a number of config values passed as `init_options` on startup, for example.
---
--- ```lua
--- vim.lsp.config('esbonio', {
--- 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://docs.esbon.io/en/esbonio-language-server-v0.16.4/lsp/getting-started.html?editor=neovim-lspconfig#configuration)
---@type vim.lsp.Config
return {
cmd = { 'python3', '-m', 'esbonio' },
filetypes = { 'rst' },
root_markers = { '.git' },
}

225
lsp/eslint.lua Normal file
View file

@ -0,0 +1,225 @@
--- @brief
---
--- https://github.com/hrsh7th/vscode-langservers-extracted
---
--- `vscode-eslint-language-server` is a linting engine for JavaScript / Typescript.
--- It can be installed via `npm`:
---
--- ```sh
--- npm i -g vscode-langservers-extracted
--- ```
---
--- The default `on_attach` config provides the `LspEslintFixAll` command that can be used to format a document on save:
--- ```lua
--- local base_on_attach = vim.lsp.config.eslint.on_attach
--- vim.lsp.config("eslint", {
--- on_attach = function(client, bufnr)
--- if not base_on_attach then return end
---
--- base_on_attach(client, bufnr)
--- vim.api.nvim_create_autocmd("BufWritePre", {
--- buffer = bufnr,
--- command = "LspEslintFixAll",
--- })
--- end,
--- })
--- ```
---
--- See [vscode-eslint](https://github.com/microsoft/vscode-eslint/blob/55871979d7af184bf09af491b6ea35ebd56822cf/server/src/eslintServer.ts#L216-L229) for configuration options.
---
--- Messages handled in lspconfig: `eslint/openDoc`, `eslint/confirmESLintExecution`, `eslint/probeFailed`, `eslint/noLibrary`
---
--- Additional messages you can handle: `eslint/noConfig`
---
--- ### Monorepo support
---
--- `vscode-eslint-language-server` supports monorepos by default. It will automatically find the config file corresponding to the package you are working on. You can use different configs in different packages.
--- This works without the need of spawning multiple instances of `vscode-eslint-language-server`.
--- You can use a different version of ESLint in each package, but it is recommended to use the same version of ESLint in all packages. The location of the ESLint binary will be determined automatically.
---
--- /!\ When using flat config files, you need to use them across all your packages in your monorepo, as it's a global setting for the server.
local util = require 'lspconfig.util'
local lsp = vim.lsp
local eslint_config_files = {
'.eslintrc',
'.eslintrc.js',
'.eslintrc.cjs',
'.eslintrc.yaml',
'.eslintrc.yml',
'.eslintrc.json',
'eslint.config.js',
'eslint.config.mjs',
'eslint.config.cjs',
'eslint.config.ts',
'eslint.config.mts',
'eslint.config.cts',
}
---@type vim.lsp.Config
return {
cmd = { 'vscode-eslint-language-server', '--stdio' },
filetypes = {
'javascript',
'javascriptreact',
'javascript.jsx',
'typescript',
'typescriptreact',
'typescript.tsx',
'vue',
'svelte',
'astro',
'htmlangular',
},
workspace_required = true,
on_attach = function(client, bufnr)
vim.api.nvim_buf_create_user_command(0, 'LspEslintFixAll', function()
client:request_sync('workspace/executeCommand', {
command = 'eslint.applyAllFixes',
arguments = {
{
uri = vim.uri_from_bufnr(bufnr),
version = lsp.util.buf_versions[bufnr],
},
},
}, nil, bufnr)
end, {})
end,
root_dir = function(bufnr, on_dir)
-- The project root is where the LSP can be started from
-- As stated in the documentation above, this LSP supports monorepos and simple projects.
-- We select then from the project root, which is identified by the presence of a package
-- manager lock file.
local root_markers = { 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb', 'bun.lock' }
-- Give the root markers equal priority by wrapping them in a table
root_markers = vim.fn.has('nvim-0.11.3') == 1 and { root_markers, { '.git' } }
or vim.list_extend(root_markers, { '.git' })
-- We fallback to the current working directory if no project root is found
local project_root = vim.fs.root(bufnr, root_markers) or vim.fn.getcwd()
-- We know that the buffer is using ESLint if it has a config file
-- in its directory tree.
--
-- Eslint used to support package.json files as config files, but it doesn't anymore.
-- We keep this for backward compatibility.
local filename = vim.api.nvim_buf_get_name(bufnr)
local eslint_config_files_with_package_json =
util.insert_package_json(eslint_config_files, 'eslintConfig', filename)
local is_buffer_using_eslint = vim.fs.find(eslint_config_files_with_package_json, {
path = filename,
type = 'file',
limit = 1,
upward = true,
stop = vim.fs.dirname(project_root),
})[1]
if not is_buffer_using_eslint then
return
end
on_dir(project_root)
end,
-- Refer to https://github.com/Microsoft/vscode-eslint#settings-options for documentation.
settings = {
validate = 'on',
packageManager = nil,
useESLintClass = false,
experimental = {
useFlatConfig = false,
},
codeActionOnSave = {
enable = false,
mode = 'all',
},
format = true,
quiet = false,
onIgnoredFiles = 'off',
rulesCustomizations = {},
run = 'onType',
problems = {
shortenToSingleLine = false,
},
-- 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 = 'auto' },
codeAction = {
disableRuleComment = {
enable = true,
location = 'separateLine',
},
showDocumentation = {
enable = true,
},
},
},
before_init = function(_, config)
-- 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).
local root_dir = config.root_dir
if root_dir then
config.settings = config.settings or {}
config.settings.workspaceFolder = {
uri = root_dir,
name = vim.fn.fnamemodify(root_dir, ':t'),
}
-- Support flat config files
-- They contain 'config' in the file name
local flat_config_files = vim.tbl_filter(function(file)
return file:match('config')
end, eslint_config_files)
for _, file in ipairs(flat_config_files) do
local found_files = vim.fn.globpath(root_dir, file, true, true)
-- Filter out files inside node_modules
local filtered_files = {}
for _, found_file in ipairs(found_files) do
if string.find(found_file, '[/\\]node_modules[/\\]') == nil then
table.insert(filtered_files, found_file)
end
end
if #filtered_files > 0 then
config.settings.experimental = config.settings.experimental or {}
config.settings.experimental.useFlatConfig = true
break
end
end
-- Support Yarn2 (PnP) projects
local pnp_cjs = root_dir .. '/.pnp.cjs'
local pnp_js = root_dir .. '/.pnp.js'
if vim.uv.fs_stat(pnp_cjs) or vim.uv.fs_stat(pnp_js) then
local cmd = config.cmd
config.cmd = vim.list_extend({ 'yarn', 'exec' }, cmd)
end
end
end,
handlers = {
['eslint/openDoc'] = function(_, result)
if result then
vim.ui.open(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,
},
}

26
lsp/expert.lua Normal file
View file

@ -0,0 +1,26 @@
---@brief
---
--- https://github.com/elixir-lang/expert
---
--- Expert is the official language server implementation for the Elixir programming language.
---
--- 'root_dir' is chosen like this: if two or more directories containing `mix.exs` were found when
--- searching directories upward, the second one (higher up) is chosen, with the assumption that it
--- is the root of an umbrella app. Otherwise the directory containing the single mix.exs that was
--- found is chosen.
---@type vim.lsp.Config
return {
filetypes = { 'elixir', 'eelixir', 'heex', 'surface' },
cmd = { 'expert' },
root_dir = function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
--- Elixir workspaces may have multiple `mix.exs` files, for an "umbrella" layout or monorepo.
--- So we specify `limit=2` and treat the highest one (if any) as the root of an umbrella app.
local matches = vim.fs.find({ 'mix.exs' }, { upward = true, limit = 2, path = fname })
local child_or_root_path, maybe_umbrella_path = unpack(matches)
local root_dir = vim.fs.dirname(maybe_umbrella_path or child_or_root_path)
on_dir(root_dir)
end,
}

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