diff --git a/.config/nvim/TODO b/.config/nvim/TODO new file mode 100644 index 00000000..a1baa533 --- /dev/null +++ b/.config/nvim/TODO @@ -0,0 +1,2 @@ +TODO: Carry over some of the old plugins +TODO: Set up whichkey diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 17bf9c88..387e05c1 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,10 +1,11 @@ require 'user.plugins' -require 'user.keybinds' +require 'user.keymaps' require 'user.options' require 'user.autocmds' require 'user.theme' require 'user.cmp' require 'user.plugins.telescope' +require 'user.plugins.whichkey' require 'user.plugins.gitsigns' require 'user.plugins.treesitter' require 'user.plugins.autopairs' @@ -18,5 +19,4 @@ require 'user.plugins.impatient' require 'user.plugins.illuminate' require 'user.plugins.indentline' require 'user.plugins.alpha' -require 'user.lsp' -require 'user.dap' +require 'user.adapters' diff --git a/.config/nvim/lua/autocmdlist.lua b/.config/nvim/lua/autocmdlist.lua new file mode 100644 index 00000000..cf64e973 --- /dev/null +++ b/.config/nvim/lua/autocmdlist.lua @@ -0,0 +1,115 @@ +return { + { -- Handles the automatic line numeration changes + { "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, + { + pattern = "*", + command="if &nu && mode() != \"i\" | set rnu | endif" + } + }, + { -- Handles the automatic line numeration changes + { "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, + { + pattern = "*", + command="if &nu | set nornu | endif" + } + }, + { + "FileType", + { + pattern = "zsh", + callback = function() + require("nvim-treesitter.highlight").attach(0, "bash") + end + } + }, + { + "BufWritePost", + { + pattern = { "bm-files", "bm-dirs" }, + command = "!shortcuts" + } + }, + { + { "BufRead", "BufNewFile" }, + { + pattern = { "Xresources", "Xdefaults", "xresources", "xdefaults" }, + command = "set filetype=xdefaults" + } + }, + { + "BufWritePost", + { + pattern = { "Xresources", "Xdefaults", "xresources", "xdefaults" }, + command = "!xrdb %" + } + }, + { + "BufWritePost", + { + pattern = "~/.local/src/dwmblocks/config.h", + command = "!cd ~/.local/src/dwmblocks/; sudo make install && { killall -q dwmblocks;setsid -f dwmblocks }" + } + }, + { + "BufWritePost", + { + pattern = "*.java", + callback = function() + vim.lsp.codelens.refresh() + end + } + }, + { + { "BufDelete", "VimLeave" }, + { + pattern = "*.tex", + command = "!texclear \"%:p\"" + } + }, + { -- Use 'q' to quit from common plugins + 'FileType', + { + pattern = { "qf", "help", "man", "lspinfo", "spectre_panel", "lir" }, + callback = function() + vim.cmd [[ + nnoremap q :close + set nobuflisted + ]] + end + } + }, + { + 'Filetype', + { + pattern = { "gitcommit", "markdown" }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, + } + }, + { -- Automatically apply changes to plugins.lua + 'BufWritePost', + { + group = 'packer_user_config', + pattern = { "plugins.lua", "pluginlist.lua" }, + command = "source | PackerCompile" + } + }, + { -- Fix auto comment + 'BufWinEnter', + { + callback = function() + vim.cmd("set formatoptions-=cro") + end + } + }, + { -- Highlight yanked text + 'TextYankPost', + { + callback = function() + vim.highlight.on_yank({ higroup = "Visual", timeout = 200 }) + end + } + } +} diff --git a/.config/nvim/lua/icons.lua b/.config/nvim/lua/iconlist.lua similarity index 94% rename from .config/nvim/lua/icons.lua rename to .config/nvim/lua/iconlist.lua index d0f0cf69..db793bc7 100644 --- a/.config/nvim/lua/icons.lua +++ b/.config/nvim/lua/iconlist.lua @@ -40,8 +40,8 @@ return { LineModified = "", LineRemoved = "", FileDeleted = "", - FileIgnored = "◌", - FileRenamed = "➜", + FileIgnored = "", + FileRenamed = "", FileStaged = "S", FileUnmerged = "", FileUnstaged = "", @@ -49,7 +49,7 @@ return { Diff = "", Repo = "", Octoface = "", - Branch = "", + Branch = "", }, ui = { ArrowCircleDown = "", @@ -142,6 +142,7 @@ return { Debug = "", Trace = "✎", }, + progress = { "", "", "", "", "", "", "", "", "", "", "", "", "" }, misc = { Robot = "ﮧ", Squirrel = "", diff --git a/.config/nvim/lua/keymaplist.lua b/.config/nvim/lua/keymaplist.lua new file mode 100644 index 00000000..579f9b96 --- /dev/null +++ b/.config/nvim/lua/keymaplist.lua @@ -0,0 +1,166 @@ +local kbopts = { silent = true, noremap = true } + +return { + kb = { + ['n'] = { -- normal mode + -- Better window navigation + {"", "h", kbopts}, + {"", "j", kbopts}, + {"", "k", kbopts}, + {"", "l", kbopts}, + -- Resize with arrows + {"", ":resize -2", kbopts}, + {"", ":resize +2", kbopts}, + {"", ":vertical resize -2", kbopts}, + {"", ":vertical resize +2", kbopts}, + -- Navigate buffers + {"", ":bnext", kbopts}, + {"", ":bprevious", kbopts}, + -- LSP + {"gD", "lua vim.lsp.buf.declaration()", kbopts}, + {"gd", "lua vim.lsp.buf.definition()", kbopts}, + {"K", "lua vim.lsp.buf.hover()", kbopts}, + {"gI", "lua vim.lsp.buf.implementation()", kbopts}, + {"gr", "lua vim.lsp.buf.references()", kbopts}, + {"gl", "lua vim.diagnostic.open_float()", kbopts}, + -- Illuminate + {'', "lua require('illuminate').next_reference{wrap=true}", kbopts}, + {'', "lua require('illuminate').next_reference{reverse=true,wrap=true}", kbopts}, + }, + ['i'] = { -- insert mode + -- Delete last word with ctrl + del + {"", "", kbopts}, + }, + ['v'] = { -- visual mode + -- Better paste + {"p", '"_dP', kbopts}, + -- Stay in indent mode + {"<", "", ">gv", kbopts}, + }, + ['x'] = { -- visual block mode + }, + ['t'] = { -- terminal mode + }, + ['c'] = { -- command mode + } + }, + wk = { + vopts = { + mode = "n", + prefix = "", + buffer = nil, + silent = true, + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps + }, + nopts = { + mode = "n", + prefix = "", + buffer = nil, + silent = true, + noremap = true, + nowait = true, + }, + vmaps = { + ["/"] = { "(comment_toggle_linewise_visual)", "Comment toggle linewise (visual)" }, + }, + nmaps = { + [";"] = { "Alpha", "Dashboard" }, + ["/"] = { "(comment_toggle_linewise_current)", "Comment toggle current line" }, + ["w"] = { "w!", "Save" }, + ["c"] = { require("user.funcs").buf_kill, "Close" }, + -- TODO: filepicker ["f"] = {}, + ["h"] = { "nohlsearch", "Clear Highlights" }, + ["e"] = { "NvimTreeToggle", "Toggle Filetree" }, + b = { + name = "Buffers", + j = { "BufferLinePick", "Jump" }, + f = { "Telescope buffers", "Find" }, + b = { "BufferLineCyclePrev", "Previous" }, + n = { "BufferLineCycleNext", "Next" }, + e = { "BufferLinePickClose", "Pick which buffer to close" }, + h = { "BufferLineCloseLeft", "Close all to the left" }, + l = { "BufferLineCloseRight", "Close all to the right" }, + D = { "BufferLineSortByDirectory", "Sort by directory" }, + L = { "BufferLineSortByExtension", "Sort by language" }, + }, + p = { + name = "Packer", + c = { "PackerCompile", "Compile" }, + i = { "PackerInstall", "Install" }, + s = { "PackerSync", "Sync" }, + S = { "PackerStatus", "Status" }, + u = { "PackerUpdate", "Update" }, + }, + g = { + name = "Git", + j = { require("gitsigns").next_hunk, "Next Hunk" }, + k = { require("gitsigns").prev_hunk, "Prev Hunk" }, + l = { require("gitsigns").blame_line, "Blame" }, + p = { require("gitsigns").preview_hunk, "Preview Hunk" }, + r = { require("gitsigns").reset_hunk, "Reset Hunk" }, + R = { require("gitsigns").reset_buffer, "Reset Buffer" }, + s = { require("gitsigns").stage_hunk, "Stage Hunk" }, + u = { require("gitsigns").undo_stage_hunk, "Undo Stage Hunk" }, + o = { "Telescope git_status", "Open changed file" }, + b = { "Telescope git_branches", "Checkout branch" }, + c = { "Telescope git_commits", "Checkout commit" }, + C = { "Telescope git_bcommits", "Checkout commit(for current file)" }, + d = { "Gitsigns diffthis HEAD", "Git Diff" }, + g = { _LAZYGIT_TOGGLE, "Toggle Lazygit"} + }, + l = { + name = "LSP", + a = { vim.lsp.buf.code_action, "Code Action" }, + d = { "Telescope diagnostics bufnr=0 theme=get_ivy", "Buffer Diagnostics" }, + w = { "Telescope diagnostics", "Diagnostics" }, + f = { vim.lsp.buf.format{ async = true }, "Format" }, + i = { "LspInfo", "Info" }, + I = { "Mason", "Mason Info" }, + j = { vim.diagnostic.goto_next, "Next Diagnostic" }, + k = { vim.diagnostic.goto_prev, "Prev Diagnostic" }, + l = { vim.lsp.codelens.run, "CodeLens Action" }, + q = { vim.diagnostic.setloclist, "Quickfix" }, + r = { vim.lsp.buf.rename, "Rename" }, + s = { "Telescope lsp_document_symbols", "Document Symbols" }, + S = { "Telescope lsp_dynamic_workspace_symbols", "Workspace Symbols" }, + e = { "Telescope quickfix", "Telescope Quickfix" }, + }, + d = { + name = "DAP", + b = { require('dap').toggle_breakpoint, "Toggle Breakpoint"}, + c = { require('dap').continue, "Continue"}, + i = { require('dap').step_into, "Step Into"}, + o = { require('dap').step_over, "Step Over"}, + O = { require('dap').step_out, "Step Out"}, + r = { require('dap').repl.toggle, "Toggle REPL"}, + l = { require('dap').run_last, "Run Last"}, + u = { require('dapui').toggle, "Toggle DAP UI"}, + t = { require('dap').terminate, "Stop Debugger"}, + }, + u = { + name = "Utility", + c = { "w!!compiler \"%:p\"", "Compile" }, + }, + s = { + name = "Search", + b = { "Telescope git_branches", "Checkout branch" }, + c = { "Telescope colorscheme", "Colorscheme" }, + f = { "Telescope find_files", "Find File" }, + h = { "Telescope help_tags", "Find Help" }, + H = { "Telescope highlights", "Find highlight groups" }, + M = { "Telescope man_pages", "Man Pages" }, + r = { "Telescope oldfiles", "Open Recent File" }, + R = { "Telescope registers", "Registers" }, + t = { "Telescope live_grep", "Text" }, + k = { "Telescope keymaps", "Keymaps" }, + C = { "Telescope commands", "Commands" }, + }, + T = { + name = "Treesitter", + i = { "TSConfigInfo", "Info" }, + }, + } + } +} diff --git a/.config/nvim/lua/pluginlist.lua b/.config/nvim/lua/pluginlist.lua new file mode 100644 index 00000000..72f64ee5 --- /dev/null +++ b/.config/nvim/lua/pluginlist.lua @@ -0,0 +1,49 @@ +return { + -- General Functionality + 'wbthomason/packer.nvim', + 'nvim-lua/plenary.nvim', + 'windwp/nvim-autopairs', + 'numToStr/Comment.nvim', + 'JoosepAlviste/nvim-ts-context-commentstring', + 'kyazdani42/nvim-web-devicons', + 'kyazdani42/nvim-tree.lua', + 'akinsho/bufferline.nvim', + 'moll/vim-bbye', + 'nvim-lualine/lualine.nvim', + 'akinsho/toggleterm.nvim', + 'ahmedkhalf/project.nvim', + 'lewis6991/impatient.nvim', + 'lukas-reineke/indent-blankline.nvim', + 'goolord/alpha-nvim', + 'RRethy/vim-illuminate', + 'nvim-telescope/telescope.nvim', + 'nvim-treesitter/nvim-treesitter', + 'lewis6991/gitsigns.nvim', + 'folke/lua-dev.nvim', + 'tpope/vim-surround', + 'tpope/vim-repeat', + 'norcalli/nvim-colorizer.lua', + 'vimwiki/vimwiki', + 'folke/which-key.nvim', + 'felipec/vim-sanegx', + 'sindrets/diffview.nvim', + -- Color Schemes, + 'folke/tokyonight.nvim', + -- Completion, + 'hrsh7th/nvim-cmp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'saadparwaiz1/cmp_luasnip', + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-nvim-lua', + -- Snippets, + 'L3MON4D3/LuaSnip', + 'rafamadriz/friendly-snippets', + -- LSP/DAP, + 'williamboman/mason.nvim', + 'jose-elias-alvarez/null-ls.nvim', + 'neovim/nvim-lspconfig', + 'williamboman/mason-lspconfig.nvim', + 'mfussenegger/nvim-dap', + 'rcarriga/nvim-dap-ui', +} diff --git a/.config/nvim/lua/user/dap.lua b/.config/nvim/lua/user/adapters/dap.lua similarity index 62% rename from .config/nvim/lua/user/dap.lua rename to .config/nvim/lua/user/adapters/dap.lua index c07778d4..911a6d03 100644 --- a/.config/nvim/lua/user/dap.lua +++ b/.config/nvim/lua/user/adapters/dap.lua @@ -1,3 +1,5 @@ +local icons = require('iconlist') + local dap_status_ok, dap = pcall(require, "dap") if not dap_status_ok then return @@ -8,17 +10,19 @@ if not dap_ui_status_ok then return end -local dap_install_status_ok, dap_install = pcall(require, "dap-install") -if not dap_install_status_ok then - return -end +-- Debugger installation is now handled by mason -dap_install.setup {} +-- local dap_install_status_ok, dap_install = pcall(require, "dap-install") +-- if not dap_install_status_ok then +-- return +-- end +-- +-- dap_install.setup {} +-- +-- dap_install.config("python", {}) +-- -- add other configs here -dap_install.config("python", {}) --- add other configs here - -require('dapui').setup{ +dapui.setup { layouts = { { elements = { @@ -41,7 +45,7 @@ require('dapui').setup{ }, } -vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DiagnosticSignError", linehl = "", numhl = "" }) +vim.fn.sign_define("DapBreakpoint", { text = icons.ui.Bug, texthl = "DiagnosticSignError", linehl = "", numhl = "" }) dap.listeners.after.event_initialized["dapui_config"] = function() dapui.open() diff --git a/.config/nvim/lua/user/adapters/handlers.lua b/.config/nvim/lua/user/adapters/handlers.lua new file mode 100644 index 00000000..eab04c3e --- /dev/null +++ b/.config/nvim/lua/user/adapters/handlers.lua @@ -0,0 +1,68 @@ +local M = {} + +local icons = require('iconlist') + +local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") +if not status_cmp_ok then + return +end + +M.capabilities = vim.lsp.protocol.make_client_capabilities() +M.capabilities.textDocument.completion.completionItem.snippetSupport = true +M.capabilities = cmp_nvim_lsp.update_capabilities(M.capabilities) + +M.setup = function() + local signs = { + + { name = "DiagnosticSignError", text = icons.diagnostics.BoldError }, + { name = "DiagnosticSignWarn", text = icons.diagnostics.BoldWarning }, + { name = "DiagnosticSignHint", text = icons.diagnostics.BoldHint }, + { name = "DiagnosticSignInfo", text = icons.diagnostics.BoldInformation }, + } + + for _, sign in ipairs(signs) do + vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) + end + + local config = { + virtual_text = false, -- disable virtual text + signs = { + active = signs, -- show signs + }, + update_in_insert = true, + underline = true, + severity_sort = true, + float = { + focusable = true, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + } + + vim.diagnostic.config(config) + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = "rounded", + }) + + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = "rounded", + }) +end + +M.on_attach = function(client, bufnr) + if client.name == "sumneko_lua" then + client.server_capabilities.documentFormattingProvider = false + end + + local status_ok, illuminate = pcall(require, "illuminate") + if not status_ok then + return + end + illuminate.on_attach(client) +end + +return M diff --git a/.config/nvim/lua/user/adapters/init.lua b/.config/nvim/lua/user/adapters/init.lua new file mode 100644 index 00000000..30db2943 --- /dev/null +++ b/.config/nvim/lua/user/adapters/init.lua @@ -0,0 +1,9 @@ +local status_ok, _ = pcall(require, "lspconfig") +if not status_ok then + return +end + +require "user.adapters.mason" +require("user.adapters.handlers").setup() +require "user.adapters.null-ls" +require "user.adapters.dap" diff --git a/.config/nvim/lua/user/lsp/mason.lua b/.config/nvim/lua/user/adapters/mason.lua similarity index 58% rename from .config/nvim/lua/user/lsp/mason.lua rename to .config/nvim/lua/user/adapters/mason.lua index 0a23dcad..dfd32f4d 100644 --- a/.config/nvim/lua/user/lsp/mason.lua +++ b/.config/nvim/lua/user/adapters/mason.lua @@ -1,12 +1,18 @@ -local servers = require('user.lsp.servers') +local servers = { + "sumneko_lua", + "bashls", + "clangd", +} + +local icons = require('iconlist') local settings = { ui = { border = "none", icons = { - package_installed = "◍", - package_pending = "◍", - package_uninstalled = "◍", + package_installed = icons.ui.Check, + package_pending = icons.ui.BoldArrowRight, + package_uninstalled = icons.ui.BoldClose, }, }, log_level = vim.log.levels.INFO, @@ -28,13 +34,13 @@ local opts = {} for _, server in pairs(servers) do opts = { - on_attach = require("user.lsp.handlers").on_attach, - capabilities = require("user.lsp.handlers").capabilities, + on_attach = require("user.adapters.handlers").on_attach, + capabilities = require("user.adapters.handlers").capabilities, } server = vim.split(server, "@")[1] - local require_ok, conf_opts = pcall(require, "user.lsp.settings." .. server) + local require_ok, conf_opts = pcall(require, "user.adapters.settings." .. server) if require_ok then opts = vim.tbl_deep_extend("force", conf_opts, opts) end diff --git a/.config/nvim/lua/user/lsp/null-ls.lua b/.config/nvim/lua/user/adapters/null-ls.lua similarity index 100% rename from .config/nvim/lua/user/lsp/null-ls.lua rename to .config/nvim/lua/user/adapters/null-ls.lua diff --git a/.config/nvim/lua/user/autocmds.lua b/.config/nvim/lua/user/autocmds.lua index 01d770a3..d9ff565a 100644 --- a/.config/nvim/lua/user/autocmds.lua +++ b/.config/nvim/lua/user/autocmds.lua @@ -1,118 +1,4 @@ -autocmds = { - { -- Handles the automatic line numeration changes - { "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, - { - pattern = "*", - command="if &nu && mode() != \"i\" | set rnu | endif" - } - }, - { -- Handles the automatic line numeration changes - { "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, - { - pattern = "*", - command="if &nu | set nornu | endif" - } - }, - { - "FileType", - { - pattern = "zsh", - callback = function() - require("nvim-treesitter.highlight").attach(0, "bash") - end - } - }, - { - "BufWritePost", - { - pattern = { "bm-files", "bm-dirs" }, - command = "!shortcuts" - } - }, - { - { "BufRead", "BufNewFile" }, - { - pattern = { "Xresources", "Xdefaults", "xresources", "xdefaults" }, - command = "set filetype=xdefaults" - } - }, - { - "BufWritePost", - { - pattern = { "Xresources", "Xdefaults", "xresources", "xdefaults" }, - command = "!xrdb %" - } - }, - { - "BufWritePost", - { - pattern = "~/.local/src/dwmblocks/config.h", - command = "!cd ~/.local/src/dwmblocks/; sudo make install && { killall -q dwmblocks;setsid -f dwmblocks }" - } - }, - { - "BufWritePost", - { - pattern = "*.java", - callback = function() - vim.lsp.codelens.refresh() - end - } - }, - { - { "BufDelete", "VimLeave" }, - { - pattern = "*.tex", - command = "!texclear \"%:p\"" - } - }, - { -- Use 'q' to quit from common plugins - 'FileType', - { - pattern = { "qf", "help", "man", "lspinfo", "spectre_panel", "lir" }, - callback = function() - vim.cmd [[ - nnoremap q :close - set nobuflisted - ]] - end - } - }, - { - 'Filetype', - { - pattern = { "gitcommit", "markdown" }, - callback = function() - vim.opt_local.wrap = true - vim.opt_local.spell = true - end, - } - }, - { -- Automatically apply changes to plugins.lua - 'BufWritePost', - { - group = 'packer_user_config', - pattern = "plugins.lua", - command = "source | PackerCompile" - } - }, - { -- Fix auto comment - 'BufWinEnter', - { - callback = function() - vim.cmd("set formatoptions-=cro") - end - } - }, - { -- Highlight yanked text - 'TextYankPost', - { - callback = function() - vim.highlight.on_yank({ higroup = "Visual", timeout = 200 }) - end - } - } -} +autocmds = require('autocmdlist') vim.api.nvim_create_augroup('packer_user_config', {clear = true}) diff --git a/.config/nvim/lua/user/cmp.lua b/.config/nvim/lua/user/cmp.lua index 66b4da2e..8a3bd393 100644 --- a/.config/nvim/lua/user/cmp.lua +++ b/.config/nvim/lua/user/cmp.lua @@ -15,7 +15,7 @@ local check_backspace = function() return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") end -local kind_icons = require('icons').kind +local kind_icons = require('iconlist').kind cmp.setup({ snippet = { expand = function(args) diff --git a/.config/nvim/lua/funcs.lua b/.config/nvim/lua/user/funcs.lua similarity index 89% rename from .config/nvim/lua/funcs.lua rename to .config/nvim/lua/user/funcs.lua index e8163840..0b782865 100644 --- a/.config/nvim/lua/funcs.lua +++ b/.config/nvim/lua/user/funcs.lua @@ -1,10 +1,5 @@ local M = {} - --- Common kill function for bdelete and bwipeout --- credits: based on bbye and nvim-bufdel, stolen from LunarVim ----@param kill_command? string defaults to "bd" ----@param bufnr? number defaults to the current buffer ----@param force? boolean defaults to false +-- Modified version of a function stolen from LunarVim function M.buf_kill(kill_command, bufnr, force) kill_command = kill_command or "bd" @@ -65,6 +60,8 @@ function M.buf_kill(kill_command, bufnr, force) end end end + else + vim.cmd("quit") end -- Check if buffer still exists, to ensure the target buffer wasn't killed diff --git a/.config/nvim/lua/user/keybinds.lua b/.config/nvim/lua/user/keybinds.lua deleted file mode 100644 index 6e013f09..00000000 --- a/.config/nvim/lua/user/keybinds.lua +++ /dev/null @@ -1,77 +0,0 @@ -local opts = { silent = true, noremap=true } - -vim.g.mapleader = "space" - -maps = { - n = { -- normal mode - -- Better window navigation - {"", "h", opts}, - {"", "j", opts}, - {"", "k", opts}, - {"", "l", opts}, - -- Resize with arrows - {"", ":resize -2", opts}, - {"", ":resize +2", opts}, - {"", ":vertical resize -2", opts}, - {"", ":vertical resize +2", opts}, - -- Navigate buffers - {"", ":bnext", opts}, - {"", ":bprevious", opts}, - -- Clear highlights - {"h", "nohlsearch", opts}, - -- Close buffers - {"", "Bdelete!", opts}, - -- NvimTree - {"e", ":NvimTreeToggle", opts}, - -- Telescope - {"ff", ":Telescope find_files", opts}, - {"ft", ":Telescope live_grep", opts}, - {"fp", ":Telescope projects", opts}, - {"fb", ":Telescope buffers", opts}, - -- Git - {"gg", "lua _LAZYGIT_TOGGLE()", opts}, - -- Comment - {"/", "lua require('Comment.api').toggle_current_linewise()", opts}, - -- DAP - {"db", "lua require'dap'.toggle_breakpoint()", opts}, - {"dc", "lua require'dap'.continue()", opts}, - {"di", "lua require'dap'.step_into()", opts}, - {"do", "lua require'dap'.step_over()", opts}, - {"dO", "lua require'dap'.step_out()", opts}, - {"dr", "lua require'dap'.repl.toggle()", opts}, - {"dl", "lua require'dap'.run_last()", opts}, - {"du", "lua require'dapui'.toggle()", opts}, - {"dt", "lua require'dap'.terminate()", opts}, - -- Illuminate - {'', 'lua require"illuminate".next_reference{wrap=true}', opts}, - {'', 'lua require"illuminate".next_reference{reverse=true,wrap=true}', opts}, - }, - i = { -- insert mode - }, - v = { -- visual mode - -- Better paste - {"p", '"_dP'}, - -- Stay in indent mode - {"<", "", ">gv"}, - }, - x = { -- visual block mode - -- Comment - {"/", 'lua require("Comment.api").toggle_linewise_op(vim.fn.visualmode())', opts}, - }, - t = { -- terminal mode - }, - c = { -- command mode - } -} - -for mode, binds in ipairs(maps) do - for _, bind in ipairs(binds) do - local key = bind[1] - local cmd = bind[2] - if entry[3] then - local opt = entry[3] - end - vim.api.nvim_set_keymap(mode, key, cmd, opt) - end -end diff --git a/.config/nvim/lua/user/keymaps.lua b/.config/nvim/lua/user/keymaps.lua new file mode 100644 index 00000000..5cf698ae --- /dev/null +++ b/.config/nvim/lua/user/keymaps.lua @@ -0,0 +1,11 @@ +maps = require('keymaplist').kb +vim.keymap.set("", "", "", { silent = true, noremap = true }) +vim.g.mapleader = " " +for mode, binds in pairs(maps) do + for _, bind in pairs(binds) do + local key = bind[1] + local cmd = bind[2] + local opt = bind[3] + vim.api.nvim_set_keymap(mode, key, cmd, opt) + end +end diff --git a/.config/nvim/lua/user/lsp/handlers.lua b/.config/nvim/lua/user/lsp/handlers.lua deleted file mode 100644 index 09dbe901..00000000 --- a/.config/nvim/lua/user/lsp/handlers.lua +++ /dev/null @@ -1,91 +0,0 @@ -local M = {} - -local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") -if not status_cmp_ok then - return -end - -M.capabilities = vim.lsp.protocol.make_client_capabilities() -M.capabilities.textDocument.completion.completionItem.snippetSupport = true -M.capabilities = cmp_nvim_lsp.update_capabilities(M.capabilities) - -M.setup = function() - local signs = { - - { name = "DiagnosticSignError", text = "" }, - { name = "DiagnosticSignWarn", text = "" }, - { name = "DiagnosticSignHint", text = "" }, - { name = "DiagnosticSignInfo", text = "" }, - } - - for _, sign in ipairs(signs) do - vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) - end - - local config = { - virtual_text = false, -- disable virtual text - signs = { - active = signs, -- show signs - }, - update_in_insert = true, - underline = true, - severity_sort = true, - float = { - focusable = true, - style = "minimal", - border = "rounded", - source = "always", - header = "", - prefix = "", - }, - } - - vim.diagnostic.config(config) - - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { - border = "rounded", - }) - - vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { - border = "rounded", - }) -end - -local function lsp_keymaps(bufnr) - local opts = { noremap = true, silent = true } - local keymap = vim.api.nvim_buf_set_keymap - keymap(bufnr, "n", "gD", "lua vim.lsp.buf.declaration()", opts) - keymap(bufnr, "n", "gd", "lua vim.lsp.buf.definition()", opts) - keymap(bufnr, "n", "K", "lua vim.lsp.buf.hover()", opts) - keymap(bufnr, "n", "gI", "lua vim.lsp.buf.implementation()", opts) - keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", opts) - keymap(bufnr, "n", "gl", "lua vim.diagnostic.open_float()", opts) - keymap(bufnr, "n", "lf", "lua vim.lsp.buf.format{ async = true }", opts) - keymap(bufnr, "n", "li", "LspInfo", opts) - keymap(bufnr, "n", "lI", "LspInstallInfo", opts) - keymap(bufnr, "n", "la", "lua vim.lsp.buf.code_action()", opts) - keymap(bufnr, "n", "lj", "lua vim.diagnostic.goto_next({buffer=0})", opts) - keymap(bufnr, "n", "lk", "lua vim.diagnostic.goto_prev({buffer=0})", opts) - keymap(bufnr, "n", "lr", "lua vim.lsp.buf.rename()", opts) - keymap(bufnr, "n", "ls", "lua vim.lsp.buf.signature_help()", opts) - keymap(bufnr, "n", "lq", "lua vim.diagnostic.setloclist()", opts) -end - -M.on_attach = function(client, bufnr) - if client.name == "tsserver" then - client.server_capabilities.documentFormattingProvider = false - end - - if client.name == "sumneko_lua" then - client.server_capabilities.documentFormattingProvider = false - end - - lsp_keymaps(bufnr) - local status_ok, illuminate = pcall(require, "illuminate") - if not status_ok then - return - end - illuminate.on_attach(client) -end - -return M diff --git a/.config/nvim/lua/user/lsp/init.lua b/.config/nvim/lua/user/lsp/init.lua deleted file mode 100644 index c8eef0fc..00000000 --- a/.config/nvim/lua/user/lsp/init.lua +++ /dev/null @@ -1,8 +0,0 @@ -local status_ok, _ = pcall(require, "lspconfig") -if not status_ok then - return -end - -require "user.lsp.mason" -require("user.lsp.handlers").setup() -require "user.lsp.null-ls" diff --git a/.config/nvim/lua/user/lsp/servers.lua b/.config/nvim/lua/user/lsp/servers.lua deleted file mode 100644 index b8d7c2e2..00000000 --- a/.config/nvim/lua/user/lsp/servers.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - "sumneko_lua", - "cssls", - "html", - "pyright", - "bashls", - "jsonls", - "yamlls", - "clangd", - "ansiblels", -} diff --git a/.config/nvim/lua/user/plugins.lua b/.config/nvim/lua/user/plugins.lua index dc8c212d..c5b58306 100644 --- a/.config/nvim/lua/user/plugins.lua +++ b/.config/nvim/lua/user/plugins.lua @@ -10,6 +10,7 @@ local ensure_packer = function() end local packer_bootstrap = ensure_packer() +local pluginlist = require "pluginlist" local status_ok, packer = pcall(require, "packer") if not status_ok then @@ -25,56 +26,10 @@ packer.init { } return packer.startup(function(use) - -- General Functionality - use 'wbthomason/packer.nvim' - use 'nvim-lua/plenary.nvim' - use 'windwp/nvim-autopairs' - use 'numToStr/Comment.nvim' - use 'JoosepAlviste/nvim-ts-context-commentstring' - use 'kyazdani42/nvim-web-devicons' - use 'kyazdani42/nvim-tree.lua' - use 'akinsho/bufferline.nvim' - use 'moll/vim-bbye' - use 'nvim-lualine/lualine.nvim' - use 'akinsho/toggleterm.nvim' - use 'ahmedkhalf/project.nvim' - use 'lewis6991/impatient.nvim' - use 'lukas-reineke/indent-blankline.nvim' - use 'goolord/alpha-nvim' - use 'RRethy/vim-illuminate' - use 'nvim-telescope/telescope.nvim' - use 'nvim-treesitter/nvim-treesitter' - use 'lewis6991/gitsigns.nvim' - use 'folke/lua-dev.nvim' - use 'tpope/vim-surround' - use 'tpope/vim-repeat' - use 'norcalli/nvim-colorizer.lua' - use 'vimwiki/vimwiki' - use 'folke/which-key.nvim' - use 'felipec/vim-sanegx' - use 'sindrets/diffview.nvim' - -- Color Schemes - use 'folke/tokyonight.nvim' - -- Completion - use 'hrsh7th/nvim-cmp' - use 'hrsh7th/cmp-buffer' - use 'hrsh7th/cmp-path' - use 'saadparwaiz1/cmp_luasnip' - use 'hrsh7th/cmp-nvim-lsp' - use 'hrsh7th/cmp-nvim-lua' - -- Snippets - use 'L3MON4D3/LuaSnip' - use 'rafamadriz/friendly-snippets' - -- LSP/DAP - use 'williamboman/mason.nvim' - use 'jose-elias-alvarez/null-ls.nvim' - use 'neovim/nvim-lspconfig' - use 'williamboman/mason-lspconfig.nvim' - use 'mfussenegger/nvim-dap' - use 'rcarriga/nvim-dap-ui' - use 'ravenxrz/DAPInstall.nvim' - - if packer_bootstrap then - require('packer').sync() - end + for _, entry in ipairs(pluginlist) do + use(entry) + end + if packer_bootstrap then + require('packer').sync() + end end) diff --git a/.config/nvim/lua/user/plugins/alpha.lua b/.config/nvim/lua/user/plugins/alpha.lua index 13a21521..4bdd7f8f 100644 --- a/.config/nvim/lua/user/plugins/alpha.lua +++ b/.config/nvim/lua/user/plugins/alpha.lua @@ -4,7 +4,7 @@ if not status_ok then end local dashboard = require 'alpha.themes.dashboard' -local icons = require 'icons' +local icons = require 'iconlist' local banner = { "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣶⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀⠀⠀", diff --git a/.config/nvim/lua/user/plugins/autopairs.lua b/.config/nvim/lua/user/plugins/autopairs.lua index 9dfd2028..3745f83e 100644 --- a/.config/nvim/lua/user/plugins/autopairs.lua +++ b/.config/nvim/lua/user/plugins/autopairs.lua @@ -5,24 +5,24 @@ if not status_ok then end npairs.setup({ - check_ts = true, -- treesitter integration - disable_filetype = { "TelescopePrompt" }, - ts_config = { - lua = { "string", "source" }, - javascript = { "string", "template_string" }, - java = false, - }, + check_ts = true, -- treesitter integration + disable_filetype = { "TelescopePrompt" }, + ts_config = { + lua = { "string", "source" }, + javascript = { "string", "template_string" }, + java = false, + }, fast_wrap = { - map = "", - chars = { "{", "[", "(", '"', "'" }, - pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), - offset = 0, -- Offset from pattern match - end_key = "$", - keys = "qwertyuiopzxcvbnmasdfghjkl", - check_comma = true, - highlight = "PmenuSel", - highlight_grey = "LineNr", - }, + map = "", + chars = { "{", "[", "(", '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), + offset = 0, -- Offset from pattern match + end_key = "$", + keys = "qwertyuiopzxcvbnmasdfghjkl", + check_comma = true, + highlight = "PmenuSel", + highlight_grey = "LineNr", + }, }) local cmp_autopairs = require("nvim-autopairs.completion.cmp") diff --git a/.config/nvim/lua/user/plugins/bufferline.lua b/.config/nvim/lua/user/plugins/bufferline.lua index 8e8b5ca7..a55aeba1 100644 --- a/.config/nvim/lua/user/plugins/bufferline.lua +++ b/.config/nvim/lua/user/plugins/bufferline.lua @@ -7,7 +7,7 @@ local function is_ft(b, ft) return vim.bo[b].filetype == ft end -local icons = require 'icons' +local icons = require 'iconlist' local config = { highlights = { diff --git a/.config/nvim/lua/user/plugins/lualine.lua b/.config/nvim/lua/user/plugins/lualine.lua index 4658adf9..519646d7 100644 --- a/.config/nvim/lua/user/plugins/lualine.lua +++ b/.config/nvim/lua/user/plugins/lualine.lua @@ -4,6 +4,7 @@ if not status_ok then end local colors = require("tokyonight.colors").setup({ transform = true }) +local icons = require('iconlist') local conditions = { buffer_not_empty = function() @@ -113,7 +114,7 @@ ins_left { ins_left { 'diagnostics', sources = { 'nvim_diagnostic' }, - symbols = { error = ' ', warn = ' ', info = ' ' }, + symbols = { error = icons.diagnostics.BoldError .. ' ', warn = icons.diagnostics.BoldWarning .. ' ', info = icons.diagnostics.BoldInformation }, diagnostics_color = { color_error = { fg = colors.red }, color_warn = { fg = colors.yellow }, @@ -137,7 +138,7 @@ ins_left { function() local current_line = vim.fn.line "." local total_lines = vim.fn.line "$" - local chars = { "", "", "", "", "", "", "", "", "", "", "", "", "" } + local chars = icons.progress local line_ratio = current_line / total_lines local index = math.ceil(line_ratio * #chars) return chars[index] @@ -165,13 +166,13 @@ ins_right { ins_right { 'branch', - icon = '', + icon = icons.git.Branch, color = { fg = colors.violet, gui = 'bold' }, } ins_right { 'diff', - symbols = { added = ' ', modified = '柳 ', removed = ' ' }, + symbols = { added = ' ', modified = '柳', removed = ' ' }, diff_color = { added = { fg = colors.green }, modified = { fg = colors.orange }, diff --git a/.config/nvim/lua/user/plugins/nvim-tree.lua b/.config/nvim/lua/user/plugins/nvim-tree.lua index 73b7157b..1ceb2e2e 100644 --- a/.config/nvim/lua/user/plugins/nvim-tree.lua +++ b/.config/nvim/lua/user/plugins/nvim-tree.lua @@ -9,7 +9,7 @@ if not config_status_ok then end local tree_cb = nvim_tree_config.nvim_tree_callback -local icons = require 'icons' +local icons = require 'iconlist' nvim_tree.setup { update_focused_file = { diff --git a/.config/nvim/lua/user/plugins/project.lua b/.config/nvim/lua/user/plugins/project.lua index fb8e5918..e85c0fd5 100644 --- a/.config/nvim/lua/user/plugins/project.lua +++ b/.config/nvim/lua/user/plugins/project.lua @@ -1,19 +1,19 @@ local status_ok, project = pcall(require, "project_nvim") if not status_ok then - return + return end project.setup({ - -- detection_methods = { "lsp", "pattern" }, -- NOTE: lsp detection will get annoying with multiple langs in one project - detection_methods = { "pattern" }, + -- detection_methods = { "lsp", "pattern" }, -- NOTE: lsp detection will get annoying with multiple langs in one project + detection_methods = { "pattern" }, - -- patterns used to detect root dir, when **"pattern"** is in detection_methods - patterns = { ".git", "Makefile", "package.json" }, + -- patterns used to detect root dir, when **"pattern"** is in detection_methods + patterns = { ".git", "Makefile", "package.json" }, }) local tele_status_ok, telescope = pcall(require, "telescope") if not tele_status_ok then - return + return end telescope.load_extension('projects') diff --git a/.config/nvim/lua/user/plugins/telescope.lua b/.config/nvim/lua/user/plugins/telescope.lua index 6ac64d89..507aff06 100644 --- a/.config/nvim/lua/user/plugins/telescope.lua +++ b/.config/nvim/lua/user/plugins/telescope.lua @@ -4,7 +4,7 @@ if not status_ok then end local actions = require "telescope.actions" -local icons = require "icons" +local icons = require "iconlist" telescope.setup { defaults = { diff --git a/.config/nvim/lua/user/plugins/toggleterm.lua b/.config/nvim/lua/user/plugins/toggleterm.lua index a633c612..4cc00d51 100644 --- a/.config/nvim/lua/user/plugins/toggleterm.lua +++ b/.config/nvim/lua/user/plugins/toggleterm.lua @@ -1,23 +1,23 @@ local status_ok, toggleterm = pcall(require, "toggleterm") if not status_ok then - return + return end toggleterm.setup({ - size = 20, - open_mapping = [[]], - hide_numbers = true, - shade_terminals = true, - shading_factor = 2, - start_in_insert = true, - insert_mappings = true, - persist_size = true, - direction = "float", - close_on_exit = true, - shell = vim.o.shell, - float_opts = { - border = "curved", - }, + size = 20, + open_mapping = [[]], + hide_numbers = true, + shade_terminals = true, + shading_factor = 2, + start_in_insert = true, + insert_mappings = true, + persist_size = true, + direction = "float", + close_on_exit = true, + shell = vim.o.shell, + float_opts = { + border = "curved", + }, }) function _G.set_terminal_keymaps() @@ -35,5 +35,5 @@ local Terminal = require("toggleterm.terminal").Terminal local lazygit = Terminal:new({ cmd = "lazygit", hidden = true }) function _LAZYGIT_TOGGLE() - lazygit:toggle() + lazygit:toggle() end diff --git a/.config/nvim/lua/user/plugins/treesitter.lua b/.config/nvim/lua/user/plugins/treesitter.lua index e9e31dfc..70774566 100644 --- a/.config/nvim/lua/user/plugins/treesitter.lua +++ b/.config/nvim/lua/user/plugins/treesitter.lua @@ -1,31 +1,30 @@ local status_ok, treesitter = pcall(require, "nvim-treesitter") if not status_ok then - return + return end local status_ok, configs = pcall(require, "nvim-treesitter.configs") if not status_ok then - return + return end configs.setup({ ensure_installed = { "lua", "markdown", "markdown_inline", "bash", "python" }, -- put the language you want in this array -- ensure_installed = "all", -- one of "all" or a list of languages - ignore_install = { "" }, -- List of parsers to ignore installing - sync_install = false, -- install languages synchronously (only applied to `ensure_installed`) + ignore_install = { "" }, -- List of parsers to ignore installing + sync_install = false, -- install languages synchronously (only applied to `ensure_installed`) highlight = { - enable = true, -- false will disable the whole extension - disable = { "css" }, -- list of language that will be disabled - }, - autopairs = { - enable = true, - }, - indent = { enable = true, disable = { "python", "css" } }, - - context_commentstring = { - enable = true, - enable_autocmd = false, - }, + enable = true, -- false will disable the whole extension + disable = { "css" }, -- list of language that will be disabled + }, + autopairs = { + enable = true, + }, + indent = { enable = true, disable = { "python", "css" } }, + context_commentstring = { + enable = true, + enable_autocmd = false, + }, }) diff --git a/.config/nvim/lua/user/plugins/whichkey.lua b/.config/nvim/lua/user/plugins/whichkey.lua new file mode 100644 index 00000000..cc364ece --- /dev/null +++ b/.config/nvim/lua/user/plugins/whichkey.lua @@ -0,0 +1,56 @@ +local status_ok, whichkey = pcall(require, "which-key") +if not status_ok then + return +end +local icons = require('iconlist') + +local maps = require('keymaplist').wk + +whichkey.setup { + marks = false, + registers = false, + presets = { + operators = false, + motions = false, + text_objects = false, + windows = false, + nav = false, + z = false, + g = false, + }, + spelling = { + enabled = false, + suggestions = 20, + }, + icons = { + breadcrumb = icons.ui.DoubleChevronRight, + separator = icons.ui.BoldArrowRight, + group = icons.ui.Plus, + }, + popup_mappings = { + scroll_down = "", + scroll_up = "", + }, + window = { + border = "single", + position = "bottom", + margin = { 1, 0, 1, 0 }, + padding = { 2, 2, 2, 2 }, + winblend = 0, + }, + layout = { + height = { min = 4, max = 25 }, + width = { min = 20, max = 50 }, + spacing = 3, + align = "left", + }, + hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, + triggers = "auto", + triggers_blacklist = { + i = { "j", "k" }, + v = { "j", "k" }, + }, +} + +whichkey.register(maps.nmaps, maps.nopts) +whichkey.register(maps.vmaps, maps.vopts) diff --git a/.config/nvim/plugin/packer_compiled.lua b/.config/nvim/plugin/packer_compiled.lua index 4c798a29..6dba9aed 100644 --- a/.config/nvim/plugin/packer_compiled.lua +++ b/.config/nvim/plugin/packer_compiled.lua @@ -79,11 +79,6 @@ _G.packer_plugins = { path = "/home/luca/.local/share/nvim/site/pack/packer/start/Comment.nvim", url = "https://github.com/numToStr/Comment.nvim" }, - ["DAPInstall.nvim"] = { - loaded = true, - path = "/home/luca/.local/share/nvim/site/pack/packer/start/DAPInstall.nvim", - url = "https://github.com/ravenxrz/DAPInstall.nvim" - }, LuaSnip = { loaded = true, path = "/home/luca/.local/share/nvim/site/pack/packer/start/LuaSnip",