diff options
| author | William Boman <william@redwill.se> | 2021-08-14 23:17:18 +0200 |
|---|---|---|
| committer | William Boman <william@redwill.se> | 2021-08-15 00:47:15 +0200 |
| commit | df597595d6c3e35f1a394e3362e77629c5ce2247 (patch) | |
| tree | 449c720913c0dc0c1eea6151daf65244071ea67a /lua | |
| parent | update README (diff) | |
| download | mason-df597595d6c3e35f1a394e3362e77629c5ce2247.tar mason-df597595d6c3e35f1a394e3362e77629c5ce2247.tar.gz mason-df597595d6c3e35f1a394e3362e77629c5ce2247.tar.bz2 mason-df597595d6c3e35f1a394e3362e77629c5ce2247.tar.lz mason-df597595d6c3e35f1a394e3362e77629c5ce2247.tar.xz mason-df597595d6c3e35f1a394e3362e77629c5ce2247.tar.zst mason-df597595d6c3e35f1a394e3362e77629c5ce2247.zip | |
add `env` option to shell.raw, and other cosmetic improvements
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-lsp-installer/installers/go.lua | 6 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/installers/shell.lua | 36 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/servers/eslintls/README.md | 32 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/servers/tsserver/README.md | 19 |
4 files changed, 75 insertions, 18 deletions
diff --git a/lua/nvim-lsp-installer/installers/go.lua b/lua/nvim-lsp-installer/installers/go.lua index f4c85248..903c62d8 100644 --- a/lua/nvim-lsp-installer/installers/go.lua +++ b/lua/nvim-lsp-installer/installers/go.lua @@ -4,8 +4,10 @@ local shell = require("nvim-lsp-installer.installers.shell") local M = {} function M.packages(packages) - return shell.raw(("go get %s"):format(table.concat(packages, " ")), { - prefix = [[set -euo pipefail; export GO111MODULE=on; export GOBIN="$PWD"; export GOPATH="$PWD";]] + return shell.raw(('export GOBIN="$PWD"; export GOPATH="$PWD"; go get %s;'):format(table.concat(packages, " ")), { + env = { + GO111MODULE = "on", + }, }) end diff --git a/lua/nvim-lsp-installer/installers/shell.lua b/lua/nvim-lsp-installer/installers/shell.lua index 54a88b02..e21d33c3 100644 --- a/lua/nvim-lsp-installer/installers/shell.lua +++ b/lua/nvim-lsp-installer/installers/shell.lua @@ -1,30 +1,34 @@ local M = {} local default_opts = { - prefix = "set -euo pipefail;" + prefix = "set -euo pipefail;", } function M.raw(raw_script, opts) opts = opts or {} - return function (server, callback) + return function(server, callback) + local jobstart_opts = { + cwd = server._root_dir, + on_exit = function(_, exit_code) + if exit_code ~= 0 then + callback(false, ("Exit code %d"):format(exit_code)) + else + callback(true, nil) + end + end, + } + + if type(opts.env) == "table" and vim.tbl_count(opts.env) then + -- passing an empty Lua table causes E475, for whatever reason + jobstart_opts.env = opts.env + end + local shell = vim.o.shell vim.o.shell = "/bin/bash" vim.cmd [[new]] - vim.fn.termopen( - (opts.prefix or default_opts.prefix) .. raw_script, - { - cwd = server._root_dir, - on_exit = function (_, exit_code) - if exit_code ~= 0 then - callback(false, ("Exit code %d"):format(exit_code)) - else - callback(true, nil) - end - end - } - ) + vim.fn.termopen((opts.prefix or default_opts.prefix) .. raw_script, jobstart_opts) vim.o.shell = shell - vim.cmd([[startinsert]]) -- so that the buffer tails the term log nicely + vim.cmd [[startinsert]] end end diff --git a/lua/nvim-lsp-installer/servers/eslintls/README.md b/lua/nvim-lsp-installer/servers/eslintls/README.md new file mode 100644 index 00000000..be2ff850 --- /dev/null +++ b/lua/nvim-lsp-installer/servers/eslintls/README.md @@ -0,0 +1,32 @@ +# eslintls + +## Enabling document formatting + +To make the `eslintls` server respond to `textDocument/formatting` LSP requests, you need to manually enable this +setting. This is done when setting up the LSP server, like so: + +```lua +local lsp_installer = require "nvim-lsp-installer" + +function common_on_attach(client, bufnr) ... end + +for _, server in pairs(installed_servers) do + local opts = { + on_attach = common_on_attach, + } + + if server.name == "eslintls" then + opts.settings = { + format = { enable = true }, -- this will enable formatting + } + end + + server:setup(opts) +end +``` + +This will make `eslintls` respond to formatting requests, for example when triggered through: + +- `:lua vim.lsp.buf.formatting()` +- `:lua vim.lsp.buf.formatting_seq_sync()` +- `:lua vim.lsp.buf.formatting_sync()` diff --git a/lua/nvim-lsp-installer/servers/tsserver/README.md b/lua/nvim-lsp-installer/servers/tsserver/README.md new file mode 100644 index 00000000..e2c8c20b --- /dev/null +++ b/lua/nvim-lsp-installer/servers/tsserver/README.md @@ -0,0 +1,19 @@ +# 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](/README.md#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) +``` |
