-
Notifications
You must be signed in to change notification settings - Fork 59
Home
Language Server Specific Configuration
Information about using various language servers with the LSP plugin is below. A sample VimScript code snippet is given for each language server to register the server with the LSP plugin. A sample absolute path to the language server executable is used in these examples. You may need to modify the path to match where the language server is installed in your system. In some cases, it may be simpler to add the language server path to the PATH environment variable.
Language: Angular Templates
Home Page: https://github.com/angular/vscode-ng-language-service
Sample code to add the angular language server to the LSP plugin:
call LspAddServer([#{name: 'angular',
\ filetype: 'html',
\ path: '/usr/local/bin/ngserver.cmd',
\ args: ['--stdio', '--ngProbeLocations', '/usr/local/bin/@angular/language-service', '--tsProbeLocations', '/usr/local/bin/typescript']
\ }])
Command to install the angular language server on Linux:
npm install -g @angular/language-server @angular/language-service typescript
Language: AWK scripts
Home Page: https://github.com/Beaglefoot/awk-language-server
Sample code to add the awk language server to the LSP plugin:
" Awk
call LspAddServer([#{name: 'awkls',
\ filetype: 'awk',
\ path: '/usr/local/bin/awk-language-server',
\ args: []
\ }])
Command to install the awk language server on Linux:
npm install -g awk-language-server
Language: Bash shell scripts
Home Page: https://github.com/bash-lsp/bash-language-server
Sample code to add the bash language server to the LSP plugin:
" Bash
call LspAddServer([#{name: 'bashls',
\ filetype: 'sh',
\ path: '/usr/local/bin/bash-language-server',
\ args: ['start']
\ }])
Language: C/C++
Home Page: https://clangd.llvm.org/
Sample code to add the clangd language server to the LSP plugin:
call LspAddServer([#{name: 'clangd',
\ filetype: ['c', 'cpp'],
\ path: '/usr/local/bin/clangd',
\ args: ['--background-index', '--clang-tidy']
\ }])
Language: CSS
Home Page: https://github.com/vscode-langservers/vscode-css-languageserver-bin
Sample code to add the CSS language server to the LSP plugin:
call LspAddServer([#{name: 'cssls',
\ filetype: 'css',
\ path: '/usr/local/node_modules/.bin/css-languageserver',
\ args: ['--stdio'],
\ }])
Note: The CSS language server supports code completion only if the snippetSupport option is enabled.
Language: Dart
Home Page: https://github.com/dart-lang/sdk/blob/main/pkg/analysis_server/tool/lsp_spec/README.md
Sample code to add the dart language server to the LSP plugin:
call LspAddServer([#{name: 'dart',
\ filetype: ['dart'],
\ path: '/usr/lib/dart/bin/dart',
\ args: ['language-server', '--client-id', 'vim']
\ }])
Language: Typescript/Javascript
Home Page: https://deno.land
Sample code to add the deno language server to the LSP plugin:
call LspAddServer([#{name: 'deno',
\ filetype: ['javascript', 'typescript'],
\ path: '/usr/local/bin/deno',
\ args: ['lsp'],
\ debug: v:true,
\ initializationOptions: #{
\ enable: v:true,
\ lint: v:true
\ }
\ }])
Language: Java
Home Page: https://github.com/eclipse/eclipse.jdt.ls
Sample code to add the Eclipse Java Development Tools (JDT) language server to the LSP plugin:
call LspAddServer([#{name: 'jdtls',
\ filetype: 'java',
\ path: '/usr/local/jdtls/bin/jdtls',
\ args: []
\ initializationOptions: {
\ settings: {
\ java: {
\ completion: {
\ filteredTypes: ["com.sun.*", "java.awt.*", "jdk.*", "org.graalvm.*", "sun.*", "javax.awt.*", "javax.swing.*"],
\ },
\ },
\ },
\ },
\ }])
The Eclipse Java language server wiki page has more information about the jdtls language server initialization options. In the above example, the filteredTypes
item is not mandatory to use the JDT language server with the LSP plugin. It is included here only as an example.
Language: General Purpose Language Server
Home Page: https://github.com/mattn/efm-langserver
Sample code to add the efm language server to the LSP plugin:
call LspAddServer([#{name: 'efm-langserver',
\ filetype: ['javascript', 'typescript'],
\ path: '/usr/local/bin/efm-langserver',
\ args: [],
\ initializationOptions: #{
\ documentFormatting: v:true
\ },
\ workspaceConfig: #{
\ languages: #{
\ javascript: [
\ #{
\ lintCommand: "eslint -f unix --stdin --stdin-filename ${INPUT}",
\ lintStdin: v:true,
\ lintFormats: ["%f:%l:%c: %m"],
\ formatCommand: "eslint --fix-to-stdout --stdin --stdin-filename=${INPUT}",
\ formatStdin: v:true
\ }
\ ],
\ typescript: [
\ #{
\ lintCommand: "eslint -f unix --stdin --stdin-filename ${INPUT}",
\ lintStdin: v:true,
\ lintFormats: ["%f:%l:%c: %m"],
\ formatCommand: "eslint --fix-to-stdout --stdin --stdin-filename=${INPUT}",
\ formatStdin: v:true
\ }
\ ]
\ }
\ }
\ }])
Language: HTML
Home Page: https://github.com/olrtg/emmet-language-server
Sample code to add the emmet language server to the LSP plugin:
call LspAddServer([#{name: 'emmet',
\ filetype: 'html',
\ path: '/usr/local/node_modules/.bin/emmet-language-server',
\ args: ['--stdio'],
\ }])
Command to install the emmet language server on Linux:
npm install -g @olrtg/emmet-language-server
Language: Fortran
Home Page: https://github.com/hansec/fortran-language-server
Sample code to add the fortran language server to the LSP plugin:
call LspAddServer([#{name: 'fortls',
\ filetype: 'fortran',
\ path: '/usr/local/bin/fortls',
\ args: ['--use_signature_help', '--hover_signature']
\ }])
Language: Go
Home Page: https://github.com/golang/tools/tree/master/gopls
Sample code to add the gopls language server to the LSP plugin:
call LspAddServer([#{name: 'gopls',
\ filetype: 'go',
\ path: '/usr/local/bin/gopls',
\ args: ['serve']
\ }])
Server Configuration: https://github.com/golang/tools/blob/master/gopls/doc/settings.md
To enable the inlay hint support, include the following in the above code to add the gopls language server:
\ workspaceConfig: #{
\ gopls: #{
\ hints: #{
\ assignVariableTypes: v:true,
\ compositeLiteralFields: v:true,
\ compositeLiteralTypes: v:true,
\ constantValues: v:true,
\ functionTypeParameters: v:true,
\ parameterNames: v:true,
\ rangeVariableTypes: v:true
\ }
\ }
\ }
Language: html
Home Page: https://github.com/vscode-langservers/vscode-html-languageserver-bin
Sample code to add the HTML language server to the LSP plugin:
call LspAddServer([#{name: 'htmlls',
\ filetype: 'html',
\ path: '/usr/local/node_modules/.bin/html-languageserver',
\ args: ['--stdio'],
\ }])
Note: The HTML language server supports code completion only if the snippetSupport option is enabled.
Language: Lua
Home Page: https://github.com/LuaLS/lua-language-server
Sample code to add the luals language server to the LSP plugin:
call LspAddServer([#{name: 'luals',
\ filetype: 'lua',
\ path: '/usr/local/luals/bin/lua-language-server',
\ args: [],
\ }])
Server Configuration: https://github.com/LuaLS/lua-language-server/wiki/Settings
To enable the inlay hint support, include the following in the above code to add the Lua language server:
\ workspaceConfig: #{
\ Lua: #{
\ hint: #{
\ enable: v:true,
\ }
\ }
\ }
Language: C#
Home Page: https://github.com/OmniSharp/omnisharp-roslyn
Sample code to add the omnisharp language server to the LSP plugin:
call LspAddServer([#{name: 'omnisharp',
\ filetype: 'cs',
\ path: expand('$HOME/omnisharp/omnisharp.exe'),
\ args: ['-z', '--languageserver', '--encoding', 'utf-8'],
\ }])
Language: Perl
Home Page: https://github.com/bscan/PerlNavigator
Sample code to add the Perl Navigator language server to the LSP plugin:
call LspAddServer([#{name: 'perlnavigator',
\ filetype: ['perl'],
\ path: '/usr/bin/node',
\ args: ['/usr/local/PerlNavigator/server/out/server.js', '--stdio']
\ }])
Language: PHP
Home Page: https://github.com/bmewburn/vscode-intelephense
Sample code to add the intelephense language server to the LSP plugin:
call LspAddServer([#{name: 'intelephense',
\ filetype: ['php'],
\ path: '/usr/local/bin/intelephense',
\ args: ['--stdio']
\ }])
Language: Python
Home Page: https://github.com/python-lsp/python-lsp-server
Sample code to add the pylsp language server to the LSP plugin:
call LspAddServer([#{name: 'pylsp',
\ filetype: 'python',
\ path: '/usr/local/bin/pylsp',
\ args: []
\ }])
Language: Python
Home Page: https://github.com/microsoft/pyright
Sample code to add the pyright language server to the LSP plugin:
call LspAddServer([#{name: 'pyright',
\ filetype: 'python',
\ path: '/usr/local/node_modules/.bin/pyright-langserver',
\ args: ['--stdio'],
\ workspaceConfig: #{
\ python: #{
\ pythonPath: '/usr/bin/python3.10'
\ }}
\ }])
Command to install the pyright language server on Linux:
$ npm install -g pyright
Server Configuration: https://microsoft.github.io/pyright/#/configuration
Language: Rust
Home Page: https://rust-analyzer.github.io/
Sample code to add the rust-analyzer language server to the LSP plugin:
call LspAddServer([#{name: 'rustanalyzer',
\ filetype: ['rust'],
\ path: '/usr/local/bin/rust-analyzer-x86_64-unknown-linux-gnu',
\ args: [],
\ syncInit: v:true
\ }])
Server Configuration: https://rust-analyzer.github.io/manual.html#configuration
To enable the inlay hint support, include the following in the above code to add the rust-analyzer language server:
\ initializationOptions: #{
\ inlayHints: #{
\ typeHints: #{
\ enable: v:true
\ },
\ parameterHints: #{
\ enable: v:true
\ }
\ },
\ }
Language: Ruby
Home Page: https://solargraph.org/
Sample code to add the Solargraph language server to the LSP plugin:
call LspAddServer([#{name: 'solargraph'
\ filetype: ['ruby'],
\ path: 'solargraph',
\ args: ['stdio']
\ }])
Language: Swift
Home Page: https://github.com/apple/sourcekit-lsp
Sample code to add the swift language server to the LSP plugin:
call LspAddServer([#{name: 'swiftls'
\ filetype: ['swift'],
\ path: '/usr/bin/xcrun',
\ args: ['sourcekit-lsp']
\ }])
Language: Typescript/JavaScript
Home Page: https://github.com/typescript-language-server/typescript-language-server
Sample code to add the typescript/javascript language server to the LSP plugin:
call LspAddServer([#{name: 'tsserver'
\ filetype: ['javascript', 'typescript'],
\ path: '/usr/local/bin/typescript-language-server',
\ args: ['stdio']
\ }])
Language: Vimscript
Home Page: https://github.com/iamcco/vim-language-server
Sample code to add the Vimscript language server to the LSP plugin:
call LspAddServer([#{name: 'vimls',
\ filetype: 'vim',
\ path: '/usr/local/bin/vim-language-server',
\ args: ['--stdio']
\ }])
Language: Vue
Home Page: https://github.com/vuejs/language-tools
Sample code to add the Volar language server to the LSP plugin:
call LspAddServer([#{name: 'volar-server',
\ filetype: ['vue', 'typescript'],
\ path: '/usr/local/node_modules/.bin/volar-server',
\ args: ['--stdio'],
\ initializationOptions: #{
\ typescript: #{
\ tsdk: '/usr/local/node_modules/typescript/lib'
\ }
\ }
\ }])
For Volar 2:
call LspAddServer([#{name: 'vue-ls',
\ filetype: ['vue'],
\ path: 'vue-language-server',
\ args: ['--stdio'],
\ initializationOptions: #{
\ typescript: #{
\ tsdk: '/usr/local/node_modules/typescript/lib'
\ }
\ vue: #{
\ hybridMode: false
\ }
\ }
\ }])
Note: The hybridMode
item in initializationOptions
is needed if you are using version >= 2.0.7.
Language: CSS
Home Page: https://github.com/hrsh7th/vscode-langservers-extracted
Sample code to add the VS Code CSS language server to the LSP plugin:
call LspAddServer([#{name: 'vscode-css-server',
\ filetype: ['css'],
\ path: '/usr/local/node_modules/.bin/vscode-css-language-server',
\ args: ['--stdio'],
\ }])
Language: Javascript
Home Page: https://github.com/hrsh7th/vscode-langservers-extracted
Sample code to add the VS Code ESLint language server to the LSP plugin:
call LspAddServer([#{name: 'vscode-eslint-server',
\ filetype: ['javascript'],
\ path: '/usr/local/node_modules/.bin/vscode-eslint-language-server',
\ args: ['--stdio'],
\ }])
Language: HTML
Home Page: https://github.com/hrsh7th/vscode-langservers-extracted
Sample code to add the VS Code HTML language server to the LSP plugin:
call LspAddServer([#{name: 'vscode-html-server',
\ filetype: ['html'],
\ path: '/usr/local/node_modules/.bin/vscode-html-language-server',
\ args: ['--stdio'],
\ }])
Language: JSON
Home Page: https://github.com/hrsh7th/vscode-langservers-extracted
Sample code to add the VS Code JSON language server to the LSP plugin:
call LspAddServer([#{name: 'vscode-json-server',
\ filetype: ['json'],
\ path: '/usr/local/node_modules/.bin/vscode-json-language-server',
\ args: ['--stdio'],
\ }])
Language: markdown
Home Page: https://github.com/hrsh7th/vscode-langservers-extracted
Sample code to add the VS Code Markdown language server to the LSP plugin:
call LspAddServer([#{name: 'vscode-markdown-server',
\ filetype: ['markdown'],
\ path: '/usr/local/node_modules/.bin/vscode-markdown-language-server',
\ args: ['--stdio'],
\ }])