aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: 74a2f17c587d81f2884bacd68ba6cde491c188e8 (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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<p align="center">
  <img src="https://user-images.githubusercontent.com/6705160/118490159-f064bb00-b71d-11eb-883e-4affbd020074.png" alt="nvim-lsp-installer" width="50%" />
</p>

-   [About](#about)
-   [Screenshots](#screenshots)
-   [Installation](#installation)
    -   [Packer](#packer)
    -   [vim-plug](#vim-plug)
-   [Usage](#usage)
    -   [Commands](#commands)
    -   [Setup](#setup)
    -   [Configuration](#configuration)
-   [Available LSPs](#available-lsps)
-   [Custom servers](#custom-servers)
-   [Logo](#logo)
-   [Roadmap](#roadmap)
-   [Default configuration](#default-configuration)

## About

Companion plugin for [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) that allows you to seamlessly install
LSP servers locally (inside `:echo stdpath("data")`).

On top of just providing commands for installing & uninstalling LSP servers, it:

-   provides a graphical UI
-   is optimized for blazing fast startup times
-   provides the ability to check for new server versions
-   supports installing custom versions of LSP servers (for example `:LspInstall rust_analyzer@nightly`)
-   relaxes the minimum requirements by attempting multiple different utilities (for example, only one of `wget`, `curl`, or `Invoke-WebRequest` is required for HTTP requests)
-   allows you to install and setup servers without having to restart neovim
-   hosts [a suite of system tests](https://github.com/williamboman/nvim-lspconfig-test) for all supported servers
-   has full support for Windows <img src="https://user-images.githubusercontent.com/6705160/131256603-cacf7f66-dfa9-4515-8ae4-0e42d08cfc6a.png" height="20">

## Screenshots

|                                                                                                                    |                                                                                                                    |                                                                                                                    |
| :----------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------: |
| <img src="https://user-images.githubusercontent.com/6705160/150685720-782e33ba-172c-44b6-8558-fb4e98495294.png" /> | <img src="https://user-images.githubusercontent.com/6705160/150685404-2cd34b25-166e-4c84-b9dd-1d5580dc2bdd.png" /> | <img src="https://user-images.githubusercontent.com/6705160/150685322-a537f021-5850-4bbc-8be2-1ece5678d205.png" /> |
| <img src="https://user-images.githubusercontent.com/6705160/150685324-1310ae7d-67bf-4053-872c-d27e8a4c4b80.png" /> | <img src="https://user-images.githubusercontent.com/6705160/150686052-fd5c4d54-b4da-4cb3-bb82-a094526ee5b5.png" /> | <img src="https://user-images.githubusercontent.com/6705160/150686059-f1be8131-1274-4f62-9aa8-345599cbd8bc.png" /> |

## Installation

Requires neovim `>= 0.6.0` and [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig). The _full requirements_ to
install _all_ servers are:

-   For Unix systems: git(1), curl(1) or wget(1), unzip(1), tar(1), gzip(1)
-   For Windows systems: powershell, git, tar, and [7zip][7zip] or [peazip][peazip] or [archiver][archiver] or [winzip][winzip]
-   Node.js (LTS) & npm
-   Python3 & pip3
-   go >= 1.17
-   JDK
-   Ruby & gem
-   PHP & Composer
-   dotnet
-   pwsh
-   Julia
-   valac (and meson & ninja)
-   rebar3

[7zip]: https://www.7-zip.org/
[archiver]: https://github.com/mholt/archiver
[peazip]: https://peazip.github.io/
[winzip]: https://www.winzip.com/

### [Packer](https://github.com/wbthomason/packer.nvim)

```lua
use {
    'neovim/nvim-lspconfig',
    'williamboman/nvim-lsp-installer',
}
```

### vim-plug

```vim
Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/nvim-lsp-installer'
```

## Usage

### Commands

-   `:LspInstallInfo` - opens a graphical overview of your language servers
-   `:LspInstall [--sync] [server] ...` - installs/reinstalls language servers. Runs in a blocking fashion if the `--sync` argument is passed (only recommended for scripting purposes).
-   `:LspUninstall [--sync] <server> ...` - uninstalls language servers. Runs in a blocking fashion if the `--sync` argument is passed (only recommended for scripting purposes).
-   `:LspUninstallAll [--no-confirm]` - uninstalls all language servers
-   `:LspInstallLog` - opens the log file in a new tab window
-   `:LspPrintInstalled` - prints all installed language servers

### Setup

The recommended way of setting up your installed servers is to do it directly through nvim-lsp-installer.
By doing so, nvim-lsp-installer will make sure to inject any necessary properties before calling lspconfig's setup
function for you. You may find a minimal example below. To see how you can override the default settings for a server,
refer to the [Wiki][overriding-default-settings].

[overriding-default-settings]: https://github.com/williamboman/nvim-lsp-installer/wiki/Advanced-Configuration#overriding-the-default-lsp-server-options

```lua
local lsp_installer = require("nvim-lsp-installer")

-- Register a handler that will be called for each installed server when it's ready (i.e. when installation is finished
-- or if the server is already installed).
lsp_installer.on_server_ready(function(server)
    local opts = {}

    -- (optional) Customize the options passed to the server
    -- if server.name == "tsserver" then
    --     opts.root_dir = function() ... end
    -- end

    -- This setup() function will take the provided server configuration and decorate it with the necessary properties
    -- before passing it onwards to lspconfig.
    -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
    server:setup(opts)
end)
```

For more advanced use cases you may also interact with more APIs nvim-lsp-installer has to offer, for example the
following (refer to `:help nvim-lsp-installer` for more docs).

```lua
local lsp_installer_servers = require('nvim-lsp-installer.servers')

local servers = {
    "rust_analyzer",
    "clangd",
    "pyright",
}

-- Loop through the servers listed above.
for _, server_name in pairs(servers) do
    local server_available, server = lsp_installer_servers.get_server(server_name)
    if server_available then
        server:on_ready(function ()
            -- When this particular server is ready (i.e. when installation is finished or the server is already installed),
            -- this function will be invoked. Make sure not to use the "catch-all" lsp_installer.on_server_ready()
            -- function to set up servers, to avoid doing setting up a server twice.
            local opts = {}
            server:setup(opts)
        end)
        if not server:is_installed() then
            -- Queue the server to be installed.
            server:install()
        end
    end
end
```

### Configuration

You can configure certain behavior of nvim-lsp-installer by calling the `.settings()` function.

_Make sure to provide your settings before any other interactions with nvim-lsp-installer!_

Refer to the [default configuration](#default-configuration) for all available settings.

Example:

```lua
local lsp_installer = require("nvim-lsp-installer")

lsp_installer.settings({
    ui = {
        icons = {
            server_installed = "✓",
            server_pending = "➜",
            server_uninstalled = "✗"
        }
    }
})
```

## Available LSPs

| Language                            | Server name                |
| ----------------------------------- | -------------------------- |
| AWK                                 | `awk_ls`                   |
| Angular                             | `angularls`                |
| Ansible                             | `ansiblels`                |
| Arduino [(docs!!!)][arduino]        | `arduino_language_server`  |
| Assembly (GAS/NASM, GO)             | `asm_lsp`                  |
| AsyncAPI                            | `spectral`                 |
| Bash                                | `bashls`                   |
| Beancount                           | `beancount`                |
| Bicep                               | `bicep`                    |
| C                                   | `ccls`                     |
| C                                   | `clangd`                   |
| C#                                  | `csharp_ls`                |
| C#                                  | `omnisharp`                |
| C++                                 | `ccls`                     |
| C++                                 | `clangd`                   |
| CMake                               | `cmake`                    |
| CSS                                 | `cssls`                    |
| CSS                                 | `cssmodules_ls`            |
| Clojure                             | `clojure_lsp`              |
| CodeQL                              | `codeqlls`                 |
| Crystal                             | `crystalline`              |
| Cucumber                            | `cucumber_language_server` |
| Dart                                | `dartls`                   |
| Deno                                | `denols`                   |
| Diagnostic (general purpose server) | `diagnosticls`             |
| Dlang                               | `serve_d`                  |
| Docker                              | `dockerls`                 |
| Dot                                 | `dotls`                    |
| EFM (general purpose server)        | `efm`                      |
| ESLint [(docs)][eslint]             | `eslint`                   |
| Elixir                              | `elixirls`                 |
| Elm                                 | `elmls`                    |
| Ember                               | `ember`                    |
| Emmet                               | `emmet_ls`                 |
| Erlang                              | `erlangls`                 |
| F#                                  | `fsautocomplete`           |
| Foam (OpenFOAM)                     | `foam_ls`                  |
| Fortran                             | `fortls`                   |
| Go                                  | `golangci_lint_ls`         |
| Go                                  | `gopls`                    |
| Grammarly                           | `grammarly`                |
| GraphQL                             | `graphql`                  |
| Groovy                              | `groovyls`                 |
| HTML                                | `html`                     |
| Haskell                             | `hls`                      |
| JSON                                | `jsonls`                   |
| Java                                | `jdtls`                    |
| JavaScript                          | `quick_lint_js`            |
| JavaScript                          | `tsserver`                 |
| Jsonnet                             | `jsonnet_ls`               |
| Julia                               | `julials`                  |
| Kotlin                              | `kotlin_language_server`   |
| LaTeX                               | `ltex`                     |
| LaTeX                               | `texlab`                   |
| Lelwel                              | `lelwel_ls`                |
| Lua                                 | `sumneko_lua`              |
| Markdown                            | `remark_ls`                |
| Markdown                            | `zeta_note`                |
| Markdown                            | `zk`                       |
| Nickel                              | `nickel_ls`                |
| Nim                                 | `nimls`                    |
| OCaml                               | `ocamlls`                  |
| Objective C                         | `ccls`                     |
| OneScript, 1C:Enterprise            | `bsl_ls`                   |
| OpenAPI                             | `spectral`                 |
| OpenCL                              | `opencl_ls`                |
| PHP                                 | `intelephense`             |
| PHP                                 | `phpactor`                 |
| PHP                                 | `psalm`                    |
| Powershell                          | `powershell_es`            |
| Prisma                              | `prismals`                 |
| Puppet                              | `puppet`                   |
| PureScript                          | `purescriptls`             |
| Python                              | `jedi_language_server`     |
| Python                              | `pyright`                  |
| Python [(docs)][pylsp]              | `pylsp`                    |
| ReScript                            | `rescriptls`               |
| Rome                                | `rome`                     |
| Ruby                                | `solargraph`               |
| Ruby                                | `typeprof`                 |
| Rust [(wiki)][rust_analyzer]        | `rust_analyzer`            |
| SQL                                 | `sqlls`                    |
| SQL                                 | `sqls`                     |
| Shopify Theme Check                 | `theme_check`              |
| Solidity                            | `solang`                   |
| Solidity                            | `solc`                     |
| Solidity (VSCode)                   | `solidity_ls`              |
| Sorbet                              | `sorbet`                   |
| Sphinx                              | `esbonio`                  |
| Stylelint                           | `stylelint_lsp`            |
| Svelte                              | `svelte`                   |
| Swift                               | `sourcekit`                |
| SystemVerilog                       | `verible`                  |
| TOML                                | `taplo`                    |
| Tailwind CSS                        | `tailwindcss`              |
| Terraform                           | `terraformls`              |
| Terraform [(docs)][tflint]          | `tflint`                   |
| TypeScript [(docs)][tsserver]       | `tsserver`                 |
| Vala                                | `vala_ls`                  |
| VimL                                | `vimls`                    |
| Vue                                 | `volar`                    |
| Vue                                 | `vuels`                    |
| XML                                 | `lemminx`                  |
| YAML                                | `yamlls`                   |
| Zig                                 | `zls`                      |

[arduino]: ./lua/nvim-lsp-installer/servers/arduino_language_server/README.md
[eslint]: ./lua/nvim-lsp-installer/servers/eslint/README.md
[tflint]: ./lua/nvim-lsp-installer/servers/tflint/README.md
[tsserver]: ./lua/nvim-lsp-installer/servers/tsserver/README.md
[pylsp]: ./lua/nvim-lsp-installer/servers/pylsp/README.md
[rust_analyzer]: https://github.com/williamboman/nvim-lsp-installer/wiki/Rust

## Custom servers

You can create your own installers by using the same APIs nvim-lsp-installer itself uses. Refer to
[CUSTOM_SERVERS.md](./CUSTOM_SERVERS.md) for more information.

## Logo

Illustrations in the logo are derived from [@Kaligule](https://schauderbasis.de/)'s "Robots" collection.

## Roadmap

-   Command (and corresponding Lua API) to update outdated servers (e.g., `:LspUpdateAll`)

## Default configuration

```lua
local DEFAULT_SETTINGS = {
    ui = {
        icons = {
            -- The list icon to use for installed servers.
            server_installed = "◍",
            -- The list icon to use for servers that are pending installation.
            server_pending = "◍",
            -- The list icon to use for servers that are not installed.
            server_uninstalled = "◍",
        },
        keymaps = {
            -- Keymap to expand a server in the UI
            toggle_server_expand = "<CR>",
            -- Keymap to install a server
            install_server = "i",
            -- Keymap to reinstall/update a server
            update_server = "u",
            -- Keymap to update all installed servers
            update_all_servers = "U",
            -- Keymap to uninstall a server
            uninstall_server = "X",
        },
    },

    -- The directory in which to install all servers.
    install_root_dir = path.concat { vim.fn.stdpath "data", "lsp_servers" },

    pip = {
        -- These args will be added to `pip install` calls. Note that setting extra args might impact intended behavior
        -- and is not recommended.
        --
        -- Example: { "--proxy", "https://proxyserver" }
        install_args = {},
    },

    -- Controls to which degree logs are written to the log file. It's useful to set this to vim.log.levels.DEBUG when
    -- debugging issues with server installations.
    log_level = vim.log.levels.INFO,

    -- Limit for the maximum amount of servers to be installed at the same time. Once this limit is reached, any further
    -- servers that are requested to be installed will be put in a queue.
    max_concurrent_installers = 4,
}
```