nvim: plugins/lsp: Drop null-ls
See the below issue https://github.com/jose-elias-alvarez/nvim-lsp-ts-utils/issues/87 We went with null-ls because we wanted formatting with prettier. Also null-ls was recommended by nvim-lsp-ts-utils. The advantage of null-ls is it provides formatting and diagnostics together in one package. However, we will get prettier by another means and for linting switch to nvim-lint.
This commit is contained in:
parent
7941b26d41
commit
49cf726ce0
2 changed files with 6 additions and 29 deletions
|
@ -1,7 +1,6 @@
|
||||||
local nvim_lsp = require 'lspconfig'
|
local nvim_lsp = require 'lspconfig'
|
||||||
local protocol = require 'vim.lsp.protocol'
|
local protocol = require 'vim.lsp.protocol'
|
||||||
local ts_utils = require 'nvim-lsp-ts-utils'
|
local ts_utils = require 'nvim-lsp-ts-utils'
|
||||||
local null_ls = require 'null-ls'
|
|
||||||
local util = require 'lspconfig/util'
|
local util = require 'lspconfig/util'
|
||||||
local cmp = require 'cmp_nvim_lsp'
|
local cmp = require 'cmp_nvim_lsp'
|
||||||
|
|
||||||
|
@ -31,19 +30,9 @@ function PeekDefinition()
|
||||||
return vim.lsp.buf_request(0, 'textDocument/definition', params, preview_location_callback)
|
return vim.lsp.buf_request(0, 'textDocument/definition', params, preview_location_callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- This should be called only once, so cannot be in on_attach as earlier.
|
|
||||||
-- See https://github.com/jose-elias-alvarez/null-ls.nvim/issues/38
|
|
||||||
-- Required by nvim-lsp-ts-utils to provide ESLint code actions, diagnostics
|
|
||||||
-- and formatting.
|
|
||||||
local null_ls_sources = {
|
|
||||||
null_ls.builtins.diagnostics.shellcheck,
|
|
||||||
}
|
|
||||||
null_ls.config({ sources = null_ls_sources })
|
|
||||||
nvim_lsp["null-ls"].setup {}
|
|
||||||
|
|
||||||
local ts_utils_setup = function(client, bufnr, opts)
|
local ts_utils_setup = function(client, bufnr, opts)
|
||||||
if client.name == 'tsserver' then
|
if client.name == 'tsserver' then
|
||||||
-- Disable tsserver formatting as we plan on formatting via null-ls
|
-- Disable tsserver formatting, we want formatting via prettier
|
||||||
client.resolved_capabilities.document_formatting = false
|
client.resolved_capabilities.document_formatting = false
|
||||||
client.resolved_capabilities.document_range_formatting = false
|
client.resolved_capabilities.document_range_formatting = false
|
||||||
|
|
||||||
|
@ -62,17 +51,6 @@ local ts_utils_setup = function(client, bufnr, opts)
|
||||||
same_file = 1, -- add to existing import statement
|
same_file = 1, -- add to existing import statement
|
||||||
},
|
},
|
||||||
|
|
||||||
eslint_enable_code_actions = true,
|
|
||||||
eslint_bin = "eslint",
|
|
||||||
eslint_enable_disable_comments = true,
|
|
||||||
eslint_enable_diagnostics = true,
|
|
||||||
eslint_config_fallback = nil,
|
|
||||||
eslint_show_rule_id = false,
|
|
||||||
|
|
||||||
enable_formatting = true,
|
|
||||||
formatter = "prettier",
|
|
||||||
formatter_config_fallback = nil,
|
|
||||||
|
|
||||||
update_imports_on_move = false,
|
update_imports_on_move = false,
|
||||||
require_confirmation_on_move = false,
|
require_confirmation_on_move = false,
|
||||||
watch_dir = nil,
|
watch_dir = nil,
|
||||||
|
@ -103,6 +81,10 @@ local on_attach = function(client, bufnr)
|
||||||
|
|
||||||
local opts = { noremap=true, silent=true }
|
local opts = { noremap=true, silent=true }
|
||||||
|
|
||||||
|
-- This needs to be here, so we disable formatting with tsserver before
|
||||||
|
-- actually checking it below.
|
||||||
|
ts_utils_setup(client, bufnr, opts)
|
||||||
|
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd' , '<cmd>lua vim.lsp.buf.definition()<CR>' , opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd' , '<cmd>lua vim.lsp.buf.definition()<CR>' , opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD' , '<cmd>lua vim.lsp.buf.declaration()<CR>' , opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD' , '<cmd>lua vim.lsp.buf.declaration()<CR>' , opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr' , '<cmd>lua vim.lsp.buf.references()<CR>' , opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr' , '<cmd>lua vim.lsp.buf.references()<CR>' , opts)
|
||||||
|
@ -163,8 +145,6 @@ local on_attach = function(client, bufnr)
|
||||||
' '; -- type parameter
|
' '; -- type parameter
|
||||||
}
|
}
|
||||||
|
|
||||||
ts_utils_setup(client, bufnr, opts)
|
|
||||||
|
|
||||||
vim.cmd [[autocmd CursorHold,CursorHoldI <buffer> lua require'nvim-lightbulb'.update_lightbulb()]]
|
vim.cmd [[autocmd CursorHold,CursorHoldI <buffer> lua require'nvim-lightbulb'.update_lightbulb()]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -82,10 +82,7 @@ local init = function ()
|
||||||
-- Alignment
|
-- Alignment
|
||||||
use 'junegunn/vim-easy-align'
|
use 'junegunn/vim-easy-align'
|
||||||
use 'nvim-lua/plenary.nvim'
|
use 'nvim-lua/plenary.nvim'
|
||||||
use {
|
use 'jose-elias-alvarez/nvim-lsp-ts-utils'
|
||||||
'jose-elias-alvarez/nvim-lsp-ts-utils',
|
|
||||||
requires = { 'jose-elias-alvarez/null-ls.nvim' }
|
|
||||||
}
|
|
||||||
-- LSP
|
-- LSP
|
||||||
use {
|
use {
|
||||||
'neovim/nvim-lspconfig',
|
'neovim/nvim-lspconfig',
|
||||||
|
|
Loading…
Reference in a new issue