refactor(nvim): remove comments and refactor binds

chezmoi
sgoudham 2 years ago
parent 8fdeb50884
commit 1f97480ac0
Signed by: hammy
GPG Key ID: 44E818FD5457EEA4

@ -1,53 +1,38 @@
local M = {}
M.default_config = {
on_attach = function(client, bufnr)
require("lsp_signature").on_attach({}, bufnr)
-- add lsp-only keybinds
local map = function(sequence, cmd, desc)
vim.keymap.set("n", sequence, cmd, { buffer = bufnr, desc = desc })
local map = function(mode, lhs, rhs, opts)
vim.keymap.set(mode, lhs, rhs, { buffer = opts[1], desc = opts[2] })
end
M.map = map
map("K", vim.lsp.buf.hover, "Hover")
map("]d", vim.diagnostic.goto_next, "Next diagnostic")
map("[d", vim.diagnostic.goto_prev, "Previous diagnostic")
M.default_config = {
on_attach = function(_, bufnr)
map("n", "K", vim.lsp.buf.hover, { bufnr, "Hover Information" })
map("n", "]d", vim.diagnostic.goto_next, { bufnr, "Next Diagnostic" })
map("n", "[d", vim.diagnostic.goto_prev, { bufnr, "Previous Diagnostic" })
map("gs", vim.lsp.buf.signature_help, "LSP Signature Help")
map("gD", vim.lsp.buf.declaration, "LSP Declarations")
map("gd", function()
require("telescope.builtin").lsp_definitions()
end, "LSP Definitions")
map("gT", function()
require("telescope.builtin").lsp_type_definitions()
end, "LSP Type Definitions")
map("gr", function()
require("telescope.builtin").lsp_references()
end, "LSP References")
map("gI", function()
require("telescope.builtin").lsp_implementations()
end, "LSP Implementations")
map("gl", function()
vim.diagnostic.open_float(0, {
scope = "line",
})
end)
map("n", "gs", vim.lsp.buf.signature_help, { bufnr, "Signature Help" })
map("n", "gD", vim.lsp.buf.declaration, { bufnr, "Declarations" })
map("n", "gd", "<cmd>Telescope lsp_definitions<CR>", { bufnr, "Definitions" })
map("n", "gT", "<cmd>Telescope lsp_type_definitions<CR>", { bufnr, "Type Definitions" })
map("n", "gr", "<cmd>Telescope lsp_references<CR>", { bufnr, "References" })
map("n", "gI", "<cmd>Telescope lsp_implementations<CR>", { bufnr, "Implementations" })
map("n", "gl", function()
vim.diagnostic.open_float(0, { scope = "line" })
end, { bufnr, "LSP Line Diagnostics" })
map("<leader>la", vim.lsp.buf.code_action, "Code Action")
map("<leader>lr", vim.lsp.buf.rename, "Rename")
map("<leader>lf", vim.lsp.buf.format, "Format")
map("<leader>ld", function()
require("telescope.builtin").diagnostics()
end, "LSP Workplace Diagnostics")
map("<leader>lD", function()
require("telescope.builtin").diagnostics({ bufnr = 0 })
end, "LSP Buffer Diagnostics")
map("<leader>ls", function()
require("telescope.builtin").lsp_document_symbols()
end, "LSP Document Symbols")
map("<leader>lS", function()
require("telescope.builtin").lsp_workspace_symbols()
end, "LSP Workplace Symbols")
map("n", "<leader>la", vim.lsp.buf.code_action, { bufnr, "Code Action" })
map("n", "<leader>lr", vim.lsp.buf.rename, { bufnr, "Rename" })
map("n", "<leader>lf", vim.lsp.buf.format, { bufnr, "Format" })
map("n", "<leader>ld", "<cmd>Telescope diagnostics<CR>", { bufnr, "Workspace Diagnostics" })
map("n", "<leader>lD", "<cmd>Telescope diagnostics bufnr=0<CR>", { bufnr, "Buffer Diagnostics" })
map("n", "<leader>ls", "<cmd>Telescope lsp_document_symbols<CR>", { bufnr, "Document Symbols" })
map("n", "<leader>lS", "<cmd>Telescope lsp_workspace_symbols<CR>", { bufnr, "Workspace Symbols" })
map("n", "<leader>lwa", vim.lsp.buf.add_workspace_folder, { bufnr, "Add Workspace Folder" })
map("n", "<leader>lwr", vim.lsp.buf.remove_workspace_folder, { bufnr, "Remove Workspace Folder" })
map("n", "<leader>lwl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, { bufnr, "List Workspace Folders" })
end,
}

@ -2,7 +2,10 @@ local M = {}
local HOME = os.getenv("HOME")
local SDKMAN_DIR = os.getenv("SDKMAN_DIR")
local lsp = require("lsp")
local map = lsp.map
local jdtls = require("jdtls")
local bundles = {}
@ -25,31 +28,18 @@ local function nnoremap(rhs, lhs, bufopts, desc)
end
local on_attach = function(client, bufnr)
lsp.default_config.on_attach(client, bufnr)
require("jdtls").setup_dap({ hotcodereplace = "auto" })
require("jdtls.dap").setup_dap_main_class_configs()
require("jdtls.setup").add_commands()
lsp.default_config.on_attach(client, bufnr)
-- Regular Neovim LSP client keymappings
local bufopts = { noremap = true, silent = true, buffer = bufnr }
nnoremap("<leader>lwa", vim.lsp.buf.add_workspace_folder, bufopts, "Add workspace folder")
nnoremap("<leader>lwr", vim.lsp.buf.remove_workspace_folder, bufopts, "Remove workspace folder")
nnoremap("<leader>lwl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts, "List workspace folders")
-- Java extensions provided by jdtls
nnoremap("<leader>lo", jdtls.organize_imports, bufopts, "Organize imports")
nnoremap("<leader>le", jdtls.extract_variable, bufopts, "Extract variable")
nnoremap("<leader>lc", jdtls.extract_constant, bufopts, "Extract constant")
vim.keymap.set(
"v",
"<leader>lm",
[[<ESC><CMD>lua require('jdtls').extract_method(true)<CR>]],
{ noremap = true, silent = true, buffer = bufnr, desc = "Extract method" }
)
nnoremap("<leader>tc", jdtls.test_class, bufopts, "Test class (DAP)")
nnoremap("<leader>tm", jdtls.test_nearest_method, bufopts, "Test method (DAP)")
map("n", "<leader>lo", jdtls.organize_imports, { bufnr, "Organize Imports" })
map("n", "<leader>lle", jdtls.extract_variable, { bufnr, "Extract Variable" })
map("n", "<leader>llc", jdtls.extract_constant, { bufnr, "Extract Constant" })
map("v", "<leader>llm", "<ESC><CMD>lua require('jdtls').extract_method(true)<CR>", { bufnr, "Extract Method" })
map("n", "<leader>ltc", jdtls.test_class, { bufnr, "Test Class (DAP)" })
map("n", "<leader>ltm", jdtls.test_nearest_method, { bufnr, "Test Method (DAP)" })
end
function M.make_jdtls_config(root_dir, workspace_folder)

@ -3,7 +3,6 @@ return {
"goolord/alpha-nvim",
config = function()
local alpha = require("alpha")
-- require("alpha.term")
local dashboard = require("alpha.themes.dashboard")
dashboard.section.header.val = {
[[================= =============== =============== ======== ========]],
@ -28,16 +27,15 @@ return {
}
dashboard.section.buttons.val = {
dashboard.button("f", " Find a file", ":Telescope find_files<CR>"),
dashboard.button("e", " New file", ":ene <BAR> startinsert<CR>"),
dashboard.button("p", " Find a project", ":Telescope projects<CR>"),
dashboard.button("r", " Recently used files", ":Telescope oldfiles<CR>"),
dashboard.button("t", " Find text", ":Telescope live_grep<CR>"),
dashboard.button("f", " Find File", ":Telescope find_files<CR>"),
dashboard.button("e", " New File", ":ene <BAR> startinsert<CR>"),
dashboard.button("p", " Find Project", ":Telescope projects<CR>"),
dashboard.button("r", " Recent Files", ":Telescope oldfiles<CR>"),
dashboard.button("t", " Find Text", ":Telescope live_grep<CR>"),
dashboard.button("c", " Configuration", ":e $MYVIMRC<CR>"),
dashboard.button("q", " Quit Neovim", ":qa<CR>"),
}
local function footer()
-- Number of plugins
local total_plugins = require("lazy").stats().count
local datetime = os.date("%d-%m-%Y %H:%M:%S")
local plugins_text = ""
@ -56,18 +54,10 @@ return {
dashboard.section.footer.val = footer()
dashboard.section.footer.opts.hl = "Type"
-- dashboard.section.header.opts.hl = "Include"
dashboard.section.buttons.opts.hl = "Keyword"
dashboard.opts.opts.noautocmd = false
-- local width = 52 -- 104
-- local height = 15 -- 28
-- dashboard.section.terminal.command = "cat | " .. os.getenv("HOME") .. "/.config/nvim/doom/render.sh"
-- dashboard.section.terminal.width = width
-- dashboard.section.terminal.height = height
-- dashboard.section.terminal.opts.redraw = true
--
dashboard.config.layout = {
{ type = "padding", val = 3 },
dashboard.section.header,
@ -76,9 +66,6 @@ return {
{ type = "padding", val = 1 },
dashboard.section.footer,
}
dashboard.config.setup = function()
vim.b.miniindentscope_disable = true
end
alpha.setup(dashboard.opts)
end,

@ -1,10 +1,4 @@
-- local has_words_before = function()
-- local line, col = unpack(vim.api.nvim_win_get_cursor(0))
-- return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
-- end
--
return {
-- snippets
{
"L3MON4D3/LuaSnip",
dependencies = {
@ -59,27 +53,6 @@ return {
["<C-Space>"] = cmp.mapping.complete({}),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
-- ["<Tab>"] = cmp.mapping(function(fallback)
-- if cmp.visible() then
-- cmp.select_next_item()
-- elseif luasnip.expand_or_jumpable() then
-- luasnip.expand_or_jump()
-- elseif has_words_before() then
-- cmp.complete()
-- else
-- fallback()
-- end
-- end, { "i", "s" }),
--
-- ["<S-Tab>"] = cmp.mapping(function(fallback)
-- if cmp.visible() then
-- cmp.select_prev_item()
-- elseif luasnip.jumpable(-1) then
-- luasnip.jump(-1)
-- else
-- fallback()
-- end
-- end, { "i", "s" }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
@ -134,6 +107,7 @@ return {
"hrsh7th/cmp-cmdline",
"saadparwaiz1/cmp_luasnip",
"lukas-reineke/cmp-under-comparator",
"onsails/lspkind.nvim",
},
},
}

@ -67,7 +67,6 @@ return {
-- apply suggestions from catppuccin theme
local sign = vim.fn.sign_define
sign("DapBreakpoint", { text = "", texthl = "DapBreakpoint", linehl = "DapBreakpointLinehl", numhl = "" })
sign("DapStopped", { text = "", texthl = "Error", linehl = "DapStoppedLinehl", numhl = "" })
sign("DapBreakpointCondition", { text = "", texthl = "DapBreakpointCondition", linehl = "", numhl = "" })
@ -116,7 +115,6 @@ return {
{ id = "stacks", size = 0.15, },
{ id = "repl", size = 0.05, },
{ id = "scopes", size = 0.40, },
-- { id = "breakpoints", size = 0.25, },
{ id = "watches", size = 0.40, },
},
position = "left",

@ -9,7 +9,6 @@ return {
components = ctp_feline.get(),
force_inactive = {
filetypes = {
-- "^NvimTree$",
"^packer$",
"^startify$",
"^fugitive$",

@ -1,7 +1,6 @@
return {
{
"lewis6991/gitsigns.nvim",
priority = 500,
config = function()
require("gitsigns").setup({
on_attach = function(bufnr)
@ -47,10 +46,6 @@ return {
gs.blame_line({ full = true })
end, {}, "Show Blame")
map("n", "<leader>gb", gs.toggle_current_line_blame, {}, "Current Line Blame")
-- map("n", "<leader>gd", gs.diffthis, {}, "Diff This")
-- map("n", "<leader>gD", function()
-- gs.diffthis("~")
-- end, {}, "")
map("n", "<leader>gd", gs.toggle_deleted, {}, "Show Deleted")
-- Text object

@ -36,13 +36,26 @@ return {
"williamboman/mason-lspconfig.nvim",
config = function()
require("mason-lspconfig").setup({
ensure_installed = { "rust_analyzer", "pyright", "sumneko_lua" },
ensure_installed = { "rust_analyzer", "pyright", "lua_ls" },
})
require("mason-lspconfig").setup_handlers({
-- default handler
function(server_name)
require("lspconfig")[server_name].setup(lsp.default_config)
end,
["ltex"] = function()
require("lspconfig")["ltex"].setup({
on_attach = function(_, _)
require("ltex_extra").setup({
load_langs = { "es-AR", "en-US" },
init_check = true,
path = vim.fn.stdpath("data") .. "/dictionary",
})
end,
})
end,
["rust_analyzer"] = function()
-- https://github.com/simrat39/rust-tools.nvim/issues/300
local config = custom_config({
@ -67,9 +80,11 @@ return {
},
})
end,
["pyright"] = function()
require("py_lsp").setup(lsp.default_config)
end,
["hls"] = function()
local ht = require("haskell-tools")
local def_opts = { noremap = true, silent = true }
@ -86,15 +101,16 @@ return {
})
-- Suggested keymaps that do not depend on haskell-language-server
-- Toggle a GHCi repl for the current package
vim.keymap.set("n", "<leader>rr", ht.repl.toggle, def_opts)
-- vim.keymap.set("n", "<leader>rr", ht.repl.toggle, def_opts)
-- Toggle a GHCi repl for the current buffer
vim.keymap.set("n", "<leader>rf", function()
ht.repl.toggle(vim.api.nvim_buf_get_name(0))
end, def_opts)
vim.keymap.set("n", "<leader>rq", ht.repl.quit, def_opts)
-- vim.keymap.set("n", "<leader>rf", function()
-- ht.repl.toggle(vim.api.nvim_buf_get_name(0))
-- end, def_opts)
-- vim.keymap.set("n", "<leader>rq", ht.repl.quit, def_opts)
end,
["sumneko_lua"] = function()
require("lspconfig")["sumneko_lua"].setup(custom_config({
["lua_ls"] = function()
require("lspconfig")["lua_ls"].setup(custom_config({
settings = {
Lua = {
format = {
@ -126,8 +142,15 @@ return {
"mrcjkb/haskell-tools.nvim",
"HallerPatrick/py_lsp.nvim",
"mfussenegger/nvim-jdtls",
"onsails/lspkind.nvim",
{
"ray-x/lsp_signature.nvim",
opts = {
hint_enable = false,
hint_prefix = "",
},
},
"barreiroleo/ltex_extra.nvim",
"lervag/vimtex",
},
},
{
@ -155,7 +178,7 @@ return {
{
"jay-babu/mason-null-ls.nvim",
opts = {
ensure_installed = { "stylua" },
ensure_installed = { "stylua", "markdownlint", "clang-format" },
},
},
}

@ -1,3 +1,6 @@
return {
{ "kylechui/nvim-surround", config = true },
{
"kylechui/nvim-surround",
config = true,
},
}

@ -29,6 +29,10 @@ return {
dependencies = {
"nvim-treesitter/nvim-treesitter-textobjects",
"nvim-treesitter/playground",
{
"kana/vim-textobj-entire",
dependencies = { "kana/vim-textobj-user" },
},
},
},
}

Loading…
Cancel
Save