nixos-config/home-manager/modules/neovim/config/lua/keys.lua

37 lines
1.5 KiB
Lua
Raw Normal View History

2022-01-13 09:03:22 +01:00
local map = vim.api.nvim_set_keymap
-- Set space as leader
map('n', ' ', '', {noremap = true})
vim.g.mapleader = ' '
-- Clear highlights with <space><space>
map('n', '<leader> ', ':noh<cr>', {noremap = true})
-- Splits
map('n', '<leader>s', '<C-w>s', {noremap = true})
map('n', '<leader>v', '<C-w>v', {noremap = true})
-- Previous and next tab
map('n', '<leader>[', ':tabp<cr>', {noremap = true})
map('n', '<leader>]', ':tabn<cr>', {noremap = true})
-- New tab
map('n', '<leader>t', ':tabnew<cr>', {noremap = true})
-- File finder
map('n', '<leader>ff', '<cmd>Telescope find_files<cr>', {noremap = true})
map('n', '<leader>fg', '<cmd>Telescope live_grep<cr>', {noremap = true})
map('n', '<leader>fb', '<cmd>Telescope buffers<cr>', {noremap = true})
map('n', '<leader>fh', '<cmd>Telescope help_tags<cr>', {noremap = true})
-- LSP
map('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', {noremap = true, silent = true})
map('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', {noremap = true, silent = true})
map('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', {noremap = true, silent = true})
map('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', {noremap = true, silent = true})
map('n', '<C-.>', '<cmd>lua vim.lsp.buf.hover()<cr>', {noremap = true, silent = true})
map('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<cr>', {noremap = true, silent = true})
map('n', '[g', '<cmd>lua vim.lsp.diagnostic.goto_prev()<cr>', {noremap = true, silent = true})
map('n', ']g', '<cmd>lua vim.lsp.diagnostic.goto_next()<cr>', {noremap = true, silent = true})