mirror of
https://github.com/sadan4/nvim.git
synced 2025-01-30 17:13:29 -05:00
91 lines
2.4 KiB
Lua
91 lines
2.4 KiB
Lua
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
|
|
|
capabilities.textDocument.foldingRange = {
|
|
dynamicRegistration = false,
|
|
lineFoldingOnly = true,
|
|
}
|
|
--
|
|
require("lspconfig").kotlin_language_server.setup({
|
|
capabilities = capabilities,
|
|
})
|
|
--Java
|
|
require("lspconfig").java_language_server.setup({
|
|
capabilities = capabilities,
|
|
})
|
|
--Lua
|
|
require("lspconfig").lua_ls.setup({
|
|
capabilities = capabilities,
|
|
on_init = function(client)
|
|
local path = client.workspace_folders[1].name
|
|
if vim.loop.fs_stat(path .. "/.luarc.json") or vim.loop.fs_stat(path .. "/.luarc.jsonc") then
|
|
return
|
|
end
|
|
|
|
client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
|
|
runtime = {
|
|
-- Tell the language server which version of Lua you're using
|
|
-- (most likely LuaJIT in the case of Neovim)
|
|
version = "LuaJIT",
|
|
},
|
|
-- Make the server aware of Neovim runtime files
|
|
workspace = {
|
|
checkThirdParty = false,
|
|
library = {
|
|
vim.env.VIMRUNTIME,
|
|
-- Depending on the usage, you might want to add additional paths here.
|
|
-- "${3rd}/luv/library"
|
|
-- "${3rd}/busted/library",
|
|
},
|
|
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
|
|
-- library = vim.api.nvim_get_runtime_file("", true)
|
|
},
|
|
})
|
|
end,
|
|
settings = {
|
|
Lua = {},
|
|
},
|
|
})
|
|
|
|
local luasnip = require("luasnip")
|
|
|
|
local cmp = require("cmp")
|
|
cmp.setup({
|
|
snippet = {
|
|
expand = function(args)
|
|
luasnip.lsp_expand(args.body)
|
|
end,
|
|
},
|
|
mapping = cmp.mapping.preset.insert({
|
|
-- ['<C-u>'] = cmp.mapping.scroll_docs(-4), -- Up
|
|
-- ['<C-d>'] = cmp.mapping.scroll_docs(4), -- Down
|
|
-- C-b (back) C-f (forward) for snippet placeholder navigation.
|
|
['<C-Space>'] = cmp.mapping.complete(),
|
|
["<CR>"] = cmp.mapping.confirm({
|
|
behavior = cmp.ConfirmBehavior.Replace,
|
|
select = true,
|
|
}),
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
elseif luasnip.expand_or_jumpable() then
|
|
luasnip.expand_or_jump()
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" }),
|
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_prev_item()
|
|
elseif luasnip.jumpable(-1) then
|
|
luasnip.jump(-1)
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" }),
|
|
}),
|
|
sources = {
|
|
{ name = "nvim_lsp" },
|
|
{ name = "luasnip" },
|
|
},
|
|
})
|