From 0e55059a631c9d264ee1502b7ca4aee75878faf7 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 10 Jun 2024 13:12:26 +0200 Subject: [PATCH] replace utils.map with vim.keymap.set --- lua/keymappings.lua | 14 +++++++------- lua/lsp.lua | 18 +++++++++--------- lua/plugins/telescope.lua | 19 +++++++++++-------- lua/utils.lua | 6 ------ 4 files changed, 27 insertions(+), 30 deletions(-) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index fab9bb7..9fe6679 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -1,15 +1,15 @@ local utils = require('utils') -- Clear trailing whitespace -utils.map("n", "", "let _s=@/:%s/\\s\\+$//e:let @/=_s") +vim.keymap.set("n", "", "let _s=@/:%s/\\s\\+$//e:let @/=_s") -- Use tab and shift+tab to cycle buffers -utils.map("n", "", "bn") -utils.map("n", "", "bp") +vim.keymap.set("n", "", "bn") +vim.keymap.set("n", "", "bp") -- Turn spellchecker on and off -utils.map("n", "se", "setlocal spell spelllang=en_us") -utils.map("n", "sq", "setlocal nospell") +vim.keymap.set("n", "se", "setlocal spell spelllang=en_us") +vim.keymap.set("n", "sq", "setlocal nospell") -utils.map("n", "", "set nonumber!") -utils.map("n", "fe", "Oil") +vim.keymap.set("n", "", "set nonumber!") +vim.keymap.set("n", "fe", "Oil") diff --git a/lua/lsp.lua b/lua/lsp.lua index a659fe2..75f79c1 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -3,15 +3,15 @@ local on_attach = function(client, bufnr) local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) -- Mappings. - utils.map("n", "K", "lua vim.lsp.buf.hover()") - utils.map("n", "", "lua vim.lsp.buf.signature_help()") - utils.map("n", "", "lua vim.lsp.buf.type_definition()") - utils.map("n", "", "lua vim.lsp.buf.rename()()") - utils.map("n", "[d", "lua vim.diagnostic.goto_prev()") - utils.map("n", "]d", "lua vim.diagnostic.goto_next()") - utils.map("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") - utils.map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") - utils.map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") + vim.keymaps.set("n", "K", "lua vim.lsp.buf.hover()") + vim.keymaps.set("n", "", "lua vim.lsp.buf.signature_help()") + vim.keymaps.set("n", "", "lua vim.lsp.buf.type_definition()") + vim.keymaps.set("n", "", "lua vim.lsp.buf.rename()()") + vim.keymaps.set("n", "[d", "lua vim.diagnostic.goto_prev()") + vim.keymaps.set("n", "]d", "lua vim.diagnostic.goto_next()") + vim.keymaps.set("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") + vim.keymaps.set("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") + vim.keymaps.set("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") if client.supports_method("textDocument/formatting") then vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 8ab6da0..e438d35 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -20,15 +20,18 @@ telescope.setup { }, } +vim.keymap.set('n', 'ss', telescope.extensions.luasnip.luasnip, {}) + vim.keymap.set('n', 'ff', builtin.find_files, {}) -vim.keymap.set('n', 'fg', builtin.git_files, {}) -vim.keymap.set('n', 'fs', telescope.extensions.luasnip.luasnip, {}) -vim.keymap.set('n', 'gg', builtin.live_grep, {}) -vim.keymap.set('n', 'bb', builtin.buffers, {}) -vim.keymap.set('n', 'hh', builtin.help_tags, {}) -vim.keymap.set('n', 'ss', builtin.lsp_dynamic_workspace_symbols, {}) -vim.keymap.set('n', 'sd', builtin.lsp_document_symbols, {}) -vim.keymap.set('n', 'dd', builtin.diagnostics, {}) +vim.keymap.set('n', 'ffg', builtin.git_files, {}) +vim.keymap.set('n', 'fg', builtin.live_grep, {}) +vim.keymap.set('n', 'fb', builtin.buffers, {}) +vim.keymap.set('n', 'fs', builtin.lsp_dynamic_workspace_symbols, {}) +vim.keymap.set('n', 'fsd', builtin.lsp_document_symbols, {}) +vim.keymap.set('n', 'fh', builtin.help_tags, {}) +vim.keymap.set('n', 'fd', builtin.diagnostics, {}) + +-- Use telescope for lsp definitions, calls and references vim.keymap.set('n', 'gd', builtin.lsp_definitions, {}) vim.keymap.set('n', 'gr', builtin.lsp_references, {}) vim.keymap.set('n', 'gi', builtin.lsp_implementations, {}) diff --git a/lua/utils.lua b/lua/utils.lua index 8411ee5..1da951a 100644 --- a/lua/utils.lua +++ b/lua/utils.lua @@ -7,10 +7,4 @@ function utils.opt(scope, key, value) if scope ~= 'o' then scopes['o'][key] = value end end -function utils.map(mode, lhs, rhs, opts) - local options = { noremap = true, silent = true } - if opts then options = vim.tbl_extend('force', options, opts) end - vim.api.nvim_set_keymap(mode, lhs, rhs, options) -end - return utils