diff --git a/nvim/init.vim b/nvim/init.vim index 95fea61..a689c17 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -22,12 +22,13 @@ Plug 'koenverburg/peepsight.nvim' Plug 'norcalli/nvim-colorizer.lua' Plug 'j-hui/fidget.nvim' " Git -Plug 'airblade/vim-gitgutter' +Plug 'lewis6991/gitsigns.nvim' " Search/Files Plug 'nvim-lua/plenary.nvim' Plug 'nvim-telescope/telescope.nvim' Plug 'ANGkeith/telescope-terraform-doc.nvim' Plug 'fannheyward/telescope-coc.nvim' +Plug 'FeiyouG/commander.nvim' " Ignore/Edit files Plug 'vim-scripts/gitignore' " Languages @@ -47,6 +48,7 @@ Plug 'hrsh7th/cmp-cmdline' Plug 'hrsh7th/cmp-buffer' Plug 'hrsh7th/cmp-path' Plug 'hrsh7th/nvim-cmp' +Plug 'folke/trouble.nvim' call plug#end() @@ -154,27 +156,8 @@ EOF " Using SPACE as key nnoremap let mapleader = " " +lua require('keybindings') -" Telescope -nnoremap Telescope git_files -nnoremap ff Telescope find_files -nnoremap fg Telescope live_grep -" Telescope git -nnoremap fgc Telescope git_commits -nnoremap fgb Telescope git_branches -nnoremap fgs Telescope git_status -" Telescope Terraform -nnoremap ftf Telescope terraform_doc -nnoremap ftm Telescope terraform_doc modules -nnoremap ftfa Telescope terraform_doc full_name=hashicorp/aws -nnoremap ftfk Telescope terraform_doc full_name=hashicorp/kubernetes -" Telescope coc -nnoremap fca Telescope coc code_actions -nnoremap fcr Telescope coc references -nnoremap fcdi Telescope coc diagnostics -nnoremap fcde Telescope coc definitions -nnoremap fcds Telescope coc document_symbols -nnoremap fcws Telescope coc workspace_symbols """"" "- Visuals diff --git a/nvim/lua/code_helpers.lua b/nvim/lua/code_helpers.lua index 9d9f33c..6ed3b66 100644 --- a/nvim/lua/code_helpers.lua +++ b/nvim/lua/code_helpers.lua @@ -110,7 +110,6 @@ require("mason-lspconfig").setup({ "helm_ls", -- helm "jsonls", -- json "tsserver", -- javascript/typescript - "autotools-language-server", -- make "marksman", -- markdown "vale_ls", -- markdown/prose "swift_mesonls", -- meson @@ -133,72 +132,16 @@ require("mason-lspconfig").setup_handlers({ end, }) -local lspconfig = require("lspconfig") - -local function quickfix() - vim.lsp.buf.code_action({ - filter = function(a) - return a.isPreferred - end, - apply = true, - }) -end - --- Global mappings. --- See `:help vim.diagnostic.*` for documentation on any of the below functions -vim.keymap.set("n", "e", vim.diagnostic.open_float) -vim.keymap.set("n", "[d", vim.diagnostic.goto_prev) -vim.keymap.set("n", "]d", vim.diagnostic.goto_next) -vim.keymap.set("n", "q", vim.diagnostic.setloclist) - --- Use LspAttach autocommand to only map the following keys --- after the language server attaches to the current buffer -vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("UserLspConfig", {}), - callback = function(ev) - -- Enable completion triggered by - vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc" - - -- Buffer local mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local opts = { buffer = ev.buf } - vim.keymap.set("n", "qf", quickfix, opts) - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) - vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) - vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) - vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) - vim.keymap.set("n", "", vim.lsp.buf.signature_help, opts) - vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, opts) - vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, opts) - vim.keymap.set("n", "wl", function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, opts) - vim.keymap.set("n", "D", vim.lsp.buf.type_definition, opts) - vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) - vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) - vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) - vim.keymap.set("n", "f", function() - vim.lsp.buf.format({ async = true }) - end, opts) - end, -}) - -- Formatter local util = require("formatter.util") --- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands require("formatter").setup({ - -- Enable or disable logging logging = true, - -- Set the log level log_level = vim.log.levels.WARN, -- All formatter configurations are opt-in filetype = { - -- Formatter configurations for filetype "lua" go here - -- and will be executed in order lua = { require("formatter.filetypes.lua").stylua, }, - javascript = { require("formatter.filetypes.javascript").prettier, }, @@ -246,3 +189,5 @@ autocmd("BufWritePost", { group = "__formatter__", command = ":FormatWrite", }) + +require("trouble").setup({}) diff --git a/nvim/lua/code_look.lua b/nvim/lua/code_look.lua index 3073b17..82057f7 100644 --- a/nvim/lua/code_look.lua +++ b/nvim/lua/code_look.lua @@ -56,3 +56,12 @@ require("peepsight").enable() -- Transforms hex colors to their respective color require("colorizer").setup() + +-- Git blame line +require("gitsigns").setup({ + current_line_blame = true, + current_line_blame_opts = { + delay = 500, + virt_text_pos = "eol", + }, +}) diff --git a/nvim/lua/keybindings.lua b/nvim/lua/keybindings.lua new file mode 100644 index 0000000..2529420 --- /dev/null +++ b/nvim/lua/keybindings.lua @@ -0,0 +1,99 @@ +require("commander").setup({ + integration = { + telescope = { + enable = true, + }, + }, +}) + +local lspconfig = require("lspconfig") + +-- Use LspAttach autocommand to only map the following keys +-- after the language server attaches to the current buffer +local lsp_antach_done = false +vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(ev) + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local opts = { buffer = ev.buf } + + require("commander").add({ + { + desc = "LSP Quickfix", + cmd = function() + vim.lsp.buf.code_action({ + filter = function(a) + return a.kind ~= "quickfix" or a.isPreferred + end, + apply = true, + }) + end, + keys = { "n", "qf", opts }, + }, + { desc = "LSP Declaration", cmd = vim.lsp.buf.declaration, keys = { "n", "gD", opts } }, + { desc = "LSP Definition", cmd = vim.lsp.buf.definition, keys = { "n", "gd", opts } }, + { desc = "LSP Hover", cmd = vim.lsp.buf.hover, keys = { "n", "K", opts } }, + { desc = "LSP Rename", cmd = vim.lsp.buf.rename, keys = { "n", "rn", opts } }, + { desc = "LSP Implementation", cmd = vim.lsp.buf.implementation, keys = { "n", "gi", opts } }, + { desc = "LSP Signature Help", cmd = vim.lsp.buf.signature_help, keys = { "n", "", opts } }, + { desc = "LSP Code Action", cmd = vim.lsp.buf.code_action, keys = { "n", "ca", opts } }, + { + desc = "LSP Format", + cmd = function() + vim.lsp.buf.format({ async = true }) + end, + keys = { "n", "f", opts }, + }, + { desc = "LSP References", cmd = "Telescope lsp_references", keys = { "n", "gr" } }, + { + desc = "LSP Diagnostics", + cmd = "Telescope diagnostics bufnr=0", + keys = { "n", "fcdi" }, + }, + { desc = "LSP Definitions", cmd = "Telescope lsp_definitions", keys = { "n", "fcde" } }, + { + desc = "LSP Document Symbols", + cmd = "Telescope lsp_document_symbols", + keys = { "n", "fcds" }, + }, + { + desc = "LSP Workspace Symbols", + cmd = "Telescope lsp_workspace_symbols", + keys = { "n", "fcws" }, + }, + }, { show = not lsp_attach_done }) + + lsp_attach_done = true + end, +}) + +require("commander").add({ + { + desc = "Open Help", + cmd = require("commander").show, + keys = { "n", "h" }, + }, + { + desc = "Search for files in git", + cmd = "Telescope git_files", + keys = { "n", "" }, + }, + { desc = "Search for files", cmd = "Telescope find_files", keys = { "n", "ff" } }, + { desc = "Search for string", cmd = "Telescope live_grep", keys = { "n", "fg" } }, + { desc = "Git Commits", cmd = "Telescope git_commits", keys = { "n", "fgc" } }, + { desc = "Git Branches", cmd = "Telescope git_branches", keys = { "n", "fgb" } }, + { desc = "Git Status", cmd = "Telescope git_status", keys = { "n", "fgs" } }, + { desc = "Terraform Doc", cmd = "Telescope terraform_doc", keys = { "n", "ftf" } }, + { desc = "Terraform Modules", cmd = "Telescope terraform_doc modules", keys = { "n", "ftm" } }, + { + desc = "Terraform AWS", + cmd = "Telescope terraform_doc full_name=hashicorp/aws", + keys = { "n", "ftfa" }, + }, + { + desc = "Terraform Kubernetes", + cmd = "Telescope terraform_doc full_name=hashicorp/kubernetes", + keys = { "n", "ftfk" }, + }, +})