diff --git a/after/plugin/keymaps.lua b/after/plugin/keymaps.lua index 5317e954..af0e9aee 100644 --- a/after/plugin/keymaps.lua +++ b/after/plugin/keymaps.lua @@ -10,6 +10,8 @@ function keymap(mode, lhs, rhs, opts) vim.api.nvim_set_keymap(mode, lhs, rhs, options) end +vim.cmd [[command ClearBufferExceptCurrent silent! execute "%bd|e#|bd#"]] + -- Navigate buffers keymap("n", "", ":bnext", opts) keymap("n", "", ":bprevious", opts) @@ -36,19 +38,15 @@ keymap('n', 'n', "nzzzv") keymap('n', 'N', "Nzzzv") -- replace without copy current selected -keymap('x', 'p', "\"_dp") +-- keymap('x', 'p', "\"_dp") +keymap("x", "p", [["_dP]]) + -- yank to system clipboard keymap('n', 'y', "\"+y", { desc = "[Y]ank to clipboard" }) keymap('v', 'y', "\"+y", { desc = "[Y]ank to clipboard" }) keymap('n', 'Y', "\"+Y", { desc = "[Y]ank to clipboard" }) --- Quickfix --- keymap('n', "", "cnextzz") --- keymap('n', "", "cprevzz") --- keymap('n', "k", "lnextzz") --- keymap('n', "j", "lprevzz") - -- Open folder in workspace in tmux session keymap("n", "op", "silent !tmux neww tmux-sessionizer", { desc = "[O]pen [P]roject" }) @@ -66,7 +64,11 @@ keymap("n", "bd", ":Bdelete", { desc = "[B]uffer [D]elete" }) keymap("n", "bw", ":Bwipeout", { desc = "[B]uffer [W]ipeout" }) -- Delete buffer except current -keymap("n", "be", ":%bd|e#|bd#", { silent = true, desc = "[B]uffer Delete [E]xcept" }) +-- keymap("n", "be", ":%bd|e#|bd#", { silent = true, desc = "[B]uffer Delete [E]xcept" }) +keymap("n", "be", ":ClearBufferExceptCurrent", { silent = true, desc = "[B]uffer Delete [E]xcept" }) -- Vim Be Good keymap("n", "vbg", ":VimBeGood", { desc = "[V]im [B]e [G]ood" }) + +-- Update source +keymap("n", "", ":so") diff --git a/after/plugin/lsp_lines.lua b/after/plugin/lsp_lines.lua new file mode 100644 index 00000000..186b6fe1 --- /dev/null +++ b/after/plugin/lsp_lines.lua @@ -0,0 +1,14 @@ +vim.diagnostic.config({ + virtual_text = false, + -- virtual_lines = { + -- only_current_line = true + -- } +}) + + +-- vim.keymap.set( +-- "", +-- "ll", +-- require("lsp_lines").toggle, +-- { desc = "Toggle lsp_lines" } +-- ) diff --git a/after/plugin/quickloc-fix.lua b/after/plugin/quickloc-fix.lua new file mode 100644 index 00000000..3856a111 --- /dev/null +++ b/after/plugin/quickloc-fix.lua @@ -0,0 +1,39 @@ +local keymap = vim.keymap.set +local trouble = require("trouble") + +vim.api.nvim_create_autocmd('DiagnosticChanged', { + callback = function() + vim.diagnostic.setqflist({ open = false }) + vim.diagnostic.setloclist({ open = false }) + end, +}) + +function QuickFixToggle() + if trouble.is_open() then + trouble.close() + else + trouble.open({ + mode = "quickfix" + }) + end +end + +function LocationListToggle() + if trouble.is_open() then + trouble.close() + else + trouble.open({ + mode = "loclist" + }) + end +end + +-- Quickfix +keymap("n", "qq", ":lua QuickFixToggle()", { desc = "[Q]uickfix [Q]uick" }) +keymap("n", "qn", "cnextzz", { desc = "[Q]uick [N]ext" }) +keymap("n", "qp", "cprevzz", { desc = "[Q]uick [P]revious" }) + +-- Location List +keymap("n", "ll", ":lua LocationListToggle()", { desc = "[L]ocation [L]ist" }) +keymap("n", "ln", "lnextzz", { desc = "[L]ocation [N]ext" }) +keymap("n", "lp", "lprevzz", { desc = "[L]ocation [P]revious" }) diff --git a/init.lua b/init.lua index 877cda0c..d9bd1881 100644 --- a/init.lua +++ b/init.lua @@ -35,7 +35,6 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now :) --]] - -- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) @@ -79,7 +78,8 @@ require('lazy').setup({ -- NOTE: This is where your plugins related to LSP can be installed. -- The configuration is done below. Search for lspconfig to find it below. - { -- LSP Configuration & Plugins + { + -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', dependencies = { -- Automatically install LSPs to stdpath for neovim @@ -95,14 +95,16 @@ require('lazy').setup({ }, }, - { -- Autocompletion + { + -- Autocompletion 'hrsh7th/nvim-cmp', dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, }, -- Useful plugin to show you pending keybinds. - { 'folke/which-key.nvim', opts = {} }, - { -- Adds git releated signs to the gutter, as well as utilities for managing changes + { 'folke/which-key.nvim', opts = {} }, + { + -- Adds git releated signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', opts = { -- See `:help gitsigns.txt` @@ -115,29 +117,36 @@ require('lazy').setup({ }, }, }, - - { -- Theme inspired by Atom - 'navarasu/onedark.nvim', - priority = 1000, + -- { -- Theme inspired by Atom + -- 'navarasu/onedark.nvim', + -- priority = 1000, + -- config = function() + -- vim.cmd.colorscheme 'onedark' + -- end, + -- }, + { + 'folke/tokyonight.nvim', -- Theme config = function() - vim.cmd.colorscheme 'onedark' - end, + vim.cmd [[colorscheme tokyonight-night]] + end }, - - { -- Set lualine as statusline + { + -- Set lualine as statusline 'nvim-lualine/lualine.nvim', -- See `:help lualine.txt` opts = { options = { icons_enabled = false, - theme = 'onedark', + -- theme = 'onedark', + theme = 'tokyonight', component_separators = '|', section_separators = '', }, }, }, - { -- Add indentation guides even on blank lines + { + -- Add indentation guides even on blank lines 'lukas-reineke/indent-blankline.nvim', -- Enable `lukas-reineke/indent-blankline.nvim` -- See `:help indent_blankline.txt` @@ -148,7 +157,7 @@ require('lazy').setup({ }, -- "gc" to comment visual regions/lines - { 'numToStr/Comment.nvim', opts = {} }, + { 'numToStr/Comment.nvim', opts = {} }, -- Fuzzy Finder (files, lsp, etc) { 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } }, @@ -166,7 +175,8 @@ require('lazy').setup({ end, }, - { -- Highlight, edit, and navigate code + { + -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', dependencies = { 'nvim-treesitter/nvim-treesitter-textobjects', @@ -358,7 +368,7 @@ require('nvim-treesitter.configs').setup { vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = "Open diagnostics list" }) +-- vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = "Open diagnostics list" }) -- LSP settings. -- This function gets run when an LSP connects to a particular buffer. @@ -389,7 +399,7 @@ local on_attach = function(_, bufnr) -- See `:help K` for why this keymap nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - -- nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') -- Lesser used LSP functionality nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') diff --git a/lua/custom/plugins/bufferline.lua b/lua/custom/plugins/bufferline.lua index f13a9e0e..0eaf145e 100644 --- a/lua/custom/plugins/bufferline.lua +++ b/lua/custom/plugins/bufferline.lua @@ -1,13 +1,13 @@ return { { 'akinsho/bufferline.nvim', - config = function () + config = function() require("bufferline").setup { options = { - indicator = { style = "icon", icon = "▎"}, + indicator = { style = "icon", icon = "▎" }, diagnostics = 'nvim_lsp', -- | "nvim_lsp" | "coc", diagnostics_update_in_insert = false, - offsets = { { filetype = "NvimTree", text = "", padding = 1 } }, + offsets = { { filetype = "NvimTree", text = "File Explorer", padding = 1 } }, separator_style = "thin", -- | "thick" | "thin" | { 'any', 'any' }, always_show_bufferline = true, } diff --git a/lua/custom/plugins/lsp_lines.lua b/lua/custom/plugins/lsp_lines.lua new file mode 100644 index 00000000..788df505 --- /dev/null +++ b/lua/custom/plugins/lsp_lines.lua @@ -0,0 +1,6 @@ +return { + "https://git.sr.ht/~whynothugo/lsp_lines.nvim", + config = function() + require('lsp_lines').setup() + end +} diff --git a/lua/custom/plugins/null-ls.lua b/lua/custom/plugins/null-ls.lua new file mode 100644 index 00000000..32e6d34c --- /dev/null +++ b/lua/custom/plugins/null-ls.lua @@ -0,0 +1,12 @@ +return { + "jose-elias-alvarez/null-ls.nvim", + config = function() + local null_ls = require("null-ls") + null_ls.setup({ + source = { + null_ls.builtins.diagnostics.eslint, + null_ls.builtins.completion.spell, + } + }) + end +} diff --git a/lua/custom/plugins/trouble.lua b/lua/custom/plugins/trouble.lua new file mode 100755 index 00000000..f101c64a --- /dev/null +++ b/lua/custom/plugins/trouble.lua @@ -0,0 +1,10 @@ +return { + "folke/trouble.nvim", + dependencies = { + "nvim-tree/nvim-web-devicons" + }, + config = function() + require("trouble").setup { + } + end +}