Add neovim configuration
This commit is contained in:
40
.config/nvim/lua/lsphelp.lua
Normal file
40
.config/nvim/lua/lsphelp.lua
Normal file
@ -0,0 +1,40 @@
|
||||
-- Helper function for creating keymaps.
|
||||
function nnoremap(rhs, lhs, desc)
|
||||
local bufopts = { noremap=true, silent=true, buffer=bufnr, desc = desc }
|
||||
|
||||
vim.keymap.set("n", rhs, lhs, bufopts)
|
||||
end
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
function default_on_attach(client, bufnr)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- Mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
nnoremap('gD', vim.lsp.buf.declaration, "Go to declaration")
|
||||
nnoremap('gd', vim.lsp.buf.definition, "Go to definition")
|
||||
nnoremap('K', vim.lsp.buf.hover, "Hover text")
|
||||
nnoremap('gi', vim.lsp.buf.implementation, "Go to implementation")
|
||||
nnoremap('<C-k>', vim.lsp.buf.signature_help, "Show signature")
|
||||
nnoremap('<space>wa', vim.lsp.buf.add_workspace_folder, "Add workspace folder")
|
||||
nnoremap('<space>wr', vim.lsp.buf.remove_workspace_folder, "Remove workspace folder")
|
||||
nnoremap('<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, "List workspace folders")
|
||||
nnoremap('<space>D', vim.lsp.buf.type_definition, "Go to type definition")
|
||||
nnoremap('<space>rn', vim.lsp.buf.rename, "Rename")
|
||||
nnoremap('<space>ca', vim.lsp.buf.code_action, "Code actions")
|
||||
nnoremap('gr', vim.lsp.buf.references, "Find references")
|
||||
nnoremap('<space>f', function() vim.lsp.buf.format { async = true } end, "Format file")
|
||||
end
|
||||
|
||||
function read_configuration()
|
||||
local configuration = {}
|
||||
local chunk, err = loadfile(os.getenv('HOME') .. '/.config/nvim/config', 't', configuration)
|
||||
if chunk then
|
||||
chunk()
|
||||
end
|
||||
return configuration
|
||||
end
|
Reference in New Issue
Block a user