Dot_Files/.config/nvim/lua/core/mappings.lua

53 lines
1.5 KiB
Lua
Raw Normal View History

2022-05-11 21:00:57 -05:00
local utils_func = require('utils.funcs')
local map = utils_func.map
2022-01-10 09:55:15 -06:00
local M = {}
M.setup = function()
2022-05-11 21:00:57 -05:00
-- set mapleader to space
vim.g.mapleader = ' '
2022-01-10 09:55:15 -06:00
2022-05-11 21:00:57 -05:00
-- Get rid of highlight after search
map('n', '<esc>', ':noh<CR>')
-- Spell Checking
2022-05-11 21:00:57 -05:00
map('n', '<leader>st', ':set spell!<CR>')
2022-02-05 02:56:46 -06:00
-- Better split movement
2022-05-11 21:00:57 -05:00
map('n', '<C-l>', '<C-w>l')
map('n', '<C-h>', '<C-w>h')
map('n', '<C-k>', '<C-w>k')
map('n', '<C-j>', '<C-w>j')
2022-02-05 02:56:46 -06:00
-- Better split closing
2022-05-11 21:00:57 -05:00
map('n', '<C-x>', '<C-w>c')
2022-02-05 02:56:46 -06:00
-- Set current focused file as cwd
2022-05-11 21:00:57 -05:00
map('n', '<leader>cd', ':cd %:p:h<CR>')
local diagnostics_active = true
map('n', '<leader>lt', '', {
callback = function()
diagnostics_active = not diagnostics_active
local set_namespace_settings = function(
lsp_config --[[table]]
)
local namespaces = vim.diagnostic.get_namespaces()
local diagnostic = vim.diagnostic.get()
for namespace_number, _ in pairs(namespaces) do
vim.diagnostic.set(namespace_number, 0, diagnostic, lsp_config)
end
end
if diagnostics_active then
vim.notify('Enabling diagnostics')
set_namespace_settings({ virtual_lines = true })
else
vim.notify('Disabling diagnostics')
set_namespace_settings({ virtual_lines = false })
end
end,
})
2022-01-10 09:55:15 -06:00
end
return M