diff --git a/init.lua b/init.lua index b7dae8a..05c8de9 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,24 @@ require("config.options") require("config.keymaps") -require("config.autocmds") -require("core.lazy") + +-- Boostrap lazy.nvim +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", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ import = "custom/plugins" }, { + change_detection = { + notify = false, + }, +}) + +vim.cmd([[colorscheme mellow]]) diff --git a/lazy-lock.json b/lazy-lock.json index 2e8920c..cddabed 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,7 +1,6 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, - "cellular-automaton.nvim": { "branch": "main", "commit": "11aea08aa084f9d523b0142c2cd9441b8ede09ed" }, + "LuaSnip": { "branch": "master", "commit": "2737edc9e674e537dc0a97e3405658d57d2d31ed" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, @@ -10,8 +9,10 @@ "gitsigns.nvim": { "branch": "main", "commit": "4daf7022f1481edf1e8fb9947df13bb07c18e89a" }, "indent-blankline.nvim": { "branch": "master", "commit": "04e44b09ee3ff189c69ab082edac1ef7ae2e256c" }, "lazy.nvim": { "branch": "main", "commit": "b1134ab82ee4279e31f7ddf7e34b2a99eb9b7bc9" }, + "lazygit.nvim": { "branch": "main", "commit": "56760339a81cd1540d5a72fd9d93010a2677b55d" }, "lsp-zero.nvim": { "branch": "v4.x", "commit": "4f1e00bfe276758d30fec5d1eb161108ff8a959b" }, "lsp_signature.nvim": { "branch": "master", "commit": "fc38521ea4d9ec8dbd4c2819ba8126cea743943b" }, + "lspkind.nvim": { "branch": "master", "commit": "a700f1436d4a938b1a1a93c9962dc796afbaef4d" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "mellow.nvim": { "branch": "main", "commit": "434a02d5f7637a24824569426176f37473205053" }, @@ -19,8 +20,8 @@ "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, "nvim-lspconfig": { "branch": "master", "commit": "d01864641c6e43c681c3e9f6cf4745c75fdd9dcc" }, - "nvim-treesitter": { "branch": "master", "commit": "425b58968340bd5b4621c2a0d626c73556516d3d" }, - "nvim-treesitter-context": { "branch": "master", "commit": "a2a334900d3643de585ac5c6140b03403454124f" }, + "nvim-treesitter": { "branch": "master", "commit": "0603b3e3d21ebe2fa82dc5361a3d500e0d3ad3a8" }, + "nvim-treesitter-context": { "branch": "master", "commit": "158377d700596367a91ea41818f76abdbf75a232" }, "nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" }, "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, "oil.nvim": { "branch": "master", "commit": "52cc8a1fb35ea6ce1df536143add7ce7215c63c0" }, @@ -28,8 +29,5 @@ "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, "telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" }, "trouble.nvim": { "branch": "main", "commit": "3dc00c0447c016cd43e03054c3d49436a1f2076d" }, - "vim-fetch": { "branch": "master", "commit": "db3fd95eb0cf7e7e9effa1338b286db33e4a36c1" }, - "vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" }, - "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, - "vim-unimpaired": { "branch": "master", "commit": "6d44a6dc2ec34607c41ec78acf81657248580bf1" } + "vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" } } diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua deleted file mode 100644 index 9685c00..0000000 --- a/lua/config/autocmds.lua +++ /dev/null @@ -1,13 +0,0 @@ --- Remove trailing whitespace on save --- vim.api.nvim_create_autocmd({"BufWritePre"}, { --- group = vim.api.nvim_create_augroup("Default", {}), --- pattern = "*", --- command = [[%s/\s\+$//e]], --- }) - --- LSP Auto format on save --- vim.api.nvim_create_autocmd({ "BufWritePre" }, { --- group = vim.api.nvim_create_augroup("Default", {}), --- pattern = "*", --- command = [[lua vim.lsp.buf.format()]], --- }) diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 7f34537..a3af9cc 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -1,54 +1,49 @@ +local set = vim.keymap.set + +-- Leader key vim.g.mapleader = " " -vim.keymap.set("n", "e", ":Oil") -vim.keymap.set("i", "", "") +-- Open file explorer +set("n", "e", ":Oil") + +-- Use same behavior for as +set("i", "", "") -- Keep things centered -vim.keymap.set("n", "n", "nzz") -vim.keymap.set("n", "N", "Nzz") -vim.keymap.set("n", "", "zz") -vim.keymap.set("n", "", "zz") -vim.keymap.set("n", "", "cnextzz") -vim.keymap.set("n", "", "cprevzz") +set("n", "n", "nzz") +set("n", "N", "Nzz") +set("n", "", "zz") +set("n", "", "zz") +set("n", "", "cnextzz") +set("n", "", "cprevzz") -- Copy to system clipboard -vim.keymap.set({ "n", "v" }, "y", [["+y]]) +set({ "n", "v" }, "y", [["+y]]) -- Escape terminal mode -vim.keymap.set("t", "", "") +set("t", "", "") --- Toggle hlsearch if it's on, otherwise just do "enter" -vim.keymap.set("n", "", function() - ---@diagnostic disable-next-line: undefined-field - if vim.v.hlsearch == 1 then - vim.cmd.nohl() - return "" - else - return vim.keycode "" - end -end, { expr = true }) - -vim.keymap.set("n", "bd", "bd") +-- Delete buffer +set("n", "bd", "bd") -- Thanks to Mr. Primeagen -vim.keymap.set({ "n", "v" }, "", "silent !tmux neww tmux-sessionizer") -vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) -vim.keymap.set("v", "J", ":m '>+1gv=gv") -vim.keymap.set("v", "K", ":m '<-2gv=gv") +set({ "n", "v" }, "", "silent !tmux neww tmux-sessionizer") + +-- Replace all occurences of word +set("n", "s", [[:%s/\<\>//gI]]) + +-- Move lines around in visual mode +set("v", "J", ":m '>+1gv=gv") +set("v", "K", ":m '<-2gv=gv") -- Move between windows with actual arrow keys -vim.keymap.set("n", "", "h") -vim.keymap.set("n", "", "j") -vim.keymap.set("n", "", "k") -vim.keymap.set("n", "", "l") +set("n", "", "h") +set("n", "", "j") +set("n", "", "k") +set("n", "", "l") -- Duplicate line -vim.keymap.set("n", "d", "mzyyp`zj") +set("n", "d", "mzyyp`zj") -- Open a new terminal pane -vim.keymap.set("n", "t", "botright terminal") --- Focus the terminal pane -vim.keymap.set("n", "f", function() - local bufnr = vim.fn.bufnr("#") - vim.api.nvim_set_current_buf(bufnr) -end) +set("n", "t", "botright terminal") diff --git a/lua/config/options.lua b/lua/config/options.lua index b89cda0..97f32e1 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -1,43 +1,60 @@ local opt = vim.opt +-- Better line number display opt.number = true opt.relativenumber = true +-- Use tabs opt.tabstop = 4 opt.softtabstop = 4 opt.shiftwidth = 4 opt.expandtab = false opt.smartindent = true + +-- Highlight cursor line opt.cursorline = true +-- Use line wrapping opt.wrap = true opt.linebreak = true opt.breakindent = true opt.showbreak = "> " +-- show partial result in preview window for :substitute opt.inccommand = "split" +-- Better search settings +opt.hlsearch = false opt.incsearch = true -opt.smartcase = true opt.ignorecase = true +opt.smartcase = true +-- Split the other way around opt.splitbelow = true opt.splitright = true +-- prevent comment insertion when pressing 'o' on a commented line opt.formatoptions:remove "o" +-- Prevent pause on long listing that don't fit inside the buffer +opt.more = false + +-- Undo settings opt.swapfile = false opt.backup = false opt.undodir = os.getenv("HOME") .. "/.vim/undodir" opt.undofile = true +opt.updatetime = 100 +-- Enable 24 bits colors opt.termguicolors = true -opt.scrolloff = 8 -opt.updatetime = 100 +-- Minimal number of screen lines to keep above and below the cursor +opt.scrolloff = 12 + +-- List of characters opt.list = true opt.listchars = "tab: ,extends:›,precedes:‹,nbsp:·,trail:·" +-- System wide clipboard opt.clipboard = "unnamedplus" - -opt.more = false diff --git a/lua/core/lazy.lua b/lua/core/lazy.lua deleted file mode 100644 index 6ef25cc..0000000 --- a/lua/core/lazy.lua +++ /dev/null @@ -1,17 +0,0 @@ --- Boostrap Lazy.nvim -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", -- latest stable release - lazypath, - }) -end -vim.opt.rtp:prepend(lazypath) - -require("lazy").setup({ { import = "plugins" } }) - -vim.cmd([[colorscheme mellow]]) diff --git a/lua/custom/completion.lua b/lua/custom/completion.lua new file mode 100644 index 0000000..82d41e6 --- /dev/null +++ b/lua/custom/completion.lua @@ -0,0 +1,34 @@ +local cmp = require("cmp") +local defaults = require("cmp.config.default")() +local lspkind = require "lspkind" +lspkind.init {} + +cmp.setup({ + completion = { + completeopt = "menu,menuone,noinsert", + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }, { "i", "c" }), + }), + -- Enable luasnip to handle snippet expansion for nvim-cmp + snippet = { + expand = function(args) + vim.snippet.expand(args.body) + end, + }, + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "path" }, + { name = "luasnip" }, + { name = "buffer" }, + }), + sorting = defaults.sorting, +}) diff --git a/lua/plugins/lsp/config.lua b/lua/custom/lsp/config.lua similarity index 50% rename from lua/plugins/lsp/config.lua rename to lua/custom/lsp/config.lua index b55cd81..106a893 100644 --- a/lua/plugins/lsp/config.lua +++ b/lua/custom/lsp/config.lua @@ -1,67 +1,18 @@ local lsp_zero = require("lsp-zero") local lspconfig = require("lspconfig") -lspconfig.gleam.setup({}) - -lspconfig.lua_ls.setup({ - settings = { - Lua = { - diagnostics = { - globals = { "vim" }, - }, - }, - }, -}) - -lspconfig.gopls.setup({ - on_attach = function(_, bufnr) - -- autcmd format on save - vim.api.nvim_create_autocmd("BufWritePre", { - buffer = bufnr, - callback = function() - vim.lsp.buf.format() - end, - }) - - -- autocmd Organize Imports on save - vim.api.nvim_create_autocmd("BufWritePre", { - buffer = bufnr, - callback = function() - local params = vim.lsp.util.make_range_params() - params.context = {only = {"source.organizeImports"}} - local result = vim.lsp.buf_request_sync(bufnr, "textDocument/codeAction", params, 1000) - for _, res in pairs(result or {}) do - for _, r in pairs(res.result or {}) do - if r.edit then - vim.lsp.util.apply_workspace_edit(r.edit, "utf-8") - else - vim.lsp.buf.execute_command(r.command) - end - end - end - end, - }) - end, -}) - - -lspconfig.eslint.setup({ - on_attach = function(_, bufnr) - vim.api.nvim_create_autocmd("BufWritePre", { - buffer = bufnr, - command = "EslintFixAll", - }) - end, -}) - - -lsp_zero.set_sign_icons({ - error = "✘", - warn = "▲", - hint = "⚑", - info = "" -}) +local servers = {} +-- Autoload LSPs from ./config/*.lua files +for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/custom/lsp/config/*.lua", true)) do + local lua_path = ft_path:gsub(".*/lua/(.+)%.lua", "%1") + local module_path = lua_path:gsub('/', '.') + local config = require(module_path) + local name = module_path:match("%.([^%.]+)$") + lspconfig[name].setup(config) + table.insert(servers, name) +end +-- Configure Vim diagnostic vim.diagnostic.config({ virtual_text = true, severity_sort = true, @@ -74,6 +25,15 @@ vim.diagnostic.config({ }, }) +-- Lsp icons +lsp_zero.set_sign_icons({ + error = "✘", + warn = "▲", + hint = "⚑", + info = "" +}) + +-- Keybindings lsp_zero.on_attach(function(_, bufnr) local opts = { buffer = bufnr, remap = false } lsp_zero.default_keymaps({ buffer = bufnr }) @@ -92,16 +52,11 @@ lsp_zero.on_attach(function(_, bufnr) vim.keymap.set("n", "", function() vim.lsp.buf.format() end, opts) end) +-- Mason configuration +local ensure_installed = { "html", "rust_analyzer", "zls", "ts_ls" } require("mason-lspconfig").setup({ handlers = { lsp_zero.default_setup, }, - ensure_installed = { - "lua_ls", - "html", - "eslint", - "gopls", - "rust_analyzer", - "zls", - }, + ensure_installed = vim.list_extend(ensure_installed, servers), }) diff --git a/lua/custom/lsp/config/eslint.lua b/lua/custom/lsp/config/eslint.lua new file mode 100644 index 0000000..88ba19d --- /dev/null +++ b/lua/custom/lsp/config/eslint.lua @@ -0,0 +1,9 @@ +return { + on_attach = function(_, bufnr) + -- Auto format with eslint fix all + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = bufnr, + command = "EslintFixAll", + }) + end, +} diff --git a/lua/custom/lsp/config/gopls.lua b/lua/custom/lsp/config/gopls.lua new file mode 100644 index 0000000..ab2e80f --- /dev/null +++ b/lua/custom/lsp/config/gopls.lua @@ -0,0 +1,43 @@ +return { + settings = { + gopls = { + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + }, + }, + on_attach = function(_, bufnr) + -- Format document on save + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = bufnr, + callback = function() + vim.lsp.buf.format() + end, + }) + + -- Auto organize imports on save + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = bufnr, + callback = function() + local params = vim.lsp.util.make_range_params() + params.context = { only = { "source.organizeImports" } } + local result = vim.lsp.buf_request_sync(bufnr, "textDocument/codeAction", params, 1000) + for _, res in pairs(result or {}) do + for _, r in pairs(res.result or {}) do + if r.edit then + vim.lsp.util.apply_workspace_edit(r.edit, "utf-8") + else + vim.lsp.buf.execute_command(r.command) + end + end + end + end, + }) + end, +} diff --git a/lua/custom/lsp/config/lua_ls.lua b/lua/custom/lsp/config/lua_ls.lua new file mode 100644 index 0000000..54f3aef --- /dev/null +++ b/lua/custom/lsp/config/lua_ls.lua @@ -0,0 +1,9 @@ +return { + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + }, + }, +} diff --git a/lua/custom/plugins/colorizer.lua b/lua/custom/plugins/colorizer.lua new file mode 100644 index 0000000..b76ab77 --- /dev/null +++ b/lua/custom/plugins/colorizer.lua @@ -0,0 +1 @@ +return { 'norcalli/nvim-colorizer.lua' } diff --git a/lua/custom/plugins/comment.lua b/lua/custom/plugins/comment.lua new file mode 100644 index 0000000..786543d --- /dev/null +++ b/lua/custom/plugins/comment.lua @@ -0,0 +1 @@ +return { "numToStr/Comment.nvim" } diff --git a/lua/custom/plugins/completion.lua b/lua/custom/plugins/completion.lua new file mode 100644 index 0000000..8810280 --- /dev/null +++ b/lua/custom/plugins/completion.lua @@ -0,0 +1,15 @@ +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "onsails/lspkind.nvim", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + { "L3MON4D3/LuaSnip", build = "make install_jsregexp" }, + "saadparwaiz1/cmp_luasnip", + }, + config = function() + require "custom.completion" + end, +} diff --git a/lua/custom/plugins/fugitive.lua b/lua/custom/plugins/fugitive.lua new file mode 100644 index 0000000..a5244a8 --- /dev/null +++ b/lua/custom/plugins/fugitive.lua @@ -0,0 +1,13 @@ +return { + "tpope/vim-fugitive", + event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" }, + keys = { + { "gd", "Gvdiffsplit!" }, + { "gl", "Git blame -w -C -C -C" }, + { "gS", "Git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD),"}, + { "gbs", "Git bisect start" }, + { "gbg", "Git bisect good" }, + { "gbb", "Git bisect bad" }, + { "gbr", "Git bisect reset" }, + }, +} diff --git a/lua/custom/plugins/gitsigns.lua b/lua/custom/plugins/gitsigns.lua new file mode 100644 index 0000000..77f6d2f --- /dev/null +++ b/lua/custom/plugins/gitsigns.lua @@ -0,0 +1,28 @@ +return { + "lewis6991/gitsigns.nvim", + event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" }, + opts = { + signs = { + add = { text = "▎" }, + change = { text = "▎" }, + delete = { text = "" }, + topdelete = { text = "" }, + changedelete = { text = "▎" }, + untracked = { text = "▎" }, + }, + }, + keys = { + { "[h", "Gitsigns next_hunk", desc = "Next Hunk" }, + { "]h", "Gitsigns prev_hunk", desc = "Prev Hunk" }, + { "ghr", "Gitsigns reset_hunk", desc = "Reset Hunk" }, + { "ghR", "Gitsigns reset_buffer", desc = "Reset Buffer" }, + { "ghp", "Gitsigns preview_hunk", desc = "Preview Hunk" }, + { + "ghb", + function() + package.loaded.gitsigns.blame_line({ full = true }) + end, + desc = "Blame Line" + }, + }, +} diff --git a/lua/custom/plugins/indent-blankline.lua b/lua/custom/plugins/indent-blankline.lua new file mode 100644 index 0000000..6561c25 --- /dev/null +++ b/lua/custom/plugins/indent-blankline.lua @@ -0,0 +1,18 @@ +return { + "lukas-reineke/indent-blankline.nvim", + main = "ibl", + opts = { + debounce = 100, + indent = { + char = "▏", + tab_char = "▏", + highlight = { "VertSplit" }, + }, + scope = { + enabled = true, + show_start = false, + show_end = false, + highlight = "LineNr", + }, + }, +} diff --git a/lua/custom/plugins/lazygit.lua b/lua/custom/plugins/lazygit.lua new file mode 100644 index 0000000..5c77df0 --- /dev/null +++ b/lua/custom/plugins/lazygit.lua @@ -0,0 +1,20 @@ +return { + "kdheepak/lazygit.nvim", + lazy = true, + cmd = { + "LazyGit", + "LazyGitConfig", + "LazyGitCurrentFile", + "LazyGitFilter", + "LazyGitFilterCurrentFile", + }, + -- optional for floating window border decoration + dependencies = { + "nvim-lua/plenary.nvim", + }, + -- setting the keybinding for LazyGit with 'keys' is recommended in + -- order to load the plugin when the command is run for the first time + keys = { + { "lg", "LazyGit", desc = "LazyGit" } + } +} diff --git a/lua/custom/plugins/lsp-zero.lua b/lua/custom/plugins/lsp-zero.lua new file mode 100644 index 0000000..adfc4e2 --- /dev/null +++ b/lua/custom/plugins/lsp-zero.lua @@ -0,0 +1,18 @@ +return { + "VonHeikemen/lsp-zero.nvim", + config = function() + require("custom.lsp.config") + end, + dependencies = { + { "neovim/nvim-lspconfig" }, + { "williamboman/mason-lspconfig.nvim" }, + { "folke/neodev.nvim" }, + { "hrsh7th/nvim-cmp" }, + { "hrsh7th/cmp-buffer" }, + { "hrsh7th/cmp-path" }, + { "saadparwaiz1/cmp_luasnip" }, + { "hrsh7th/cmp-nvim-lsp" }, + { "hrsh7th/cmp-nvim-lua" }, + { "ray-x/lsp_signature.nvim" }, + } +} diff --git a/lua/custom/plugins/mason.lua b/lua/custom/plugins/mason.lua new file mode 100644 index 0000000..99aa4d3 --- /dev/null +++ b/lua/custom/plugins/mason.lua @@ -0,0 +1,10 @@ +return { + "williamboman/mason.nvim", + cmd = "Mason", + version = false, + build = ":MasonUpdate", + opts = {}, + keys = { + { "cm", "Mason", desc = "Open Mason" }, + }, +} diff --git a/lua/custom/plugins/mellow.lua b/lua/custom/plugins/mellow.lua new file mode 100644 index 0000000..34cfe71 --- /dev/null +++ b/lua/custom/plugins/mellow.lua @@ -0,0 +1 @@ +return { "mellow-theme/mellow.nvim" } diff --git a/lua/custom/plugins/oil.lua b/lua/custom/plugins/oil.lua new file mode 100644 index 0000000..ffacc46 --- /dev/null +++ b/lua/custom/plugins/oil.lua @@ -0,0 +1,32 @@ +return { + "stevearc/oil.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + CustomOilBar = function() + local path = vim.fn.expand "%" + path = path:gsub("oil://", "") + return " " .. vim.fn.fnamemodify(path, ":.") + end + + require("oil").setup { + columns = { "icon" }, + keymaps = { + ["g?"] = "actions.show_help", + [""] = "actions.select", + [""] = false, + [""] = "actions.close", + [""] = "actions.refresh", + ["-"] = "actions.parent", + ["_"] = "actions.open_cwd", + ["`"] = "actions.cd", + ["~"] = "actions.tcd", + ["gs"] = "actions.change_sort", + ["gx"] = "actions.open_external", + ["g."] = "actions.toggle_hidden", + }, + win_options = { + statusline = "%{v:lua.CustomOilBar()}", + }, + } + end, +} diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua new file mode 100644 index 0000000..aab8abc --- /dev/null +++ b/lua/custom/plugins/telescope.lua @@ -0,0 +1,21 @@ +return { + "nvim-telescope/telescope.nvim", + cmd = "Telescope", + lazy = false, + version = false, + dependencies = { + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + { "nvim-lua/plenary.nvim" }, + }, + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case", + } + }, + config = function() + require("custom.telescope") + end, +} diff --git a/lua/plugins/treesitter.lua b/lua/custom/plugins/treesitter.lua similarity index 100% rename from lua/plugins/treesitter.lua rename to lua/custom/plugins/treesitter.lua diff --git a/lua/custom/plugins/trouble.lua b/lua/custom/plugins/trouble.lua new file mode 100644 index 0000000..387c950 --- /dev/null +++ b/lua/custom/plugins/trouble.lua @@ -0,0 +1,13 @@ +return { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = {}, + keys = { + { "xx", "Trouble diagnostics", desc = "Trouble Workspace Diagnostics" }, + { "xl", "Trouble loclist", desc = "Trouble Loclist" }, + { "xq", "Trouble quickfix", desc = "Trouble Quickfix" }, + { "xt", "Trouble lsp_references", desc = "Trouble LSP References" }, + { "xj", function() require("trouble").next({ skip_groups = true, jump = true }) end, desc = "Trouble Next" }, + { "xk", function() require("trouble").previous({ skip_groups = true, jump = true }) end, desc = "Trouble Previous" }, + }, +} diff --git a/lua/custom/telescope.lua b/lua/custom/telescope.lua new file mode 100644 index 0000000..176c974 --- /dev/null +++ b/lua/custom/telescope.lua @@ -0,0 +1,24 @@ +local actions = require("telescope.actions") + +require("telescope").setup { + defaults = { + mappings = { + i = { + [""] = actions.close + }, + }, + } +} + +local builtin = require "telescope.builtin" +local set = vim.keymap.set + +set("n", "", builtin.find_files) +set("n", "fb", builtin.current_buffer_fuzzy_find) +set("n", "fg", builtin.git_commits) +set("n", "fh", builtin.help_tags) +set("n", "p", function() builtin.live_grep { no_ignore = true } end) +set("n", "fa", function() + builtin.find_files({ follow = true, no_ignore = true, hidden = true, file_ignore_patterns = { '.git,node_modules' } }) +end) +set("n", "ff", function() builtin.find_files({ follow = true, no_ignore = true, hidden = true }) end) diff --git a/lua/plugins/coding.lua b/lua/plugins/coding.lua deleted file mode 100644 index 98f2ac2..0000000 --- a/lua/plugins/coding.lua +++ /dev/null @@ -1,97 +0,0 @@ -return { - { - "L3MON4D3/LuaSnip", - version = "2.*", - build = "make install_jsregexp", - dependencies = { - 'nvim-treesitter/nvim-treesitter', - }, - init = function() - local ls = require('luasnip') - ls.setup({ - enable_autosnippets = true, - }) - end - }, - -- Autocomplete - { - "hrsh7th/nvim-cmp", - version = false, - event = "InsertEnter", - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "L3MON4D3/LuaSnip", - }, - opts = function() - local cmp = require("cmp") - local defaults = require("cmp.config.default")() - local cmp_format = require("lsp-zero").cmp_format() - return { - completion = { - completeopt = "menu,menuone,noinsert", - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [""] = function(fallback) - cmp.abort() - fallback() - end, - }), - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "path" }, - { name = "luasnip" }, - }, { - { name = "buffer" }, - }), - sorting = defaults.sorting, - formatting = cmp_format, - } - end, - config = function(_, opts) - require("cmp").setup(opts) - end, - }, - { - "ray-x/lsp_signature.nvim", - event = "VeryLazy", - opts = {}, - config = function(_, opts) require 'lsp_signature'.setup(opts) end, - }, - -- Supermaven (copilot) - -- { - -- "supermaven-inc/supermaven-nvim", - -- config = function() - -- require("supermaven-nvim").setup({}) - -- end, - -- }, - -- GitHub Copilot - -- { "github/copilot.vim" }, - -- Comment - { - "numToStr/Comment.nvim", - opts = { - -- add any options here - }, - lazy = false, - config = function() - require("Comment").setup() - end - }, - -- Surround - { "tpope/vim-surround", event = "BufRead", }, - -- Unimpaired - { "tpope/vim-unimpaired", event = "BufRead", }, -} diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua deleted file mode 100644 index 684d549..0000000 --- a/lua/plugins/editor.lua +++ /dev/null @@ -1,52 +0,0 @@ -return { - { - "folke/trouble.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - opts = {}, - keys = { - { "xx", "Trouble diagnostics", desc = "Trouble Workspace Diagnostics" }, - { "xl", "Trouble loclist", desc = "Trouble Loclist" }, - { "xq", "Trouble quickfix", desc = "Trouble Quickfix" }, - { "xt", "Trouble lsp_references", desc = "Trouble LSP References" }, - { "xj", function() require("trouble").next({ skip_groups = true, jump = true }) end, desc = "Trouble Next" }, - { "xk", function() require("trouble").previous({ skip_groups = true, jump = true }) end, desc = "Trouble Previous" }, - }, - }, - { "wsdjeg/vim-fetch", event = "VeryLazy" }, - { "nvim-tree/nvim-web-devicons" }, - { - "eandrju/cellular-automaton.nvim", - event = "VeryLazy", - keys = { - { "mr", "CellularAutomaton make_it_rain", desc = "Make it rain" }, - }, - }, - { - "lukas-reineke/indent-blankline.nvim", - main = "ibl", - opts = {}, - config = function() - require("ibl").setup { - debounce = 100, - indent = { - char = "▏", - tab_char = "▏", - highlight = { "VertSplit" }, - }, - scope = { - enabled = true, - show_start = false, - show_end = false, - highlight = "LineNr", - }, - } - end, - }, - { "mellow-theme/mellow.nvim" }, - { - 'norcalli/nvim-colorizer.lua', - config = function() - require('colorizer').setup() - end - }, -} diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua deleted file mode 100644 index 09ce95a..0000000 --- a/lua/plugins/git.lua +++ /dev/null @@ -1,50 +0,0 @@ -return { - -- Fugitive - { - "tpope/vim-fugitive", - event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" }, - config = function() - local function map(mode, l, r, desc) - vim.keymap.set(mode, l, r, { silent = true, noremap = true, desc = desc }) - end - - map("n", "gd", "Gvdiffsplit!", "Git Diff") - map("n", "gl", "Git blame -w -C -C -C", "Git Blame") - map("n", "gS", "Git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)", - "Git Push Set Upstream") - map("n", "gbs", "Git bisect start", "Git Bisect Start") - map("n", "gbg", "Git bisect good", "Git Bisect Good") - map("n", "gbb", "Git bisect bad", "Git Bisect Bad") - map("n", "gbr", "Git bisect reset", "Git Bisect Reset") - end - }, - -- Gitsigns - { - "lewis6991/gitsigns.nvim", - event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" }, - opts = { - signs = { - add = { text = "▎" }, - change = { text = "▎" }, - delete = { text = "" }, - topdelete = { text = "" }, - changedelete = { text = "▎" }, - untracked = { text = "▎" }, - }, - on_attach = function(buffer) - local gs = package.loaded.gitsigns - - local function map(mode, l, r, desc) - vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) - end - - map("n", "[h", gs.next_hunk, "Next Hunk") - map("n", "]h", gs.prev_hunk, "Prev Hunk") - map({ "n", "v" }, "ghr", "Gitsigns reset_hunk", "Reset Hunk") - map("n", "ghR", gs.reset_buffer, "Reset Buffer") - map("n", "ghp", gs.preview_hunk, "Preview Hunk") - map("n", "ghb", function() gs.blame_line({ full = true }) end, "Blame Line") - end, - }, - }, -} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua deleted file mode 100644 index 5aded5c..0000000 --- a/lua/plugins/lsp.lua +++ /dev/null @@ -1,30 +0,0 @@ -return { - -- LSP - { - "VonHeikemen/lsp-zero.nvim", - config = function() - require("plugins.lsp.config") - end, - dependencies = { - { "neovim/nvim-lspconfig" }, - { "williamboman/mason-lspconfig.nvim" }, - { "folke/neodev.nvim" }, - { "hrsh7th/nvim-cmp" }, - { "hrsh7th/cmp-buffer" }, - { "hrsh7th/cmp-path" }, - { "saadparwaiz1/cmp_luasnip" }, - { "hrsh7th/cmp-nvim-lsp" }, - { "hrsh7th/cmp-nvim-lua" }, - } - }, - -- Mason - { - "williamboman/mason.nvim", - cmd = "Mason", - keys = { { "cm", "Mason", desc = "Mason" } }, - build = ":MasonUpdate", - config = function(_, opts) - require("mason").setup(opts) - end - } -} diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua deleted file mode 100644 index c864e54..0000000 --- a/lua/plugins/oil.lua +++ /dev/null @@ -1,40 +0,0 @@ -return { - { - "stevearc/oil.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - config = function() - CustomOilBar = function() - local path = vim.fn.expand "%" - path = path:gsub("oil://", "") - return " " .. vim.fn.fnamemodify(path, ":.") - end - - require("oil").setup { - columns = { "icon" }, - keymaps = { - ["g?"] = "actions.show_help", - [""] = "actions.select", - [""] = false, - [""] = "actions.close", - [""] = "actions.refresh", - ["-"] = "actions.parent", - ["_"] = "actions.open_cwd", - ["`"] = "actions.cd", - ["~"] = "actions.tcd", - ["gs"] = "actions.change_sort", - ["gx"] = "actions.open_external", - ["g."] = "actions.toggle_hidden", - }, - win_options = { - statusline = "%{v:lua.CustomOilBar()}", - }, - } - - -- Open parent directory in current window - vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) - - -- Open parent directory in floating window - vim.keymap.set("n", "-", require("oil").toggle_float) - end, - }, -} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua deleted file mode 100644 index e1d773f..0000000 --- a/lua/plugins/telescope.lua +++ /dev/null @@ -1,51 +0,0 @@ -return { - "nvim-telescope/telescope.nvim", - cmd = "Telescope", - version = false, - dependencies = { - { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, - { "nvim-lua/plenary.nvim" }, - }, - extensions = { - fzf = { - fuzzy = true, -- false will only do exact matching - override_generic_sorter = true, -- override the generic sorter - override_file_sorter = true, -- override the file sorter - case_mode = "smart_case", -- or "ignore_case" or "respect_case" - } - }, - config = function() - local actions = require("telescope.actions") - require("telescope").setup { - defaults = { - mappings = { - i = { - [""] = actions.close - }, - }, - } - } - end, - keys = { - { "", "Telescope find_files", desc = "Find files" }, - { - "p", - function() require("telescope.builtin").live_grep({ no_ignore = true }) end, - desc = "Live Grep" - }, - -- Search almost everything (except .git folder) - { - "fa", - function() require("telescope.builtin").find_files({ follow = true, no_ignore = true, hidden = true, file_ignore_patterns = { '.git' } }) end, - desc = "Find all files" - }, - -- Search everything - { - "fl", - function() require("telescope.builtin").find_files({ follow = true, no_ignore = true, hidden = true }) end, - desc = "Find all files" - }, - { "fb", "Telescope buffers", desc = "Find buffer" }, - { "fc", "Telescope git_commits", desc = "Find commits" }, - }, -}