Add harper-ls for spelling & grammer checking
This language server's default list of supported filetypes is overridden, instead it is not automatically enabled but rather (dis|en)abled when the `spell` setting is changed.
This commit is contained in:
parent
5a265839f9
commit
00f87db692
@ -3,6 +3,7 @@ local ensure_installed = {
|
||||
'clangd', -- C/C++
|
||||
'lua_ls', -- Lua
|
||||
'opencl_ls', -- OpenCL
|
||||
'harper_ls', -- Spelling & grammar
|
||||
}
|
||||
|
||||
if vim.fn.executable('npm') == 1 then
|
||||
@ -117,6 +118,32 @@ return {
|
||||
},
|
||||
})
|
||||
|
||||
vim.lsp.config('harper_ls', {
|
||||
filetypes = {}, -- Disable for all filetypes
|
||||
})
|
||||
|
||||
-- (Dis|en)able harper-ls when spell mode is (dis|en)enabled.
|
||||
vim.api.nvim_create_autocmd("OptionSet", {
|
||||
pattern = "spell",
|
||||
callback = function()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
if vim.v.option_new then
|
||||
vim.lsp.start({
|
||||
name = "harper_ls",
|
||||
cmd = { "harper-ls", "--stdio" },
|
||||
root_dir = vim.fn.getcwd(),
|
||||
}, { bufnr = bufnr })
|
||||
else
|
||||
for _, client in pairs(vim.lsp.get_clients({ bufnr = bufnr })) do
|
||||
if client.name == "harper_ls" then
|
||||
vim.lsp.buf_detach_client(bufnr, client.id)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local cmp = require('cmp')
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user