87 lines
2.0 KiB
Lua
87 lines
2.0 KiB
Lua
local lsp = require('lsp-zero').preset({
|
|
manage_nvim_cmp = {
|
|
set_sources = 'recommended',
|
|
}
|
|
})
|
|
local cmp = require('cmp');
|
|
|
|
-- Set the lsp autocomplete to put text from selection into the buffer.
|
|
--
|
|
-- This setup_nvim_cmp function is deprecated, though this seems to be
|
|
-- the cleanest solution as of lsp-zero v2.x. A fallback solution is
|
|
-- commented out below.
|
|
lsp.setup_nvim_cmp({
|
|
select_behavior = cmp.SelectBehavior.Insert
|
|
})
|
|
|
|
vim.diagnostic.config({
|
|
virtual_text = true
|
|
})
|
|
|
|
lsp.on_attach(function(client, bufnr)
|
|
lsp.default_keymaps({buffer = bufnr})
|
|
-- Set tagfunc back to empty instead of vim.lsp.tagfunc(),
|
|
-- to use default tag jumping behaviour withouth going through the lsp.
|
|
-- - see https://neovim.io/doc/user/lsp.html
|
|
vim.opt.tagfunc = ""
|
|
end)
|
|
|
|
-- (Optional) Configure lua language server for neovim
|
|
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls())
|
|
|
|
local function load_dictionary(file_path)
|
|
if not os.rename(file_path, file_path) and true or false then
|
|
print("Ltex Dictionary path not found.")
|
|
return
|
|
end
|
|
|
|
local dict = {}
|
|
local lines = io.lines(file_path)
|
|
for line in io.lines(file_path) do
|
|
table.insert(dict, line)
|
|
end
|
|
return dict
|
|
end
|
|
|
|
local dictionary = load_dictionary(LTEX_DICT)
|
|
|
|
require('lspconfig').ltex.setup{
|
|
settings = {
|
|
ltex = {
|
|
dictionary = {
|
|
["en-US"] = dictionary,
|
|
["en-GB"] = dictionary,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
-- lsp.skip_server_setup({'ltex'})
|
|
|
|
lsp.setup()
|
|
|
|
-- Below commented code is a fallback for when the setup_nvim_cmp()
|
|
-- is gone
|
|
--
|
|
-- This is adapted from the defaults provided by lsp-zero
|
|
-- - see https://github.com/VonHeikemen/lsp-zero.nvim/blob/v2.x/lua/lsp-zero/cmp.lua
|
|
--
|
|
--local select_opts = { behavior = cmp.SelectBehavior.Insert }
|
|
--cmp.setup({
|
|
-- mapping = {
|
|
-- ['<C-p>'] = cmp.mapping(function()
|
|
-- if cmp.visible() then
|
|
-- cmp.select_prev_item(select_opts)
|
|
-- else
|
|
-- cmp.complete()
|
|
-- end
|
|
-- end),
|
|
-- ['<C-n>'] = cmp.mapping(function()
|
|
-- if cmp.visible() then
|
|
-- cmp.select_next_item(select_opts)
|
|
-- else
|
|
-- cmp.complete()
|
|
-- end
|
|
-- end),
|
|
-- }
|
|
--})
|