diff --git a/symlinks/config/nvim/init.lua b/symlinks/config/nvim/init.lua index 5d64465..b65f567 100644 --- a/symlinks/config/nvim/init.lua +++ b/symlinks/config/nvim/init.lua @@ -30,13 +30,13 @@ require("lsp") vim.cmd("syntax on") require("init.colors") -vim.api.nvim_set_keymap("n", "Q", "gq", {}) -vim.api.nvim_set_keymap("i", "", "u", {noremap = true}) +vim.keymap.set("n", "Q", "gq", {noremap = false}) +vim.keymap.set("i", "", "u") vim.cmd("command! Wq :wq") vim.cmd("command! W :w") -vim.api.nvim_set_keymap("n", "c", ":ccl lcl", {noremap = true}) +vim.keymap.set("n", "c", ":ccl lcl") -- Allow recursive searches vim.cmd("set path+=**") diff --git a/symlinks/config/nvim/lua/lsp/jdtls_setup.lua b/symlinks/config/nvim/lua/lsp/jdtls_setup.lua index 67b53aa..2df8a28 100644 --- a/symlinks/config/nvim/lua/lsp/jdtls_setup.lua +++ b/symlinks/config/nvim/lua/lsp/jdtls_setup.lua @@ -9,21 +9,15 @@ function M.setup() require "jdtls".setup_dap() require "jdtls.setup".add_commands() local on_attach = function(client, bufnr) - local function buf_set_keymap(...) - vim.api.nvim_buf_set_keymap(bufnr, ...) - end - local function buf_set_option(...) - vim.api.nvim_buf_set_option(bufnr, ...) - end - - buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") - - local default_opts = {noremap = true, silent = true} + vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc" common_config.on_attach(client, bufnr) - buf_set_keymap("n", "", "lua require('jdtls').code_action()", default_opts) - buf_set_keymap("n", "ac", "lua require('jdtls').code_action()", default_opts) + local code_action_fun = function() + require "jdtls".code_action() + end + vim.keymap.set("n", "", code_action_fun) + vim.keymap.set("n", "ac", code_action_fun) end local root_markers = {"gradlew", "pom.xml"} diff --git a/symlinks/config/nvim/lua/lsp/server_config.lua b/symlinks/config/nvim/lua/lsp/server_config.lua index aca5af1..d629f10 100644 --- a/symlinks/config/nvim/lua/lsp/server_config.lua +++ b/symlinks/config/nvim/lua/lsp/server_config.lua @@ -5,28 +5,90 @@ local M = {} M.on_attach = function(client, bufnr) - local function buf_set_keymap(...) - vim.api.nvim_buf_set_keymap(bufnr, ...) - end - local function buf_set_option(...) - vim.api.nvim_buf_set_option(bufnr, ...) - end - - buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") - - local default_opts = {noremap = true, silent = true} + vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc" -- Lsp keymaps - buf_set_keymap("n", "", "lua vim.lsp.buf.definition()", default_opts) - buf_set_keymap("n", "gD", "lua vim.lsp.buf.declaration()", default_opts) - buf_set_keymap("n", "gr", "lua vim.lsp.buf.references()", default_opts) - buf_set_keymap("n", "gi", "lua vim.lsp.buf.implementation()", default_opts) - buf_set_keymap("n", "rn", "lua vim.lsp.buf.rename()", default_opts) - buf_set_keymap("n", "", "lua vim.lsp.buf.signature_help()", default_opts) - buf_set_keymap("n", "K", "lua vim.lsp.buf.hover()", default_opts) - buf_set_keymap("n", "", "lua vim.lsp.buf.code_action()", default_opts) - buf_set_keymap("n", "ac", "lua vim.lsp.buf.code_action()", default_opts) - buf_set_keymap("n", "a", "lua vim.lsp.buf.code_action_range()", default_opts) + local opts = {buffer = bufnr} + vim.keymap.set( + "n", + "", + function() + vim.lsp.buf.definition() + end, + opts + ) + vim.keymap.set( + "n", + "gD", + function() + vim.lsp.buf.declaration() + end, + opts + ) + vim.keymap.set( + "n", + "gr", + function() + vim.lsp.buf.references() + end, + opts + ) + vim.keymap.set( + "n", + "gi", + function() + vim.lsp.buf.implementation() + end, + opts + ) + vim.keymap.set( + "n", + "rn", + function() + vim.lsp.buf.rename() + end, + opts + ) + vim.keymap.set( + "n", + "", + function() + vim.lsp.buf.signature_help() + end, + opts + ) + vim.keymap.set( + "n", + "K", + function() + vim.lsp.buf.hover() + end, + opts + ) + vim.keymap.set( + "n", + "", + function() + vim.lsp.buf.code_action() + end, + opts + ) + vim.keymap.set( + "n", + "ac", + function() + vim.lsp.buf.code_action() + end, + opts + ) + vim.keymap.set( + "n", + "a", + function() + vim.lsp.buf.code_action_range() + end, + opts + ) end return M diff --git a/symlinks/config/nvim/plugin/dap.lua b/symlinks/config/nvim/plugin/dap.lua index eb56152..1f105e0 100644 --- a/symlinks/config/nvim/plugin/dap.lua +++ b/symlinks/config/nvim/plugin/dap.lua @@ -4,7 +4,15 @@ local dap = require("dap") -vim.cmd [[ au FileType dap-repl lua require('dap.ext.autocompl').attach() ]] +vim.api.nvim_create_autocmd( + "FileType", + { + pattern = "dap-repl", + callback = function(args) + require("dap.ext.autocompl").attach() + end + } +) -- Nvim DAP Treesitter integration require("nvim-dap-virtual-text").setup() @@ -52,19 +60,12 @@ dap.listeners.after["event_initialized"]["me"] = function() for _, keymap in pairs(keymaps) do if keymap.lhs == "K" then table.insert(keymap_restore, keymap) - api.nvim_buf_del_keymap(buf, "n", "K") + vim.keymap.del("n", "K", {buffer = buf}) end end end vim.keymap.set( - "n", - "K", - function() - dapui.eval() - end - ) - vim.keymap.set( - "v", + {"n", "v"}, "K", function() dapui.eval() @@ -74,7 +75,7 @@ end dap.listeners.after["event_terminated"]["me"] = function() for _, keymap in pairs(keymap_restore) do - api.nvim_buf_set_keymap(keymap.buffer, keymap.mode, keymap.lhs, keymap.rhs, {silent = keymap.silent == 1}) + vim.keymap.set(keymap.mode, keymap.lhs, keymap.rhs, {silent = keymap.silent == 1, buffer = keymap.buffer}) end keymap_restore = {} end