augh
This commit is contained in:
parent
99c942cc3b
commit
618a1e6841
8 changed files with 87 additions and 141 deletions
37
dot_config/nvim/lua/plugins/completion.lua
Normal file
37
dot_config/nvim/lua/plugins/completion.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
mapping = {
|
||||
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), {"i", "c"}),
|
||||
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
||||
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
|
||||
['<C-e>'] = cmp.mapping({
|
||||
i = cmp.mapping.abort(),
|
||||
c = cmp.mapping.close(),
|
||||
}),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{name = "nvim_lsp"},
|
||||
}, {
|
||||
{name = "buffer"},
|
||||
}),
|
||||
})
|
||||
|
||||
cmp.setup.cmdline(":", {
|
||||
sources = cmp.config.sources({
|
||||
{name = "path"},
|
||||
}, {
|
||||
{name = "buffer"},
|
||||
}),
|
||||
})
|
||||
|
||||
-- Setup lspconfig.
|
||||
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
local lsps = {"sumneko_lua", "rust_analyzer"}
|
||||
for _, lsp in pairs(lsps) do
|
||||
require('lspconfig')[lsp].setup {
|
||||
capabilities = capabilities
|
||||
}
|
||||
end
|
|
@ -9,7 +9,7 @@ Utils.nmap("]d", "<cmd>lua vim.diagnostic.goto_next()<CR>")
|
|||
Utils.nmap("<space>q", "<cmd>lua vim.diagnostic.setloclist()<CR>")
|
||||
|
||||
-- Set the following keybinds only after LSP attachment
|
||||
local on_attach = function(_, bufnr)
|
||||
local on_attach = function(client, bufnr)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
|
@ -28,10 +28,12 @@ local on_attach = function(_, bufnr)
|
|||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<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', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||
|
||||
require("aerial").on_attach(client, bufnr)
|
||||
end
|
||||
|
||||
-- Initialize servers that don't need any extra config
|
||||
local simple_servers = {"rust_analyzer"}
|
||||
local simple_servers = {}
|
||||
for _, lsp in pairs(simple_servers) do
|
||||
require("lspconfig")[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
|
@ -47,6 +49,7 @@ table.insert(runtime_path, "lua/?.lua")
|
|||
table.insert(runtime_path, "lua/?/init.lua")
|
||||
|
||||
require("lspconfig").sumneko_lua.setup {
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue