nvim: cleanup plugin conf. deprecate dln.utils

This commit is contained in:
Daniel Lundin 2022-09-10 12:17:35 +02:00
parent 688587e9ab
commit 5364b16285
7 changed files with 41 additions and 71 deletions

View file

@ -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

View file

@ -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", "<Cmd>lua vim.lsp.buf.hover()<CR>")
map("i", "<C-k>", "<Cmd>lua vim.lsp.buf.signature_help()<CR>")
map("n", "1gd", "<Cmd>lua vim.lsp.buf.type_definition()<CR>")
map("n", "gf", "<Cmd>lua vim.lsp.buf.formatting()<CR>")
map("n", "rn", "<Cmd>lua vim.lsp.buf.rename()<CR>")
map("n", "[d", "<Cmd>lua vim.lsp.diagnostic.goto_prev()<CR>")
map("n", "]d", "<Cmd>lua vim.lsp.diagnostic.goto_next()<CR>")
map("n", "gwa", "<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>")
map("n", "gwr", "<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>")
map("n", "gwl", "<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>")
require("plugins/lsp-config")
end,
})

View file

@ -1,5 +1,4 @@
local map = require("dln.utils").map
map("i", "<C-J>", [[copilot#Accept("\<CR>")]], { noremap = true, silent = true, expr = true, script = true })
vim.keymap.set("i", "<C-J>", [[copilot#Accept("\<CR>")]], { noremap = true, silent = true, expr = true, script = true })
vim.g.copilot_no_tab_map = true
vim.g.copilot_assume_mapped = true

View file

@ -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()<CR>", silent)
map("n", "Dc", ":lua require 'dap'.continue()<CR>", silent)
map("n", "Di", ":lua require 'dap'.step_into()<CR>", silent)
map("n", "Do", ":lua require 'dap'.step_over()<CR>", silent)
map("n", "DO", ":lua require 'dap'.step_out()<CR>", silent)
map("n", "Dr", ":lua require 'dap'.repl.toggle({height = 5})<CR>", silent)
map("n", "Dh", ":lua require 'dap.ui.widgets'.hover()<CR>", silent)
vim.keymap.set("n", "DD", ":lua require 'dap'.toggle_breakpoint()<CR>", silent)
vim.keymap.set("n", "Dc", ":lua require 'dap'.continue()<CR>", silent)
vim.keymap.set("n", "Di", ":lua require 'dap'.step_into()<CR>", silent)
vim.keymap.set("n", "Do", ":lua require 'dap'.step_over()<CR>", silent)
vim.keymap.set("n", "DO", ":lua require 'dap'.step_out()<CR>", silent)
vim.keymap.set("n", "Dr", ":lua require 'dap'.repl.toggle({height = 5})<CR>", silent)
vim.keymap.set("n", "Dh", ":lua require 'dap.ui.widgets'.hover()<CR>", silent)

View file

@ -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", "<Cmd>lua vim.lsp.buf.hover()<CR>")
vim.keymap.set("i", "<C-k>", "<Cmd>lua vim.lsp.buf.signature_help()<CR>")
vim.keymap.set("n", "1gd", "<Cmd>lua vim.lsp.buf.type_definition()<CR>")
vim.keymap.set("n", "gf", "<Cmd>lua vim.lsp.buf.formatting()<CR>")
vim.keymap.set("n", "rn", "<Cmd>lua vim.lsp.buf.rename()<CR>")
vim.keymap.set("n", "[d", "<Cmd>lua vim.lsp.diagnostic.goto_prev()<CR>")
vim.keymap.set("n", "]d", "<Cmd>lua vim.lsp.diagnostic.goto_next()<CR>")
vim.keymap.set("n", "gwa", "<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>")
vim.keymap.set("n", "gwr", "<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>")
vim.keymap.set("n", "gwl", "<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>")
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",

View file

@ -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", "<leader>y", ":lua require('dap-go').debug_test()<CR>", silent)
vim.keymap.set("n", "<leader>y", ":lua require('dap-go').debug_test()<CR>", silent)

View file

@ -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", "<C-l>", ':let @/=""<CR>') -- clear search
map("n", "H", "^")
map("n", "L", "$")
map("i", "", "<C-w>")
map("n", ",L", ":luafile %<CR>") -- 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", "<C-l>", ':let @/=""<CR>') -- clear search
vim.keymap.set("n", ",L", ":luafile %<CR>") -- Reload lua file