diff --git a/.config/nvim/lua/dln/utils.lua b/.config/nvim/lua/dln/utils.lua deleted file mode 100644 index fc80c16..0000000 --- a/.config/nvim/lua/dln/utils.lua +++ /dev/null @@ -1,19 +0,0 @@ -local M = {} - -function M.term_codes(s) - return vim.api.nvim_replace_termcodes(s, true, true, true) -end - -function M.map(mode, lhs, rhs, opts) - opts = vim.tbl_extend("force", {noremap = true}, opts or {}) - for i = 1, #mode do - vim.api.nvim_set_keymap(mode:sub(i, i), lhs, rhs, opts) - end -end - -function M.mapx(mode, lhs, rhs, opts) - opts = vim.tbl_extend("force", {expr = true, silent = true}, opts or {}) - return M.map(mode, lhs, rhs, opts) -end - -return M diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 2013412..a1f0614 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -126,18 +126,7 @@ return require("packer").startup(function() use({ "neovim/nvim-lspconfig", config = function() - require("dln.lsp-config") - local map = require("dln.utils").map - map("n", "K", "lua vim.lsp.buf.hover()") - map("i", "", "lua vim.lsp.buf.signature_help()") - map("n", "1gd", "lua vim.lsp.buf.type_definition()") - map("n", "gf", "lua vim.lsp.buf.formatting()") - map("n", "rn", "lua vim.lsp.buf.rename()") - map("n", "[d", "lua vim.lsp.diagnostic.goto_prev()") - map("n", "]d", "lua vim.lsp.diagnostic.goto_next()") - map("n", "gwa", "lua vim.lsp.buf.add_workspace_folder()") - map("n", "gwr", "lua vim.lsp.buf.add_workspace_folder()") - map("n", "gwl", "lua vim.lsp.buf.add_workspace_folder()") + require("plugins/lsp-config") end, }) diff --git a/.config/nvim/lua/plugins/copilot.lua b/.config/nvim/lua/plugins/copilot.lua index de59b37..2289045 100644 --- a/.config/nvim/lua/plugins/copilot.lua +++ b/.config/nvim/lua/plugins/copilot.lua @@ -1,5 +1,4 @@ -local map = require("dln.utils").map -map("i", "", [[copilot#Accept("\")]], { noremap = true, silent = true, expr = true, script = true }) +vim.keymap.set("i", "", [[copilot#Accept("\")]], { noremap = true, silent = true, expr = true, script = true }) vim.g.copilot_no_tab_map = true vim.g.copilot_assume_mapped = true diff --git a/.config/nvim/lua/plugins/dap.lua b/.config/nvim/lua/plugins/dap.lua index 477cb39..eeb109f 100644 --- a/.config/nvim/lua/plugins/dap.lua +++ b/.config/nvim/lua/plugins/dap.lua @@ -1,14 +1,13 @@ require("dap") -local map = require('dln.utils').map local silent = { silent = true } vim.fn.sign_define("DapStopped", { text = "⇒", texthl = "", linehl = "debugPC", numhl = "" }) vim.fn.sign_define("DapBreakpoint", { text = "🧘", texthl = "", linehl = "debugPC", numhl = "" }) -map("n", "DD", ":lua require 'dap'.toggle_breakpoint()", silent) -map("n", "Dc", ":lua require 'dap'.continue()", silent) -map("n", "Di", ":lua require 'dap'.step_into()", silent) -map("n", "Do", ":lua require 'dap'.step_over()", silent) -map("n", "DO", ":lua require 'dap'.step_out()", silent) -map("n", "Dr", ":lua require 'dap'.repl.toggle({height = 5})", silent) -map("n", "Dh", ":lua require 'dap.ui.widgets'.hover()", silent) +vim.keymap.set("n", "DD", ":lua require 'dap'.toggle_breakpoint()", silent) +vim.keymap.set("n", "Dc", ":lua require 'dap'.continue()", silent) +vim.keymap.set("n", "Di", ":lua require 'dap'.step_into()", silent) +vim.keymap.set("n", "Do", ":lua require 'dap'.step_over()", silent) +vim.keymap.set("n", "DO", ":lua require 'dap'.step_out()", silent) +vim.keymap.set("n", "Dr", ":lua require 'dap'.repl.toggle({height = 5})", silent) +vim.keymap.set("n", "Dh", ":lua require 'dap.ui.widgets'.hover()", silent) diff --git a/.config/nvim/lua/dln/lsp-config.lua b/.config/nvim/lua/plugins/lsp-config.lua similarity index 84% rename from .config/nvim/lua/dln/lsp-config.lua rename to .config/nvim/lua/plugins/lsp-config.lua index 1b01b01..e7708cf 100644 --- a/.config/nvim/lua/dln/lsp-config.lua +++ b/.config/nvim/lua/plugins/lsp-config.lua @@ -1,14 +1,37 @@ local lspconfig = require("lspconfig") --- local configs = require("lspconfig.configs") -local util = require("lspconfig.util") local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) +vim.keymap.set("n", "K", "lua vim.lsp.buf.hover()") +vim.keymap.set("i", "", "lua vim.lsp.buf.signature_help()") +vim.keymap.set("n", "1gd", "lua vim.lsp.buf.type_definition()") +vim.keymap.set("n", "gf", "lua vim.lsp.buf.formatting()") +vim.keymap.set("n", "rn", "lua vim.lsp.buf.rename()") +vim.keymap.set("n", "[d", "lua vim.lsp.diagnostic.goto_prev()") +vim.keymap.set("n", "]d", "lua vim.lsp.diagnostic.goto_next()") +vim.keymap.set("n", "gwa", "lua vim.lsp.buf.add_workspace_folder()") +vim.keymap.set("n", "gwr", "lua vim.lsp.buf.add_workspace_folder()") +vim.keymap.set("n", "gwl", "lua vim.lsp.buf.add_workspace_folder()") + +local border = { + { "🭽", "FloatBorder" }, + { "▔", "FloatBorder" }, + { "🭾", "FloatBorder" }, + { "▕", "FloatBorder" }, + { "🭿", "FloatBorder" }, + { "▁", "FloatBorder" }, + { "🭼", "FloatBorder" }, + { "▏", "FloatBorder" }, +} + +vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }) +vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }) vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { update_in_insert = false, virtual_text = false, }) + local signs = { Error = "🔥", Warn = "⚠️ ", Hint = "💡", Info = "💡" } for type, icon in pairs(signs) do local hl = "DiagnosticSign" .. type @@ -24,6 +47,7 @@ end local servers = { "bashls", "dockerls", + "gopls", "jsonls", -- "sql", "pyright", diff --git a/.config/nvim/lua/plugins/nvim-dap-go.lua b/.config/nvim/lua/plugins/nvim-dap-go.lua index eb8ae9a..20807d9 100644 --- a/.config/nvim/lua/plugins/nvim-dap-go.lua +++ b/.config/nvim/lua/plugins/nvim-dap-go.lua @@ -1,6 +1,5 @@ -local dapgo = require('dap-go') -local map = require('dln.utils').map -local silent = { silent=true } +local dapgo = require("dap-go") +local silent = { silent = true } dapgo.setup() -map("n", "y", ":lua require('dap-go').debug_test()", silent) +vim.keymap.set("n", "y", ":lua require('dap-go').debug_test()", silent) diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua index 40982bf..60233d3 100644 --- a/.config/nvim/lua/settings.lua +++ b/.config/nvim/lua/settings.lua @@ -62,29 +62,8 @@ vim.o.fillchars = "stl: ,stlnc: " -- vim.o.titlestring = "%F%m %r %y" vim.wo.foldmethod = "expr" vim.wo.foldexpr = "nvim_treesitter#foldexpr()" - ---- Key mappings -local map = require("dln.utils").map -map("n", "", ':let @/=""') -- clear search -map("n", "H", "^") -map("n", "L", "$") -map("i", "", "") - -map("n", ",L", ":luafile %") -- Reload lua file - ---- Plugins vim.g.netrw_dirhistmax = 0 -local border = { - { "🭽", "FloatBorder" }, - { "▔", "FloatBorder" }, - { "🭾", "FloatBorder" }, - { "▕", "FloatBorder" }, - { "🭿", "FloatBorder" }, - { "▁", "FloatBorder" }, - { "🭼", "FloatBorder" }, - { "▏", "FloatBorder" }, -} - -vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }) -vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }) +--- Key mappings +vim.keymap.set("n", "", ':let @/=""') -- clear search +vim.keymap.set("n", ",L", ":luafile %") -- Reload lua file