blob: 4e8e6d774669551f3dc070fa47cefc92c1522d56 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
<p align="center">
<img src="https://user-images.githubusercontent.com/6705160/118490159-f064bb00-b71d-11eb-883e-4affbd020074.png" alt="nvim-lsp-installer" width="60%" />
</p>
## About
Semi-opinionated companion plugin for [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig).
It comes with all batteries included, or at least to the extent possible. On top of just providing commands for
installing & uninsalling LSP servers, it:
- provides configurations for servers that aren't supported by nvim-lspconfig (`eslint`)
- provides extra APIs for non-standard LSP functionalities, for example `_typescript.applyRenameFile`
- has support for a variety of different install methods (primarily [google/zx](https://github.com/google/zx))
- provides adapters that offer out-of-box integrations with other plugins
- managed versioning of installed servers (future)
Inspired by [nvim-lspinstall](https://github.com/kabouzeid/nvim-lspinstall).
## Installation
Some install scripts are written in [google/zx](https://github.com/google/zx) and will require a [Node.js LTS](https://nodejs.org/) runtime to be installed.
### vim-plug
```vim
Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/nvim-lsp-installer'
```
### [Packer](https://github.com/wbthomason/packer.nvim)
```lua
use {
'neovim/nvim-lsp-config',
'williamboman/nvim-lsp-installer',
}
```
## Usage
### Commands
- `:LspInstall <language>` - installs/reinstalls a language server
- `:LspUninstall <language>` - uninstalls a language server
- `:LspUninstallAll` - uninstalls all language servers
- `:LspPrintInstalled` - prints all installed language servers
### Setup
```lua
local lsp_installer = require'nvim-lsp-installer'
function common_on_attach(client, bufnr)
-- setup buffer keymaps etc.
end
local installed_servers = lsp_installer.get_installed_servers()
for _, server in pairs(installed_servers) do
opts = {
on_attach = common_on_attach,
}
-- (optional) Customize the options passed to the server
-- if server.name == "tsserver" then
-- opts.root_dir = function() ... end
-- end
server:setup(opts)
end
```
## Available LSPs
- angularls
- bashls
- clangd
- clojure_lsp
- cmake
- cssls
- denols
- dockerls
- elixirls
- elmls
- eslintls
- gopls
- graphql
- html
- jsonls
- omnisharp (csharp)
- pyright
- rust_analyzer
- solargraph (ruby)
- sumneko_lua
- texlab
- tsserver
- vimls
- vuels
- yamlls
## Extras
### tsserver
The `tsserver` language server comes with the following extras:
- `rename_file(old, new)` Tells the language server that a file was renamed. Useful when refactoring. Refer to the [adapters section](#adapters) to find plugin integrations that automatically executes this for you.
Usage:
```lua
require'nvim-lsp-installer.extras.tsserver'.rename_file(old, new)
```
- `organize_imports(bufname)` Organizes the imports of a file. `bufname` is optional, will default to current buffer.
Usage:
```lua
require'nvim-lsp-installer.extras.tsserver'.organize_imports(bufname)
```
## Adapters
Make sure to only attempt connecting adapters once the plugin(s) involved have been loaded.
### [kyazdani42/nvim-tree.lua](https://github.com/kyazdani42/nvim-tree.lua)
```lua
require'nvim-lsp-installer.adapters.nvim-tree'.connect()
```
Supported capabilities:
- `_typescript.applyRenameFile`. Automatically executes the rename file client request when renaming a node.
## Logo
Illustrations in the logo are derived from [@Kaligule](https://schauderbasis.de/)'s "Robots" collection.
|