diff --git a/.config/nvim/.stylua.toml b/.config/nvim/.stylua.toml new file mode 100644 index 0000000..f4c1cee --- /dev/null +++ b/.config/nvim/.stylua.toml @@ -0,0 +1,6 @@ +column_width = 120 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 3 +quote_style = "AutoPreferDouble" +call_parentheses = "None" diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 39e1c46..faa0657 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,15 +1,2 @@ --- ~/.config/nvim/init.lua --- Charles Danesi (https://github.com/cdanesi) - --- Settings -require("plugins") -require("core.options") -require("core.keymaps") -require("core.colorscheme") - --- Plugins -require("plugins.gitsigns") -require("plugins.autopairs") -require("plugins.lualine") -require("plugins.treesitter") -require("plugins.colorizer") +require("core") +require("core.lazy") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..0e1e578 --- /dev/null +++ b/.config/nvim/lazy-lock.json @@ -0,0 +1,45 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, + "alpha-nvim": { "branch": "main", "commit": "bf3c8bb8c02ed3d9644cc5bbc48e2bdc39349cd7" }, + "auto-session": { "branch": "main", "commit": "3cd531ce4d46fb156268ddedf5f3e6822ef26af7" }, + "bufferline.nvim": { "branch": "main", "commit": "5c528bee3dd797d5bd6bae5f229411939b25b203" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "conform.nvim": { "branch": "master", "commit": "6a28c90082a67f62a323ab90d988e000a718a8c7" }, + "dressing.nvim": { "branch": "master", "commit": "1b7921eecc65af1baf8ac1dc06f0794934cbcfb2" }, + "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, + "gitsigns.nvim": { "branch": "main", "commit": "7c27a30450130cd59c4994a6755e3c5d74d83e76" }, + "indent-blankline.nvim": { "branch": "master", "commit": "04e44b09ee3ff189c69ab082edac1ef7ae2e256c" }, + "lazy.nvim": { "branch": "main", "commit": "cf8ecc2c5e4332760431a33534240b0cbc6680ab" }, + "lazygit.nvim": { "branch": "main", "commit": "56760339a81cd1540d5a72fd9d93010a2677b55d" }, + "lspkind.nvim": { "branch": "master", "commit": "a700f1436d4a938b1a1a93c9962dc796afbaef4d" }, + "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, + "nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" }, + "nvim-cmp": { "branch": "main", "commit": "29fb4854573355792df9e156cb779f0d31308796" }, + "nvim-lint": { "branch": "master", "commit": "36da8dd0ddc4f88e0beae234c20e75397326f143" }, + "nvim-lsp-file-operations": { "branch": "master", "commit": "9744b738183a5adca0f916527922078a965515ed" }, + "nvim-lspconfig": { "branch": "master", "commit": "54617a18f4cf46f0c2f6d024fa6feb7515fe036d" }, + "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" }, + "nvim-tree.lua": { "branch": "master", "commit": "120ba58254835d412bbc91cffe847e9be835fadd" }, + "nvim-treesitter": { "branch": "master", "commit": "92d2501d698e0fe855bd222540f9648890fab6c7" }, + "nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "9c74db656c3d0b1c4392fc89a016b1910539e7c0" }, + "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, + "onenord.nvim": { "branch": "main", "commit": "7f8a7482a1145c1286ee05d46ef4d028a4f7264a" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "substitute.nvim": { "branch": "main", "commit": "97f49d16f8eea7967d41db4f657dd63af53eeba1" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, + "trouble.nvim": { "branch": "main", "commit": "2f3b537f2207ce32f4459f9d56746ee013b5e01b" }, + "vim-maximizer": { "branch": "master", "commit": "2e54952fe91e140a2e69f35f22131219fcd9c5f1" }, + "vim-tmux-navigator": { "branch": "master", "commit": "a9b52e7d36114d40350099f254b5f299a35df978" }, + "which-key.nvim": { "branch": "main", "commit": "8badb359f7ab8711e2575ef75dfe6fbbd87e4821" } +} diff --git a/.config/nvim/lua/core/colorscheme.lua b/.config/nvim/lua/core/colorscheme.lua index 1067900..dddd0dd 100644 --- a/.config/nvim/lua/core/colorscheme.lua +++ b/.config/nvim/lua/core/colorscheme.lua @@ -1,6 +1,16 @@ -- set colorscheme if it's installed -local status, _ = pcall(vim.cmd, "colorscheme nord") -if not status then - print("Color scheme not found!") - return -end + +-- local status, _ = pcall(vim.cmd, "colorscheme nord") +-- if not status then +-- print("Color scheme not found!") +-- return +-- end + +return { + "shaunsingh/nord.nvim", + lazy = false, + priority = 1000, + config = function() + vim.cmd([[colorscheme nord]]) + end, +} diff --git a/.config/nvim/lua/core/init.lua b/.config/nvim/lua/core/init.lua new file mode 100644 index 0000000..5b6cf7c --- /dev/null +++ b/.config/nvim/lua/core/init.lua @@ -0,0 +1,3 @@ +require('core.options') +require('core.keymaps') +require('core.colorscheme') diff --git a/.config/nvim/lua/core/keymaps.lua b/.config/nvim/lua/core/keymaps.lua index f31044f..7ebb107 100644 --- a/.config/nvim/lua/core/keymaps.lua +++ b/.config/nvim/lua/core/keymaps.lua @@ -3,3 +3,23 @@ vim.g.mapleader = " " vim.g.maplocalleader = "\\" local keymap = vim.keymap + +keymap.set("i", "jk", "", { desc = "Exit insert mode with jk" }) + +keymap.set("n", "nh", ":nohl", { desc = "Clear search highlights" }) + +-- inc/dec numbers +keymap.set("n", "+", "", { desc = "Increment number" }) +keymap.set("n", "-", "", { desc = "Decrement number" }) + +-- window management +keymap.set("n", "sv", "v", { desc = "Split window vertically" }) +keymap.set("n", "sh", "s", { desc = "Split window horizontally" }) +keymap.set("n", "se", "=", { desc = "Make splits equal size" }) +keymap.set("n", "sx", "close", { desc = "Close current split" }) + +keymap.set("n", "to", "tabnew", { desc = "Open new tab" }) +keymap.set("n", "tx", "tabclose", { desc = "Close current tab" }) +keymap.set("n", "tn", "tabn", { desc = "Go to next tab" }) +keymap.set("n", "tp", "tabp", { desc = "Go to previous tab" }) +keymap.set("n", "tf", "tabnew %", { desc = "Open current buffer in new tab" }) diff --git a/.config/nvim/lua/core/lazy.lua b/.config/nvim/lua/core/lazy.lua new file mode 100644 index 0000000..896ed22 --- /dev/null +++ b/.config/nvim/lua/core/lazy.lua @@ -0,0 +1,24 @@ +-- lazy bootstrap +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +-- lazy setup +require("lazy").setup({ { import = "plugins" }, { import = "plugins.lsp" } }, { + checker = { + enabled = true, + notify = false, + }, + change_detection = { + notify = false, + } +}) diff --git a/.config/nvim/lua/core/options.lua b/.config/nvim/lua/core/options.lua index f707f41..deae6b1 100644 --- a/.config/nvim/lua/core/options.lua +++ b/.config/nvim/lua/core/options.lua @@ -1,3 +1,5 @@ +vim.cmd("let g:netrw_liststyle = 3") + local opt = vim.opt -- line numbers @@ -24,7 +26,7 @@ opt.iskeyword:append("-") -- consider string-string as a whole word opt.cursorline = true -- appearance -opt.termguicolors = false +opt.termguicolors = true opt.background = "dark" opt.signcolumn = "yes" opt.colorcolumn = "90" diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua deleted file mode 100644 index 0c0abfb..0000000 --- a/.config/nvim/lua/plugins.lua +++ /dev/null @@ -1,69 +0,0 @@ --- auto install packer if not installed -local ensure_packer = function() - local fn = vim.fn - local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" - if fn.empty(fn.glob(install_path)) > 0 then - fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }) - vim.cmd([[packadd packer.nvim]]) - return true - end - return false -end -local packer_bootstrap = ensure_packer() -- true if packer was just installed - --- autocommand that reloads neovim and installs/updates/removes plugins --- when file is saved -vim.cmd([[ - augroup packer_user_config - autocmd! - autocmd BufWritePost plugins.lua source | PackerSync - augroup end -]]) - --- import packer safely -local status, packer = pcall(require, "packer") -if not status then - return -end - -packer.init({ - display = { - open_fn = function() - return require('packer.util').float({ border = 'rounded' }) - end, - }, -}) - --- add list of plugins to install -return packer.startup(function(use) - use("wbthomason/packer.nvim") - use("nvim-lua/plenary.nvim") - use("rmehri01/onenord.nvim") - use("shaunsingh/nord.nvim") - use("christoomey/vim-tmux-navigator") - use("lewis6991/gitsigns.nvim") - use("windwp/nvim-autopairs") - use("nvim-lualine/lualine.nvim") - use("nvim-tree/nvim-web-devicons") - use({ - "nvim-treesitter/nvim-treesitter", - run = function() - local ts_update = require("nvim-treesitter.install").update({ with_sync = true }) - ts_update() - end, - }) - use("tpope/vim-obsession") - use("norcalli/nvim-colorizer.lua") - use({ - "MeanderingProgrammer/render-markdown.nvim", - after = { 'nvim-treesitter' }, - requires = { 'nvim-tree/nvim-web-devicons', opt = true }, - }) - use("seanbreckenridge/gitsigns-yadm") -- bring yadm support back to gitsigns - - use("ThePrimeagen/vim-be-good") -- get gud - - if packer_bootstrap then - require("packer").sync() - end -end) diff --git a/.config/nvim/lua/plugins/alpha.lua b/.config/nvim/lua/plugins/alpha.lua new file mode 100644 index 0000000..ba08d76 --- /dev/null +++ b/.config/nvim/lua/plugins/alpha.lua @@ -0,0 +1,36 @@ +return { + "goolord/alpha-nvim", + event = "VimEnter", + config = function() + local alpha = require("alpha") + local dashboard = require("alpha.themes.dashboard") + + -- Set header + dashboard.section.header.val = { + " ", + " ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ", + " ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ", + " ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ", + " ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ", + " ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ", + " ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ", + " ", + } + + -- Set menu + dashboard.section.buttons.val = { + dashboard.button("e", " > New File", "ene"), + dashboard.button("SPC ee", " > Toggle file explorer", "NvimTreeToggle"), + dashboard.button("SPC ff", "󰱼 > Find File", "Telescope find_files"), + dashboard.button("SPC fs", " > Find Word", "Telescope live_grep"), + dashboard.button("SPC wr", "󰁯 > Restore Session For Current Directory", "SessionRestore"), + dashboard.button("q", " > Quit NVIM", "qa"), + } + + -- Send config to alpha + alpha.setup(dashboard.opts) + + -- Disable folding on alpha buffer + vim.cmd([[autocmd FileType alpha setlocal nofoldenable]]) + end, +} diff --git a/.config/nvim/lua/plugins/auto-session.lua b/.config/nvim/lua/plugins/auto-session.lua new file mode 100644 index 0000000..0f03fe2 --- /dev/null +++ b/.config/nvim/lua/plugins/auto-session.lua @@ -0,0 +1,16 @@ +return { + "rmagatti/auto-session", + config = function() + local auto_session = require("auto-session") + + auto_session.setup({ + auto_restore_enabled = false, + auto_session_suppress_dirs = { "~/", "~/Downloads", "~/Documents", "~/Desktop", "~/Photos" } + }) + + local keymap = vim.keymap + + keymap.set("n", "wr", "SessionRestore", { desc = "Restore session for cwd" }) + keymap.set("n", "ws", "SessionSave", { desc = "Save session for auto session root dir" }) + end, +} diff --git a/.config/nvim/lua/plugins/autopairs.lua b/.config/nvim/lua/plugins/autopairs.lua index 16ac95d..ea2daff 100644 --- a/.config/nvim/lua/plugins/autopairs.lua +++ b/.config/nvim/lua/plugins/autopairs.lua @@ -1,14 +1,24 @@ -local autopairs_setup, autopairs = pcall(require, "nvim-autopairs") -if not autopairs_setup then - return -end - -autopairs.setup({ - check_ts = true, - ts_config = { - lua = { "string" }, - javascript = { "template_string" }, - java = false, +return { + "windwp/nvim-autopairs", + event = { "InsertEnter" }, + dependencies = { + "hrsh7th/nvim-cmp", }, -}) + config = function() + local autopairs = require("nvim-autopairs") + + autopairs.setup({ + check_ts = true, + ts_config = { + lua = { "string" }, + javascript = { "template_string" }, + java = false, + }, + }) + + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + local cmp = require("cmp") + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) + end, +} diff --git a/.config/nvim/lua/plugins/bufferline.lua b/.config/nvim/lua/plugins/bufferline.lua new file mode 100644 index 0000000..af55276 --- /dev/null +++ b/.config/nvim/lua/plugins/bufferline.lua @@ -0,0 +1,11 @@ +return { + "akinsho/bufferline.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + version = "*", + opts = { + options = { + mode = "tabs", + separator_style = "slant", + }, + }, +} diff --git a/.config/nvim/lua/plugins/colorizer.lua b/.config/nvim/lua/plugins/colorizer.lua deleted file mode 100644 index 706ebe9..0000000 --- a/.config/nvim/lua/plugins/colorizer.lua +++ /dev/null @@ -1,7 +0,0 @@ -require 'colorizer'.setup({ - 'css'; - 'javascript'; - 'html'; - 'conf'; - 'yaml'; -}) diff --git a/.config/nvim/lua/plugins/comment.lua b/.config/nvim/lua/plugins/comment.lua new file mode 100644 index 0000000..ae7d7e5 --- /dev/null +++ b/.config/nvim/lua/plugins/comment.lua @@ -0,0 +1,16 @@ +return { + "numToStr/Comment.nvim", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "JoosepAlviste/nvim-ts-context-commentstring", + }, + + config = function() + local comment = require("Comment") + local ts_context_commentstring = require("ts_context_commentstring.integrations.comment_nvim") + + comment.setup({ + pre_hook = ts_context_commentstring.create_pre_hook(), + }) + end, +} diff --git a/.config/nvim/lua/plugins/dressing.lua b/.config/nvim/lua/plugins/dressing.lua new file mode 100644 index 0000000..d5f9379 --- /dev/null +++ b/.config/nvim/lua/plugins/dressing.lua @@ -0,0 +1,5 @@ +return { + "stevearc/dressing.nvim", + event = "VeryLazy", + opts = {}, +} diff --git a/.config/nvim/lua/plugins/gitsigns.lua b/.config/nvim/lua/plugins/gitsigns.lua index b286e77..a59b23e 100644 --- a/.config/nvim/lua/plugins/gitsigns.lua +++ b/.config/nvim/lua/plugins/gitsigns.lua @@ -1,49 +1,84 @@ -local setup, gitsigns = pcall(require, "gitsigns") -if not setup then - return -end +return { + "lewis6991/gitsigns.nvim", + event = { "BufReadPre", "BufNewFile" }, + opts = { + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, desc) + vim.keuymap.set(mode, l, r, { buffer = bufnr, desc = desc }) + end -gitsigns.setup { - _on_attach_pre = - function(_, callback) - require("gitsigns-yadm").yadm_signs(callback) + map("n", "]h", gs.next_hunk, "Next Hunk") + map("n", "[h", gs.prev_hunk, "Prev Hunk") + + map("n", "hs", gs.stage_hunk, "Stage Hunk") + map("n", "hr", gs.reset_hunk, "Reset Hunk") + map("v", "hs", function() + gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, "Reset Hunk") + + map("n", "hS", gs.stage_buffer, "Stage buffer") + map("n", "hR", gs.reset_buffer, "Reset buffer") + map("n", "hu", gs.undo_stage_hunk, "Undo stage hunk") + map("n", "hp", gs.preview_hunk, "Preview hunk") + + map("n", "hb", function() + gs.blame_line({ full = true }) + end, "Blame line") + + map("n", "hB", gs.toggle_current_line_blame, "Toggle line blame") + + map("n", "hd", gs.diffthis, "Diff this") + map("n", "hD", function() + gs.diffthis("~") + end, "Diff this ~") + + map({ "o", "x" }, "ih", ":Gitsigns select_hunk", "Gitsigns select hunk") end, - signs = { - add = { text = '+' }, - change = { text = '│' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - untracked = { text = '┆' }, }, - signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` - numhl = false, -- Toggle with `:Gitsigns toggle_numhl` - linehl = false, -- Toggle with `:Gitsigns toggle_linehl` - word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` - watch_gitdir = { - interval = 1000, - follow_files = true - }, - attach_to_untracked = true, - current_line_blame = true, -- Toggle with `:Gitsigns toggle_current_line_blame` - current_line_blame_opts = { - virt_text = true, - virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' - delay = 200, - ignore_whitespace = false, - }, - current_line_blame_formatter = ', - ', - sign_priority = 6, - update_debounce = 100, - status_formatter = nil, -- Use default - max_file_length = 40000, -- Disable if file is longer than this (in lines) - preview_config = { - -- Options passed to nvim_open_win - border = 'single', - style = 'minimal', - relative = 'cursor', - row = 0, - col = 1 - }, - -- on_attach = function(bufnr) + + config = function() + local gitsigns = require("gitsigns") + + gitsigns.setup { + signs = { + add = { text = '+' }, + change = { text = '│' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + untracked = { text = '┆' }, + }, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + interval = 1000, + follow_files = true + }, + attach_to_untracked = true, + current_line_blame = true, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' + delay = 200, + ignore_whitespace = false, + }, + current_line_blame_formatter = ', - ', + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, -- Disable if file is longer than this (in lines) + preview_config = { + -- Options passed to nvim_open_win + border = 'single', + style = 'minimal', + relative = 'cursor', + row = 0, + col = 1 + }, + } + end, } diff --git a/.config/nvim/lua/plugins/indent-blankline.lua b/.config/nvim/lua/plugins/indent-blankline.lua new file mode 100644 index 0000000..af06198 --- /dev/null +++ b/.config/nvim/lua/plugins/indent-blankline.lua @@ -0,0 +1,8 @@ +return { + "lukas-reineke/indent-blankline.nvim", + event = { "BufReadPre", "BufNewFile" }, + main = "ibl", + opts = { + indent = { char = "┊" }, + }, +} diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..7eddacc --- /dev/null +++ b/.config/nvim/lua/plugins/init.lua @@ -0,0 +1,4 @@ +return { + "nvim-lua/plenary.nvim", + "christoomey/vim-tmux-navigator", +} diff --git a/.config/nvim/lua/plugins/lazygit.lua b/.config/nvim/lua/plugins/lazygit.lua new file mode 100644 index 0000000..4c4aebc --- /dev/null +++ b/.config/nvim/lua/plugins/lazygit.lua @@ -0,0 +1,16 @@ +return { + "kdheepak/lazygit.nvim", + cmd = { + "LazyGit", + "LazyGitConfig", + "LazyGitCurrentFile", + "LazyGitFilter", + "LazyGitFilterCurrentFile", + }, + dependencies = { + "nvim-lua/plenary.nvim", + }, + keys = { + { "lg", "LazyGit", desc = "Open LazyGit" }, + }, +} diff --git a/.config/nvim/lua/plugins/linting.lua b/.config/nvim/lua/plugins/linting.lua new file mode 100644 index 0000000..bfba8a0 --- /dev/null +++ b/.config/nvim/lua/plugins/linting.lua @@ -0,0 +1,30 @@ +return { + "mfussenegger/nvim-lint", + event = { "BufReadPre", "BufNewFile" }, + + config = function() + local lint = require("lint") + + lint.linters_by_ft = { + javascript = { "eslint_d" }, + typescript = { "eslint_d" }, + javascriptreact = { "eslint_d" }, + typescriptreact = { "eslint_d" }, + svelte = { "eslint_d" }, + python = { "pylint" }, + } + + local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + + vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { + group = lint_augroup, + callback = function() + lint.try_lint() + end, + }) + + vim.keymap.set("n", "l", function() + lint.try_lint() + end, { desc = "Trigger linting for current file"}) + end, +} diff --git a/.config/nvim/lua/plugins/lsp/lspconfig.lua b/.config/nvim/lua/plugins/lsp/lspconfig.lua new file mode 100644 index 0000000..5983f89 --- /dev/null +++ b/.config/nvim/lua/plugins/lsp/lspconfig.lua @@ -0,0 +1,103 @@ +return { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "hrsh7th/cmp-nvim-lsp", + { "antosha417/nvim-lsp-file-operations", config = true }, + { "folke/neodev.nvim", opts = {} }, + }, + + config = function() + local lspconfig = require("lspconfig") + local mason_lspconfig = require("mason-lspconfig") + local cmp_nvim_lsp = require("cmp_nvim_lsp") + local keymap = vim.keymap + + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(ev) + local opts = { buffer = ev.buf, silent=true } + + opts.desc = "Show LSP references" + keymap.set("n", "gR", "Telescope lsp_references", opts) + + opts.desc = "Go to declaration" + keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + + opts.desc = "Show LSP definitions" + keymap.set("n", "gd", "Telescope lsp_definitions", opts) + + opts.desc = "Show LSP implementations" + keymap.set("n", "gi", "Telescope lsp_implementations", opts) + + opts.desc = "Show LSP type definitions" + keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) + + opts.desc = "See available code actions" + keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) + + opts.desc = "Smart rename" + keymap.set("n", "rn", vim.lsp.buf.rename, opts) + + opts.desc = "Show buffer diagnostics" + keymap.set("n", "D", "Telescope diagnostics bufnf=0", opts) + + opts.desc = "Show line diagnostics" + keymap.set("n", "d", vim.diagnostic.open_float, opts) + + opts.desc = "Go to previous diagnostic" + keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) + + opts.desc = "Go to next diagnostic" + keymap.set("n", "]d", vim.diagnostic.goto_next, opts) + + opts.desc = "Show documentation for what is under cursor" + keymap.set("n", "K", vim.lsp.buf.hover, opts) + + opts.desc = "Restart LSP" + keymap.set("n", "rs", ":LspRestart", opts) + end, + }) + + local capabilities = cmp_nvim_lsp.default_capabilities() + + local signs = { Error = " ", Warn = " ", Hint = "󰠠 ", Info = " " } + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) + end + + mason_lspconfig.setup_handlers({ + -- default handler for installed servers + function(server_name) + lspconfig[server_name].setup({ + capabilities = capabilities, + }) + end, + ["emmet_ls"] = function() + -- configure emmet language server + lspconfig["emmet_ls"].setup({ + capabilities = capabilities, + filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" }, + }) + end, + ["lua_ls"] = function() + -- configure lua server (with special settings) + lspconfig["lua_ls"].setup({ + capabilities = capabilities, + settings = { + Lua = { + -- make the language server recognize "vim" global + diagnostics = { + globals = { "vim" }, + }, + completion = { + callSnippet = "Replace", + }, + }, + }, + }) + end, + }) + end, +} diff --git a/.config/nvim/lua/plugins/lsp/mason.lua b/.config/nvim/lua/plugins/lsp/mason.lua new file mode 100644 index 0000000..401b0ec --- /dev/null +++ b/.config/nvim/lua/plugins/lsp/mason.lua @@ -0,0 +1,43 @@ +return { + "williamboman/mason.nvim", + dependencies = { + "williamboman/mason-lspconfig.nvim", + "WhoIsSethDaniel/mason-tool-installer.nvim", + }, + + config = function() + local mason = require("mason") + local mason_lspconfig = require("mason-lspconfig") + local mason_tool_installer = require("mason-tool-installer") + + mason.setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", + }, + }, + }) + + mason_lspconfig.setup({ + ensure_installed = { + "html", + "cssls", + "lua_ls", + "emmet_ls", + }, + }) + + mason_tool_installer.setup({ + ensure_installed = { + "prettier", + "stylua", + "isort", + "black", + "pylint", + "eslint_d", + }, + }) + end, +} diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua index bfe3179..7387f26 100644 --- a/.config/nvim/lua/plugins/lualine.lua +++ b/.config/nvim/lua/plugins/lualine.lua @@ -1,40 +1,59 @@ -require('lualine').setup { - options = { - icons_enabled = true, - theme = 'onenord', - component_separators = { left = '', right = ''}, - section_separators = { left = '', right = ''}, - disabled_filetypes = { - statusline = {}, - winbar = {}, - }, - ignore_focus = {}, - always_divide_middle = true, - globalstatus = false, - refresh = { - statusline = 1000, - tabline = 1000, - winbar = 1000, - } - }, - sections = { - lualine_a = {'mode'}, - lualine_b = {'branch', 'diff', 'diagnostics'}, - lualine_c = {'filename'}, - lualine_x = {'encoding', 'fileformat', 'filetype'}, - lualine_y = {'progress'}, - lualine_z = {'location'} - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = {'filename'}, - lualine_x = {'location'}, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - winbar = {}, - inactive_winbar = {}, - extensions = {} +return { + "nvim-lualine/lualine.nvim", + dependencies = { + "nvim-tree/nvim-web-devicons", + "rmehri01/onenord.nvim" + }, + config = function() + local lualine = require("lualine") + local lazy_status = require("lazy.status") + + lualine.setup({ + options = { + icons_enabled = true, + theme = 'onenord', + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = { + { + lazy_status.updates, + cond = lazy_status.has_updates, + color = { fg = "#ff9e64" }, + }, + {'encoding', 'fileformat', 'filetype'}, + }, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} + }) + end, } diff --git a/.config/nvim/lua/plugins/nvim-cmp.lua b/.config/nvim/lua/plugins/nvim-cmp.lua new file mode 100644 index 0000000..39dba20 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-cmp.lua @@ -0,0 +1,56 @@ +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + { + "L3MON4D3/LuaSnip", + version = "v2.*", + build = "make install_jsregexp", + }, + "saadparwaiz1/cmp_luasnip", + "rafamadriz/friendly-snippets", + "onsails/lspkind.nvim", + }, + + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + local lspkind = require("lspkind") + + require("luasnip.loaders.from_vscode").lazy_load() + + cmp.setup({ + completion = { + completeopt = "menu,menuone,preview,noselect", + }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = false }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }), + formatting = { + format = lspkind.cmp_format({ + maxwidth = 50, + ellipsis_char = "...", + }), + }, + }) + end, +} diff --git a/.config/nvim/lua/plugins/nvim-tree.lua b/.config/nvim/lua/plugins/nvim-tree.lua new file mode 100644 index 0000000..05d8e86 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-tree.lua @@ -0,0 +1,50 @@ +return { + "nvim-tree/nvim-tree.lua", + dependencies = "nvim-tree/nvim-web-devicons", + config = function() + local nvimtree = require("nvim-tree") + + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + + nvimtree.setup({ + view = { + width = 35, + relativenumber = true, + }, + renderer = { + indent_markers = { + enable = true, + }, + icons = { + glyphs = { + folder = { + arrow_closed = "", -- arrow when folder is closed + arrow_open = "", -- arrow when folder is open + }, + }, + }, + }, + actions = { + open_file = { + window_picker = { + enable = false, + }, + }, + }, + filters = { + custom = { ".DS_Store" }, + }, + git = { + ignore = false, + }, + }) + + local keymap = vim.keymap + + keymap.set("n", "ee", "NvimTreeToggle", { desc = "Toggle file explorer" }) + keymap.set("n", "ef", "NvimTreeFindFileToggle", { desc = "Toggle file explorer on current file" }) + keymap.set("n", "ec", "NvimTreeCollapse", { desc = "Collapse file explorer" }) + keymap.set("n", "er", "NvimTreeRefresh", { desc = "Refresh file explorer" }) + end +} diff --git a/.config/nvim/lua/plugins/prettier.lua b/.config/nvim/lua/plugins/prettier.lua new file mode 100644 index 0000000..85744b0 --- /dev/null +++ b/.config/nvim/lua/plugins/prettier.lua @@ -0,0 +1,40 @@ +return { + "stevearc/conform.nvim", + event = { "BufReadPre", "BufNewFile" }, + + config = function() + local conform = require("conform") + + conform.setup({ + formatters_by_ft = { + javascript = { "prettier" }, + typescript = { "prettier" }, + javascriptreact = { "prettier" }, + typescriptreact = { "prettier" }, + svelte = { "prettier" }, + css = { "prettier" }, + html = { "prettier" }, + json = { "prettier" }, + yaml = { "prettier" }, + markdown = { "prettier" }, + graphql = { "prettier" }, + liquid = { "prettier" }, + lua = { "stylua" }, + python = { "sort", "black" }, + }, + format_on_save = { + lsp_fallback = true, + async = false, + timeout_ms = 1000, + }, + }) + + vim.keymap.set({ "n", "v" }, "mp", function() + conform.format({ + lsp_fallback = true, + async = false, + timeout_ms = 1000, + }) + end, { desc = "Format file or range (in visual mode)" }) + end, +} diff --git a/.config/nvim/lua/plugins/substitute.lua b/.config/nvim/lua/plugins/substitute.lua new file mode 100644 index 0000000..b4e47a1 --- /dev/null +++ b/.config/nvim/lua/plugins/substitute.lua @@ -0,0 +1,17 @@ +return { + "gbprod/substitute.nvim", + event = { "BufReadPre", "BufNewFile" }, + + config = function() + local substitute = require("substitute") + + substitute.setup() + + local keymap = vim.keymap + + keymap.set("n", "s", substitute.operator, { desc = "Substitute with motion" }) + keymap.set("n", "ss", substitute.line, { desc = "Substitute line" }) + keymap.set("n", "S", substitute.line, { desc = "Substitute to end of line" }) + keymap.set("x", "s", substitute.visual, { desc = "Substitute in visual mode" }) + end, +} diff --git a/.config/nvim/lua/plugins/surround.lua b/.config/nvim/lua/plugins/surround.lua new file mode 100644 index 0000000..5907810 --- /dev/null +++ b/.config/nvim/lua/plugins/surround.lua @@ -0,0 +1,6 @@ +return { + "kylechui/nvim-surround", + event = { "BufReadPre", "BufNewFile" }, + version = "*", + config = true, +} diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..eebb438 --- /dev/null +++ b/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,38 @@ +return { + "nvim-telescope/telescope.nvim", + branch = "0.1.x", + dependencies = { + "nvim-lua/plenary.nvim", + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + "nvim-tree/nvim-web-devicons", + "folke/todo-comments.nvim", + }, + config = function() + local telescope = require("telescope") + local actions = require("telescope.actions") + + telescope.setup({ + defaults = { + path_display = { "smart" }, + mappings = { + i = { + [""] = actions.move_selection_previous, + [""] = actions.move_selection_next, + [""] = actions.send_selected_to_qflist + actions.open_qflist, + }, + }, + }, + }) + + telescope.load_extension("fzf") + + -- keymaps + local keymap = vim.keymap + + keymap.set("n", "ff", "Telescope find_files", { desc = "Fuzzy find files in cwd" }) + keymap.set("n", "fr", "Telescope oldfiles", { desc = "Fuzzy find recent files" }) + keymap.set("n", "fs", "Telescope live_grep", { desc = "Find string in cwd" }) + keymap.set("n", "fc", "Telescope grep_string", { desc = "Find string under cursor in cwd" }) + keymap.set("n", "ft", "TodoTelescope", { desc = "Find todos" }) + end, +} diff --git a/.config/nvim/lua/plugins/todo-comments.lua b/.config/nvim/lua/plugins/todo-comments.lua new file mode 100644 index 0000000..2583bcf --- /dev/null +++ b/.config/nvim/lua/plugins/todo-comments.lua @@ -0,0 +1,20 @@ +return { + "folke/todo-comments.nvim", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { "nvim-lua/plenary.nvim" }, + + config = function() + local todo_comments = require("todo-comments") + local keymap = vim.keymap + + keymap.set("n", "]t", function() + todo_comments.jump_next() + end, { desc = "Next todo comment" }) + + keymap.set("n", "[t", function() + todo_comments.jump_prev() + end, { desc = "Previous todo comment" }) + + todo_comments.setup() + end, +} diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index bb588f5..750062e 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -1,44 +1,60 @@ -local status, treesitter = pcall(require, "nvim-treesitter.configs") -if not status then - return -end +return { + "nvim-treesitter/nvim-treesitter", + event = { "BufReadPre", "BufNewFile" }, + build = ":TSUpdate", + dependencies = { + "windwp/nvim-ts-autotag", + }, + config = function() + local treesitter = require("nvim-treesitter.configs") -treesitter.setup({ - highlight = { - enable = true, - }, - indent = { enable = true }, - autotag = { enable = true }, - ensure_installed = { - "bash", - "cmake", - "cpp", - "css", - "diff", - "dockerfile", - "git_config", - "git_rebase", - "gitcommit", - "gitignore", - "graphql", - "html", - "javascript", - "json", - "lua", - "markdown", - "markdown_inline", - "nginx", - "perl", - "php", - "python", - "regex", - "sql", - "ssh_config", - "todotxt", - "typescript", - "vim", - "xml", - "yaml", - }, - auto_install = true, -}) + treesitter.setup({ + highlight = { + enable = true, + }, + indent = { enable = true }, + autotag = { enable = true }, + ensure_installed = { + "bash", + "cmake", + "cpp", + "css", + "diff", + "dockerfile", + "git_config", + "git_rebase", + "gitcommit", + "gitignore", + "graphql", + "html", + "javascript", + "json", + "lua", + "markdown", + "markdown_inline", + "nginx", + "perl", + "php", + "python", + "regex", + "sql", + "ssh_config", + "todotxt", + "typescript", + "vim", + "xml", + "yaml", + }, + auto_install = true, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = false, + node_decremental = "", + }, + }, + }) + end, +} diff --git a/.config/nvim/lua/plugins/trouble.lua b/.config/nvim/lua/plugins/trouble.lua new file mode 100644 index 0000000..3614bf4 --- /dev/null +++ b/.config/nvim/lua/plugins/trouble.lua @@ -0,0 +1,15 @@ +return { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons", "folke/todo-comments.nvim", }, + opts = { + focus = true, + }, + cmd = "Trouble", + keys = { + { "xw", "Trouble diagnostics toggle", desc = "Open trouble workspace diagnostics" }, + { "xd", "Trouble diagnostics toggle filter.buf=0", desc = "Open trouble document diagnostics" }, + { "xq", "Trouble quickfix toggle", desc = "Open trouble quickfix list" }, + { "xl", "Trouble loclist toggle", desc = "Open trouble location list" }, + { "xt", "Trouble todo toggle", desc = "Open todos in trouble" }, + }, +} diff --git a/.config/nvim/lua/plugins/vim-maximizer.lua b/.config/nvim/lua/plugins/vim-maximizer.lua new file mode 100644 index 0000000..f30868f --- /dev/null +++ b/.config/nvim/lua/plugins/vim-maximizer.lua @@ -0,0 +1,6 @@ +return { + "szw/vim-maximizer", + keys = { + { "sm", "MaximizerToggle", desc = "Maximize/Minimize a split" }, + }, +} diff --git a/.config/nvim/lua/plugins/which-key.lua b/.config/nvim/lua/plugins/which-key.lua new file mode 100644 index 0000000..eb481dd --- /dev/null +++ b/.config/nvim/lua/plugins/which-key.lua @@ -0,0 +1,10 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 500 + end, + opts = { + }, +}