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

@ -2,7 +2,10 @@ local M = {}
local HOME = os.getenv("HOME") local HOME = os.getenv("HOME")
local SDKMAN_DIR = os.getenv("SDKMAN_DIR") local SDKMAN_DIR = os.getenv("SDKMAN_DIR")
local lsp = require("lsp") local lsp = require("lsp")
local map = lsp.map
local jdtls = require("jdtls") local jdtls = require("jdtls")
local bundles = {} local bundles = {}
@ -25,31 +28,18 @@ local function nnoremap(rhs, lhs, bufopts, desc)
end end
local on_attach = function(client, bufnr) local on_attach = function(client, bufnr)
lsp.default_config.on_attach(client, bufnr)
require("jdtls").setup_dap({ hotcodereplace = "auto" }) require("jdtls").setup_dap({ hotcodereplace = "auto" })
require("jdtls.dap").setup_dap_main_class_configs() require("jdtls.dap").setup_dap_main_class_configs()
require("jdtls.setup").add_commands() 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 -- Java extensions provided by jdtls
nnoremap("<leader>lo", jdtls.organize_imports, bufopts, "Organize imports") map("n", "<leader>lo", jdtls.organize_imports, { bufnr, "Organize Imports" })
nnoremap("<leader>le", jdtls.extract_variable, bufopts, "Extract variable") map("n", "<leader>lle", jdtls.extract_variable, { bufnr, "Extract Variable" })
nnoremap("<leader>lc", jdtls.extract_constant, bufopts, "Extract constant") map("n", "<leader>llc", jdtls.extract_constant, { bufnr, "Extract Constant" })
vim.keymap.set( map("v", "<leader>llm", "<ESC><CMD>lua require('jdtls').extract_method(true)<CR>", { bufnr, "Extract Method" })
"v", map("n", "<leader>ltc", jdtls.test_class, { bufnr, "Test Class (DAP)" })
"<leader>lm", map("n", "<leader>ltm", jdtls.test_nearest_method, { bufnr, "Test Method (DAP)" })
[[<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)")
end end
function M.make_jdtls_config(root_dir, workspace_folder) function M.make_jdtls_config(root_dir, workspace_folder)

@ -3,7 +3,6 @@ return {
"goolord/alpha-nvim", "goolord/alpha-nvim",
config = function() config = function()
local alpha = require("alpha") local alpha = require("alpha")
-- require("alpha.term")
local dashboard = require("alpha.themes.dashboard") local dashboard = require("alpha.themes.dashboard")
dashboard.section.header.val = { dashboard.section.header.val = {
[[================= =============== =============== ======== ========]], [[================= =============== =============== ======== ========]],
@ -28,16 +27,15 @@ return {
} }
dashboard.section.buttons.val = { dashboard.section.buttons.val = {
dashboard.button("f", " Find a file", ":Telescope find_files<CR>"), dashboard.button("f", " Find File", ":Telescope find_files<CR>"),
dashboard.button("e", " New file", ":ene <BAR> startinsert<CR>"), dashboard.button("e", " New File", ":ene <BAR> startinsert<CR>"),
dashboard.button("p", " Find a project", ":Telescope projects<CR>"), dashboard.button("p", " Find Project", ":Telescope projects<CR>"),
dashboard.button("r", " Recently used files", ":Telescope oldfiles<CR>"), dashboard.button("r", " Recent Files", ":Telescope oldfiles<CR>"),
dashboard.button("t", " Find text", ":Telescope live_grep<CR>"), dashboard.button("t", " Find Text", ":Telescope live_grep<CR>"),
dashboard.button("c", " Configuration", ":e $MYVIMRC<CR>"), dashboard.button("c", " Configuration", ":e $MYVIMRC<CR>"),
dashboard.button("q", " Quit Neovim", ":qa<CR>"), dashboard.button("q", " Quit Neovim", ":qa<CR>"),
} }
local function footer() local function footer()
-- Number of plugins
local total_plugins = require("lazy").stats().count local total_plugins = require("lazy").stats().count
local datetime = os.date("%d-%m-%Y %H:%M:%S") local datetime = os.date("%d-%m-%Y %H:%M:%S")
local plugins_text = "" local plugins_text = ""
@ -56,18 +54,10 @@ return {
dashboard.section.footer.val = footer() dashboard.section.footer.val = footer()
dashboard.section.footer.opts.hl = "Type" dashboard.section.footer.opts.hl = "Type"
-- dashboard.section.header.opts.hl = "Include"
dashboard.section.buttons.opts.hl = "Keyword" dashboard.section.buttons.opts.hl = "Keyword"
dashboard.opts.opts.noautocmd = false 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 = { dashboard.config.layout = {
{ type = "padding", val = 3 }, { type = "padding", val = 3 },
dashboard.section.header, dashboard.section.header,
@ -76,9 +66,6 @@ return {
{ type = "padding", val = 1 }, { type = "padding", val = 1 },
dashboard.section.footer, dashboard.section.footer,
} }
dashboard.config.setup = function()
vim.b.miniindentscope_disable = true
end
alpha.setup(dashboard.opts) alpha.setup(dashboard.opts)
end, 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 { return {
-- snippets
{ {
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
dependencies = { dependencies = {
@ -59,27 +53,6 @@ return {
["<C-Space>"] = cmp.mapping.complete({}), ["<C-Space>"] = cmp.mapping.complete({}),
["<C-e>"] = cmp.mapping.abort(), ["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }), ["<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({ sources = cmp.config.sources({
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
@ -134,6 +107,7 @@ return {
"hrsh7th/cmp-cmdline", "hrsh7th/cmp-cmdline",
"saadparwaiz1/cmp_luasnip", "saadparwaiz1/cmp_luasnip",
"lukas-reineke/cmp-under-comparator", "lukas-reineke/cmp-under-comparator",
"onsails/lspkind.nvim",
}, },
}, },
} }

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

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

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

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

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

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

Loading…
Cancel
Save