108 lines
3.8 KiB
Lua
108 lines
3.8 KiB
Lua
|
return {
|
||
|
'VonHeikemen/lsp-zero.nvim',
|
||
|
branch = 'v1.x',
|
||
|
dependencies = {
|
||
|
-- LSP Support
|
||
|
{'neovim/nvim-lspconfig'}, -- Required
|
||
|
{'williamboman/mason.nvim'}, -- Optional
|
||
|
{'williamboman/mason-lspconfig.nvim'}, -- Optional
|
||
|
{'lvimuser/lsp-inlayhints.nvim'},
|
||
|
|
||
|
-- Autocompletion
|
||
|
{'hrsh7th/nvim-cmp'}, -- Required
|
||
|
{'hrsh7th/cmp-nvim-lsp'}, -- Required
|
||
|
{'hrsh7th/cmp-buffer'}, -- Optional
|
||
|
{'hrsh7th/cmp-path'}, -- Optional
|
||
|
{'saadparwaiz1/cmp_luasnip'}, -- Optional
|
||
|
{'hrsh7th/cmp-nvim-lua'}, -- Optional
|
||
|
|
||
|
-- Snippets
|
||
|
{'L3MON4D3/LuaSnip'}, -- Required
|
||
|
{'rafamadriz/friendly-snippets'}, -- Optional
|
||
|
},
|
||
|
init = function()
|
||
|
local lsp_zero = require('lsp-zero')
|
||
|
local ih = require('lsp-inlayhints')
|
||
|
ih.setup()
|
||
|
|
||
|
lsp_zero.on_attach(function(client, bufnr)
|
||
|
-- see :help lsp-zero-keybindings
|
||
|
-- to learn the available actions
|
||
|
lsp_zero.default_keymaps({buffer = bufnr})
|
||
|
-- ih.on_attach(client, bufnr)
|
||
|
end)
|
||
|
require('mason').setup({})
|
||
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||
|
|
||
|
require('mason-lspconfig').setup({
|
||
|
ensure_installed = {},
|
||
|
handlers = {
|
||
|
function(server_name)
|
||
|
require('lspconfig')[server_name].setup({
|
||
|
capabilities = capabilities,
|
||
|
on_attach = function(client, bufnr)
|
||
|
ih.on_attach(client, bufnr)
|
||
|
end,
|
||
|
})
|
||
|
end,
|
||
|
},
|
||
|
})
|
||
|
local cmp = require("cmp")
|
||
|
|
||
|
cmp.setup({
|
||
|
expand = function(args)
|
||
|
vim.snippet.expand(args.body)
|
||
|
end,
|
||
|
window = {
|
||
|
completion = cmp.config.window.bordered(),
|
||
|
documentation = cmp.config.window.bordered(),
|
||
|
},
|
||
|
mapping = cmp.mapping.preset.insert({
|
||
|
['<C-k>'] = cmp.mapping.scroll_docs(-4),
|
||
|
['<C-j>'] = cmp.mapping.scroll_docs(4),
|
||
|
['<C-Tab>'] = cmp.mapping.complete(),
|
||
|
['<Esc>/home/yourname/Documents/CC-Tweaked-EmmyLua'] = cmp.mapping.abort(),
|
||
|
-- Accept currently selected item.
|
||
|
-- Set `select` to `false` to only confirm explicitly selected items.
|
||
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||
|
}),
|
||
|
sources = cmp.config.sources({
|
||
|
{ name = 'nvim_lsp' },
|
||
|
{ name = 'vsnip' }, -- For vsnip users.
|
||
|
-- { name = 'luasnip' }, -- For luasnip users.
|
||
|
-- { name = 'ultisnips' }, -- For ultisnips users.
|
||
|
-- { name = 'snippy' }, -- For snippy users.
|
||
|
}, {
|
||
|
{ name = 'buffer' },
|
||
|
})
|
||
|
})
|
||
|
|
||
|
-- require('lspconfig').clangd.setup({})
|
||
|
|
||
|
require('lspconfig').lua_ls.setup({
|
||
|
settings = {
|
||
|
Lua = {}
|
||
|
},
|
||
|
on_init = function(client)
|
||
|
local uv = vim.uv or vim.loop
|
||
|
local path = client.workspace_folders[1].name
|
||
|
|
||
|
-- Don't do anything if there is a project local config
|
||
|
if uv.fs_stat(path .. '/.luarc.json') or
|
||
|
uv.fs_stat(path .. '/.luarc.jsonc') then
|
||
|
return
|
||
|
end
|
||
|
|
||
|
-- Apply neovim specific settings
|
||
|
local lua_opts = lsp_zero.nvim_lua_ls()
|
||
|
|
||
|
client.config.settings.Lua = vim.tbl_deep_extend(
|
||
|
'force',
|
||
|
client.config.settings.Lua,
|
||
|
lua_opts.settings.Lua
|
||
|
)
|
||
|
end
|
||
|
})
|
||
|
end
|
||
|
};
|