From 94b29a3de26c65e06bf956229a3ceaa45ba7a14f Mon Sep 17 00:00:00 2001 From: frank Date: Thu, 30 Jan 2025 19:09:26 -0500 Subject: [PATCH] first commit of nvim config --- .stylua.toml | 6 + init.lua | 36 ++++ lazy-lock.json | 45 +++++ lua/core/keymaps.lua | 75 ++++++++ lua/core/options.lua | 43 +++++ lua/core/snippets.lua | 36 ++++ lua/plugins/alpha.lua | 24 +++ lua/plugins/autocompletion.lua | 175 +++++++++++++++++ lua/plugins/bufferline.lua | 60 ++++++ lua/plugins/codecompanion.lua | 51 +++++ lua/plugins/colortheme.lua | 28 +++ lua/plugins/comment.lua | 14 ++ lua/plugins/gitsigns.lua | 20 ++ lua/plugins/indent-blankline.lua | 25 +++ lua/plugins/lsp.lua | 247 ++++++++++++++++++++++++ lua/plugins/lualine.lua | 72 +++++++ lua/plugins/misc.lua | 44 +++++ lua/plugins/neotree.lua | 315 +++++++++++++++++++++++++++++++ lua/plugins/none-ls.lua | 54 ++++++ lua/plugins/telescope.lua | 113 +++++++++++ lua/plugins/treesitter.lua | 52 +++++ 21 files changed, 1535 insertions(+) create mode 100644 .stylua.toml create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/core/keymaps.lua create mode 100644 lua/core/options.lua create mode 100644 lua/core/snippets.lua create mode 100644 lua/plugins/alpha.lua create mode 100644 lua/plugins/autocompletion.lua create mode 100644 lua/plugins/bufferline.lua create mode 100644 lua/plugins/codecompanion.lua create mode 100644 lua/plugins/colortheme.lua create mode 100644 lua/plugins/comment.lua create mode 100644 lua/plugins/gitsigns.lua create mode 100644 lua/plugins/indent-blankline.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/lualine.lua create mode 100644 lua/plugins/misc.lua create mode 100644 lua/plugins/neotree.lua create mode 100644 lua/plugins/none-ls.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/treesitter.lua diff --git a/.stylua.toml b/.stylua.toml new file mode 100644 index 0000000..139e939 --- /dev/null +++ b/.stylua.toml @@ -0,0 +1,6 @@ +column_width = 160 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferSingle" +call_parentheses = "None" diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..02b82cb --- /dev/null +++ b/init.lua @@ -0,0 +1,36 @@ +require 'core.options' -- Load general options +require 'core.keymaps' -- Load general keymaps +require 'core.snippets' -- Custom code snippets + +-- Set up the Lazy plugin manager +local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = 'https://github.com/folke/lazy.nvim.git' + local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } + if vim.v.shell_error ~= 0 then + error('Error cloning lazy.nvim:\n' .. out) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Set up plugins +require('lazy').setup { + require 'plugins.neotree', + require 'plugins.colortheme', + require 'plugins.bufferline', + require 'plugins.lualine', + require 'plugins.treesitter', + require 'plugins.telescope', + require 'plugins.lsp', + require 'plugins.autocompletion', + require 'plugins.none-ls', + require 'plugins.gitsigns', + require 'plugins.alpha', + require 'plugins.indent-blankline', + require 'plugins.misc', + require 'plugins.codecompanion', + require 'plugins.comment', +} + +-- The line beneath this is called `modeline`. See `:help modeline` +-- vim: ts=2 sts=2 sw=2 et diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..80f3639 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,45 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "LuaSnip": { "branch": "master", "commit": "7ad2eaeaca56d6ed63acacbfc114b99f1f67b982" }, + "alpha-nvim": { "branch": "main", "commit": "b6f4129302db197a7249e67a90de3f2b676de13e" }, + "bufferline.nvim": { "branch": "main", "commit": "0b2fd861eee7595015b6561dade52fb060be10c4" }, + "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" }, + "codecompanion.nvim": { "branch": "main", "commit": "65bda3201fe1be1ff2c5e66da0ff3c86c5d3c055" }, + "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, + "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, + "gitsigns.nvim": { "branch": "main", "commit": "899e993850084ea33d001ec229d237bc020c19ae" }, + "image.nvim": { "branch": "master", "commit": "4007cddc4cfc1b5ddd49744a38362e7b0432b3a0" }, + "indent-blankline.nvim": { "branch": "master", "commit": "db926997af951da38e5004ec7b9fbdc480b48f5d" }, + "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, + "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "482350b050bd413931c2cdd4857443c3da7d57cb" }, + "mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "29f7c215332ba95e470811c380ddbce2cebe2af4" }, + "none-ls-extras.nvim": { "branch": "main", "commit": "dfdc998a8c7bb728abab156942bd43ed2345845a" }, + "none-ls.nvim": { "branch": "main", "commit": "203f5ebde4a1af48ba2eb146401b5be2e7866942" }, + "nord.nvim": { "branch": "master", "commit": "80c1e5321505aeb22b7a9f23eb82f1e193c12470" }, + "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, + "nvim-autopairs": { "branch": "master", "commit": "19606af7c039271d5aa96bceff101e7523af3136" }, + "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, + "nvim-lspconfig": { "branch": "master", "commit": "911167921d49cd5c1c9b2436031d0da3945e787f" }, + "nvim-treesitter": { "branch": "master", "commit": "bef7ec6f7a01ba0717da73082e33c224bdc2ddcc" }, + "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, + "nvim-window-picker": { "branch": "main", "commit": "41cfaa428577c53552200a404ae9b3a0b5719706" }, + "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "todo-comments.nvim": { "branch": "main", "commit": "319c01b99b7a8c9ac2066bf0efd4d6ec68fef444" }, + "vim-bbye": { "branch": "master", "commit": "25ef93ac5a87526111f43e5110675032dbcacf56" }, + "vim-fugitive": { "branch": "master", "commit": "0444df68cd1cdabc7453d6bd84099458327e5513" }, + "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, + "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, + "vim-tmux-navigator": { "branch": "master", "commit": "5b3c701686fb4e6629c100ed32e827edf8dad01e" }, + "which-key.nvim": { "branch": "main", "commit": "bfec3d6bc0a9b0b2cb11644642f78c2c3915eef0" } +} diff --git a/lua/core/keymaps.lua b/lua/core/keymaps.lua new file mode 100644 index 0000000..0882b2a --- /dev/null +++ b/lua/core/keymaps.lua @@ -0,0 +1,75 @@ +-- Set leader key +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' + +-- Disable the spacebar key's default behavior in Normal and Visual modes +vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) + +-- For conciseness +local opts = { noremap = true, silent = true } + +-- save file +vim.keymap.set('n', '', ' w ', opts) + +-- save file without auto-formatting +vim.keymap.set('n', 'sn', 'noautocmd w ', opts) + +-- quit file +vim.keymap.set('n', '', ' q ', opts) + +-- delete single character without copying into register +vim.keymap.set('n', 'x', '"_x', opts) + +-- Vertical scroll and center +vim.keymap.set('n', '', 'zz', opts) +vim.keymap.set('n', '', 'zz', opts) + +-- Find and center +vim.keymap.set('n', 'n', 'nzzzv', opts) +vim.keymap.set('n', 'N', 'Nzzzv', opts) + +-- Resize with arrows +vim.keymap.set('n', '', ':resize -2', opts) +vim.keymap.set('n', '', ':resize +2', opts) +vim.keymap.set('n', '', ':vertical resize -2', opts) +vim.keymap.set('n', '', ':vertical resize +2', opts) + +-- Buffers +vim.keymap.set('n', '', ':bnext', opts) +vim.keymap.set('n', '', ':bprevious', opts) +vim.keymap.set('n', 'x', ':bdelete!', opts) -- close buffer +vim.keymap.set('n', 'b', ' enew ', opts) -- new buffer + +-- Window management +vim.keymap.set('n', 'v', 'v', opts) -- split window vertically +vim.keymap.set('n', 'h', 's', opts) -- split window horizontally +vim.keymap.set('n', 'se', '=', opts) -- make split windows equal width & height +vim.keymap.set('n', 'xs', ':close', opts) -- close current split window + +-- Navigate between splits +vim.keymap.set('n', '', ':wincmd k', opts) +vim.keymap.set('n', '', ':wincmd j', opts) +vim.keymap.set('n', '', ':wincmd h', opts) +vim.keymap.set('n', '', ':wincmd l', opts) + +-- Tabs +vim.keymap.set('n', 'to', ':tabnew', opts) -- open new tab +vim.keymap.set('n', 'tx', ':tabclose', opts) -- close current tab +vim.keymap.set('n', 'tn', ':tabn', opts) -- go to next tab +vim.keymap.set('n', 'tp', ':tabp', opts) -- go to previous tab + +-- Toggle line wrapping +vim.keymap.set('n', 'lw', 'set wrap!', opts) + +-- Stay in indent mode +vim.keymap.set('v', '<', '', '>gv', opts) + +-- Keep last yanked when pasting +vim.keymap.set('v', 'p', '"_dP', opts) + +-- Diagnostic keymaps +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', 'd', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) diff --git a/lua/core/options.lua b/lua/core/options.lua new file mode 100644 index 0000000..de8f4e0 --- /dev/null +++ b/lua/core/options.lua @@ -0,0 +1,43 @@ +vim.wo.number = true -- Make line numbers default (default: false) +vim.o.relativenumber = true -- Set relative numbered lines (default: false) +vim.o.clipboard = 'unnamedplus' -- Sync clipboard between OS and Neovim. (default: '') +vim.o.wrap = false -- Display lines as one long line (default: true) +vim.o.linebreak = true -- Companion to wrap, don't split words (default: false) +vim.o.mouse = 'a' -- Enable mouse mode (default: '') +vim.o.autoindent = true -- Copy indent from current line when starting new one (default: true) +vim.o.ignorecase = true -- Case-insensitive searching UNLESS \C or capital in search (default: false) +vim.o.smartcase = true -- Smart case (default: false) +vim.o.shiftwidth = 4 -- The number of spaces inserted for each indentation (default: 8) +vim.o.tabstop = 4 -- Insert n spaces for a tab (default: 8) +vim.o.softtabstop = 4 -- Number of spaces that a tab counts for while performing editing operations (default: 0) +vim.o.expandtab = true -- Convert tabs to spaces (default: false) +vim.o.scrolloff = 4 -- Minimal number of screen lines to keep above and below the cursor (default: 0) +vim.o.sidescrolloff = 8 -- Minimal number of screen columns either side of cursor if wrap is `false` (default: 0) +vim.o.cursorline = false -- Highlight the current line (default: false) +vim.o.splitbelow = true -- Force all horizontal splits to go below current window (default: false) +vim.o.splitright = true -- Force all vertical splits to go to the right of current window (default: false) +vim.o.hlsearch = false -- Set highlight on search (default: true) +vim.o.showmode = false -- We don't need to see things like -- INSERT -- anymore (default: true) +vim.opt.termguicolors = true -- Set termguicolors to enable highlight groups (default: false) +vim.o.whichwrap = 'bs<>[]hl' -- Which "horizontal" keys are allowed to travel to prev/next line (default: 'b,s') +vim.o.numberwidth = 4 -- Set number column width to 2 {default 4} (default: 4) +vim.o.swapfile = false -- Creates a swapfile (default: true) +vim.o.smartindent = true -- Make indenting smarter again (default: false) +vim.o.showtabline = 2 -- Always show tabs (default: 1) +vim.o.backspace = 'indent,eol,start' -- Allow backspace on (default: 'indent,eol,start') +vim.o.pumheight = 10 -- Pop up menu height (default: 0) +vim.o.conceallevel = 0 -- So that `` is visible in markdown files (default: 1) +vim.wo.signcolumn = 'yes' -- Keep signcolumn on by default (default: 'auto') +vim.o.fileencoding = 'utf-8' -- The encoding written to a file (default: 'utf-8') +vim.o.cmdheight = 1 -- More space in the Neovim command line for displaying messages (default: 1) +vim.o.breakindent = true -- Enable break indent (default: false) +vim.o.updatetime = 250 -- Decrease update time (default: 4000) +vim.o.timeoutlen = 300 -- Time to wait for a mapped sequence to complete (in milliseconds) (default: 1000) +vim.o.backup = false -- Creates a backup file (default: false) +vim.o.writebackup = false -- If a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited (default: true) +vim.o.undofile = true -- Save undo history (default: false) +vim.o.completeopt = 'menuone,noselect' -- Set completeopt to have a better completion experience (default: 'menu,preview') +vim.opt.shortmess:append 'c' -- Don't give |ins-completion-menu| messages (default: does not include 'c') +vim.opt.iskeyword:append '-' -- Hyphenated words recognized by searches (default: does not include '-') +vim.opt.formatoptions:remove { 'c', 'r', 'o' } -- Don't insert the current comment leader automatically for auto-wrapping comments using 'textwidth', hitting in insert mode, or hitting 'o' or 'O' in normal mode. (default: 'croql') +vim.opt.runtimepath:remove '/usr/share/vim/vimfiles' -- Separate Vim plugins from Neovim in case Vim still in use (default: includes this path if Vim is installed) diff --git a/lua/core/snippets.lua b/lua/core/snippets.lua new file mode 100644 index 0000000..5aab05a --- /dev/null +++ b/lua/core/snippets.lua @@ -0,0 +1,36 @@ +-- Custom code snippets for different purposes + +-- Prevent LSP from overwriting treesitter color settings +-- https://github.com/NvChad/NvChad/issues/1907 +vim.highlight.priorities.semantic_tokens = 95 -- Or any number lower than 100, treesitter's priority level + +-- Appearance of diagnostics +vim.diagnostic.config { + virtual_text = { + prefix = '●', + -- Add a custom format function to show error codes + format = function(diagnostic) + local code = diagnostic.code and string.format('[%s]', diagnostic.code) or '' + return string.format('%s %s', code, diagnostic.message) + end, + }, + underline = false, + update_in_insert = true, + float = { + source = 'always', -- Or "if_many" + }, + -- Make diagnostic background transparent + on_ready = function() + vim.cmd 'highlight DiagnosticVirtualText guibg=NONE' + end, +} + +-- Highlight on yank +local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) +vim.api.nvim_create_autocmd('TextYankPost', { + callback = function() + vim.highlight.on_yank() + end, + group = highlight_group, + pattern = '*', +}) diff --git a/lua/plugins/alpha.lua b/lua/plugins/alpha.lua new file mode 100644 index 0000000..e510a98 --- /dev/null +++ b/lua/plugins/alpha.lua @@ -0,0 +1,24 @@ +return { + 'goolord/alpha-nvim', + dependencies = { + 'nvim-tree/nvim-web-devicons', + }, + + config = function() + local alpha = require 'alpha' + local dashboard = require 'alpha.themes.startify' + + dashboard.section.header.val = { + [[ ]], + [[ ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ]], + [[ ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ]], + [[ ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ]], + [[ ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ]], + [[ ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ]], + [[ ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ]], + [[ ]], + } + + alpha.setup(dashboard.opts) + end, +} diff --git a/lua/plugins/autocompletion.lua b/lua/plugins/autocompletion.lua new file mode 100644 index 0000000..af63e81 --- /dev/null +++ b/lua/plugins/autocompletion.lua @@ -0,0 +1,175 @@ +return { -- Autocompletion + 'hrsh7th/nvim-cmp', + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + { + 'L3MON4D3/LuaSnip', + build = (function() + -- Build Step is needed for regex support in snippets. + -- This step is not supported in many windows environments. + -- Remove the below condition to re-enable on windows. + if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then + return + end + return 'make install_jsregexp' + end)(), + dependencies = { + -- `friendly-snippets` contains a variety of premade snippets. + -- See the README about individual language/framework/plugin snippets: + -- https://github.com/rafamadriz/friendly-snippets + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, + }, + }, + 'saadparwaiz1/cmp_luasnip', + + -- Adds other completion capabilities. + -- nvim-cmp does not ship with all sources by default. They are split + -- into multiple repos for maintenance purposes. + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + }, + config = function() + -- See `:help cmp` + local cmp = require 'cmp' + local luasnip = require 'luasnip' + luasnip.config.setup {} + + local kind_icons = { + Text = '󰉿', + Method = 'm', + Function = '󰊕', + Constructor = '', + Field = '', + Variable = '󰆧', + Class = '󰌗', + Interface = '', + Module = '', + Property = '', + Unit = '', + Value = '󰎠', + Enum = '', + Keyword = '󰌋', + Snippet = '', + Color = '󰏘', + File = '󰈙', + Reference = '', + Folder = '󰉋', + EnumMember = '', + Constant = '󰇽', + Struct = '', + Event = '', + Operator = '󰆕', + TypeParameter = '󰊄', + } + cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { completeopt = 'menu,menuone,noinsert' }, + + -- For an understanding of why these mappings were + -- chosen, you will need to read `:help ins-completion` + -- + -- No, but seriously. Please read `:help ins-completion`, it is really good! + mapping = cmp.mapping.preset.insert { + -- Select the [n]ext item + [''] = cmp.mapping.select_next_item(), + -- Select the [p]revious item + [''] = cmp.mapping.select_prev_item(), + + -- Scroll the documentation window [b]ack / [f]orward + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + + -- Accept ([y]es) the completion. + -- This will auto-import if your LSP supports it. + -- This will expand snippets if the LSP sent a snippet. + [''] = cmp.mapping.confirm { select = true }, + + -- If you prefer more traditional completion keymaps, + -- you can uncomment the following lines + --[''] = cmp.mapping.confirm { select = true }, + --[''] = cmp.mapping.select_next_item(), + --[''] = cmp.mapping.select_prev_item(), + + -- Manually trigger a completion from nvim-cmp. + -- Generally you don't need this, because nvim-cmp will display + -- completions whenever it has completion options available. + [''] = cmp.mapping.complete {}, + + -- Think of as moving to the right of your snippet expansion. + -- So if you have a snippet that's like: + -- function $name($args) + -- $body + -- end + -- + -- will move you to the right of each of the expansion locations. + -- is similar, except moving you backwards. + [''] = cmp.mapping(function() + if luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function() + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + end + end, { 'i', 's' }), + + -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: + -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps + -- Select next/previous item with Tab / Shift + Tab + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { + name = 'lazydev', + -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it + group_index = 0, + }, + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'buffer' }, + { name = 'path' }, + }, + formatting = { + fields = { 'kind', 'abbr', 'menu' }, + format = function(entry, vim_item) + vim_item.kind = string.format('%s', kind_icons[vim_item.kind]) + vim_item.menu = ({ + nvim_lsp = '[LSP]', + luasnip = '[Snippet]', + buffer = '[Buffer]', + path = '[Path]', + })[entry.source.name] + return vim_item + end, + }, + } + end, +} diff --git a/lua/plugins/bufferline.lua b/lua/plugins/bufferline.lua new file mode 100644 index 0000000..b7ccb30 --- /dev/null +++ b/lua/plugins/bufferline.lua @@ -0,0 +1,60 @@ +return { + 'akinsho/bufferline.nvim', + dependencies = { + 'moll/vim-bbye', + 'nvim-tree/nvim-web-devicons', + }, + config = function() + require('bufferline').setup { + options = { + mode = 'buffers', -- set to "tabs" to only show tabpages instead + themable = true, -- allows highlight groups to be overriden i.e. sets highlights as default + numbers = 'none', -- | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string, + close_command = 'Bdelete! %d', -- can be a string | function, see "Mouse actions" + buffer_close_icon = '✗', + close_icon = '✗', + path_components = 1, -- Show only the file name without the directory + modified_icon = '●', + left_trunc_marker = '', + right_trunc_marker = '', + max_name_length = 30, + max_prefix_length = 30, -- prefix used when a buffer is de-duplicated + tab_size = 21, + diagnostics = false, + diagnostics_update_in_insert = false, + color_icons = true, + show_buffer_icons = true, + show_buffer_close_icons = true, + show_close_icon = true, + persist_buffer_sort = true, -- whether or not custom sorted buffers should persist + separator_style = { '│', '│' }, -- | "thick" | "thin" | { 'any', 'any' }, + enforce_regular_tabs = true, + always_show_bufferline = true, + show_tab_indicators = false, + indicator = { + -- icon = '▎', -- this should be omitted if indicator style is not 'icon' + style = 'none', -- Options: 'icon', 'underline', 'none' + }, + icon_pinned = '󰐃', + minimum_padding = 1, + maximum_padding = 5, + maximum_length = 15, + sort_by = 'insert_at_end', + }, + highlights = { + separator = { + fg = '#434C5E', + }, + buffer_selected = { + bold = true, + italic = false, + }, + -- separator_selected = {}, + -- tab_selected = {}, + -- background = {}, + -- indicator_selected = {}, + -- fill = {}, + }, + } + end, +} diff --git a/lua/plugins/codecompanion.lua b/lua/plugins/codecompanion.lua new file mode 100644 index 0000000..47f8e05 --- /dev/null +++ b/lua/plugins/codecompanion.lua @@ -0,0 +1,51 @@ +return { + 'olimorris/codecompanion.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-treesitter/nvim-treesitter', + }, + config = { + adapters = { + llama3 = function() + return require('codecompanion.adapters').extend('ollama', { + name = 'llama3', -- Give this adapter a different name to differentiate it from the default ollama adapter + schema = { + model = { + default = 'llama3.1', + }, + -- num_ctx = { + -- default = 16384, + -- }, + -- num_predict = { + -- default = -1, + -- }, + }, + }) + end, + deepseekr1 = function() + return require('codecompanion.adapters').extend('ollama', { + name = 'deepseekr1', -- Give this adapter a different name to differentiate it from the default ollama adapter + schema = { + model = { + default = 'deepseek-r1', + }, + -- num_ctx = { + -- default = 16384, + -- }, + -- num_predict = { + -- default = -1, + -- }, + }, + }) + end, + }, + strategies = { + chat = { + adapter = 'deepseekr1', + }, + inline = { + adapter = 'deepseekr1', + }, + }, + }, +} diff --git a/lua/plugins/colortheme.lua b/lua/plugins/colortheme.lua new file mode 100644 index 0000000..db1d834 --- /dev/null +++ b/lua/plugins/colortheme.lua @@ -0,0 +1,28 @@ +return { + 'shaunsingh/nord.nvim', + lazy = false, + priority = 1000, + config = function() + -- Example config in lua + vim.g.nord_contrast = true + vim.g.nord_borders = false + vim.g.nord_disable_background = true + vim.g.nord_italic = false + vim.g.nord_uniform_diff_background = true + vim.g.nord_bold = false + + -- Load the colorscheme + require('nord').set() + + -- Toggle background transparency + local bg_transparent = true + + local toggle_transparency = function() + bg_transparent = not bg_transparent + vim.g.nord_disable_background = bg_transparent + vim.cmd [[colorscheme nord]] + end + + vim.keymap.set('n', 'bg', toggle_transparency, { noremap = true, silent = true }) + end, +} diff --git a/lua/plugins/comment.lua b/lua/plugins/comment.lua new file mode 100644 index 0000000..7259942 --- /dev/null +++ b/lua/plugins/comment.lua @@ -0,0 +1,14 @@ +-- Easily comment visual regions/lines +return { + 'numToStr/Comment.nvim', + opts = {}, + config = function() + local opts = { noremap = true, silent = true } + vim.keymap.set('n', '', require('Comment.api').toggle.linewise.current, opts) + vim.keymap.set('n', '', require('Comment.api').toggle.linewise.current, opts) + vim.keymap.set('n', '', require('Comment.api').toggle.linewise.current, opts) + vim.keymap.set('v', '', "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) + vim.keymap.set('v', '', "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) + vim.keymap.set('v', '', "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) + end, +} diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..a56976b --- /dev/null +++ b/lua/plugins/gitsigns.lua @@ -0,0 +1,20 @@ +-- Adds git related signs to the gutter, as well as utilities for managing changes +return { + 'lewis6991/gitsigns.nvim', + opts = { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + signs_staged = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + }, +} diff --git a/lua/plugins/indent-blankline.lua b/lua/plugins/indent-blankline.lua new file mode 100644 index 0000000..27e4408 --- /dev/null +++ b/lua/plugins/indent-blankline.lua @@ -0,0 +1,25 @@ +return { + 'lukas-reineke/indent-blankline.nvim', + main = 'ibl', + opts = { + indent = { + char = '▏', + }, + scope = { + show_start = false, + show_end = false, + show_exact_scope = false, + }, + exclude = { + filetypes = { + 'help', + 'startify', + 'dashboard', + 'packer', + 'neogitstatus', + 'NvimTree', + 'Trouble', + }, + }, + }, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..247635a --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,247 @@ +return { + -- Main LSP Configuration + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs and related tools to stdpath for Neovim + { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants + 'williamboman/mason-lspconfig.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', + + -- Useful status updates for LSP. + -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` + { 'j-hui/fidget.nvim', opts = {} }, + + -- Allows extra capabilities provided by nvim-cmp + 'hrsh7th/cmp-nvim-lsp', + }, + config = function() + -- Brief aside: **What is LSP?** + -- + -- LSP is an initialism you've probably heard, but might not understand what it is. + -- + -- LSP stands for Language Server Protocol. It's a protocol that helps editors + -- and language tooling communicate in a standardized fashion. + -- + -- In general, you have a "server" which is some tool built to understand a particular + -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers + -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone + -- processes that communicate with some "client" - in this case, Neovim! + -- + -- LSP provides Neovim with features like: + -- - Go to definition + -- - Find references + -- - Autocompletion + -- - Symbol Search + -- - and more! + -- + -- Thus, Language Servers are external tools that must be installed separately from + -- Neovim. This is where `mason` and related plugins come into play. + -- + -- If you're wondering about lsp vs treesitter, you can check out the wonderfully + -- and elegantly composed help section, `:help lsp-vs-treesitter` + + -- This function gets run when an LSP attaches to a particular buffer. + -- That is to say, every time a new file is opened that is associated with + -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this + -- function will be executed to configure the current buffer + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), + callback = function(event) + -- NOTE: Remember that Lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local map = function(keys, func, desc, mode) + mode = mode or 'n' + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end + + -- Jump to the definition of the word under your cursor. + -- This is where a variable was first declared, or where a function is defined, etc. + -- To jump back, press . + map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + + -- Find references for the word under your cursor. + map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + + -- Jump to the implementation of the word under your cursor. + -- Useful when your language has ways of declaring types without an actual implementation. + map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + + -- Jump to the type of the word under your cursor. + -- Useful when you're not sure what type a variable is and you want to see + -- the definition of its *type*, not where it was *defined*. + map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') + + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + + -- Fuzzy find all the symbols in your current workspace. + -- Similar to document symbols, except searches over your entire project. + map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + -- Rename the variable under your cursor. + -- Most Language Servers support renaming across files, etc. + map('rn', vim.lsp.buf.rename, '[R]e[n]ame') + + -- Execute a code action, usually your cursor needs to be on top of an error + -- or a suggestion from your LSP for this to activate. + map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) + + -- WARN: This is not Goto Definition, this is Goto Declaration. + -- For example, in C this would take you to the header. + map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + + -- The following two autocommands are used to highlight references of the + -- word under your cursor when your cursor rests there for a little while. + -- See `:help CursorHold` for information about when this is executed + -- + -- When you move your cursor, the highlights will be cleared (the second autocommand). + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then + local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.document_highlight, + }) + + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.clear_references, + }) + + vim.api.nvim_create_autocmd('LspDetach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } + end, + }) + end + + -- The following code creates a keymap to toggle inlay hints in your + -- code, if the language server you are using supports them + -- + -- This may be unwanted, since they displace some of your code + if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then + map('th', function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) + end, '[T]oggle Inlay [H]ints') + end + end, + }) + + -- LSP servers and clients are able to communicate to each other what features they support. + -- By default, Neovim doesn't support everything that is in the LSP specification. + -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. + -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) + + -- Enable the following language servers + -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. + -- + -- Add any additional override configuration in the following tables. Available keys are: + -- - cmd (table): Override the default command used to start the server + -- - filetypes (table): Override the default list of associated filetypes for the server + -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. + -- - settings (table): Override the default settings passed when initializing the server. + -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + local servers = { + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- rust_analyzer = {}, + -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs + -- + -- Some languages (like typescript) have entire language plugins that can be useful: + -- https://github.com/pmizio/typescript-tools.nvim + -- + -- But for many setups, the LSP (`tsserver`) will work just fine + tsserver = {}, + ruff = {}, + pylsp = { + settings = { + pylsp = { + plugins = { + pyflakes = { enabled = false }, + pycodestyle = { enabled = false }, + autopep8 = { enabled = false }, + yapf = { enabled = false }, + mccabe = { enabled = false }, + pylsp_mypy = { enabled = false }, + pylsp_black = { enabled = false }, + pylsp_isort = { enabled = false }, + }, + }, + }, + }, + html = { filetypes = { 'html', 'twig', 'hbs' } }, + cssls = {}, + tailwindcss = {}, + dockerls = {}, + sqlls = {}, + terraformls = {}, + jsonls = {}, + yamlls = {}, + + lua_ls = { + -- cmd = {...}, + -- filetypes = { ...}, + -- capabilities = {}, + settings = { + Lua = { + completion = { + callSnippet = 'Replace', + }, + runtime = { version = 'LuaJIT' }, + workspace = { + checkThirdParty = false, + library = { + '${3rd}/luv/library', + unpack(vim.api.nvim_get_runtime_file('', true)), + }, + }, + diagnostics = { disable = { 'missing-fields' } }, + format = { + enable = false, + }, + }, + }, + }, + } + + -- Ensure the servers and tools above are installed + -- To check the current status of installed tools and/or manually install + -- other tools, you can run + -- :Mason + -- + -- You can press `g?` for help in this menu. + require('mason').setup() + + -- You can add other tools here that you want Mason to install + -- for you, so that they are available from within Neovim. + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + 'stylua', -- Used to format Lua code + }) + require('mason-tool-installer').setup { ensure_installed = ensure_installed } + + require('mason-lspconfig').setup { + handlers = { + function(server_name) + local server = servers[server_name] or {} + -- This handles overriding only values explicitly passed + -- by the server configuration above. Useful when disabling + -- certain features of an LSP (for example, turning off formatting for tsserver) + server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) + require('lspconfig')[server_name].setup(server) + end, + }, + } + end, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..429bc2a --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,72 @@ +return { + 'nvim-lualine/lualine.nvim', + config = function() + local mode = { + 'mode', + fmt = function(str) + return ' ' .. str + -- return ' ' .. str:sub(1, 1) -- displays only the first character of the mode + end, + } + + local filename = { + 'filename', + file_status = true, -- displays file status (readonly status, modified status) + path = 0, -- 0 = just filename, 1 = relative path, 2 = absolute path + } + + local hide_in_width = function() + return vim.fn.winwidth(0) > 100 + end + + local diagnostics = { + 'diagnostics', + sources = { 'nvim_diagnostic' }, + sections = { 'error', 'warn' }, + symbols = { error = ' ', warn = ' ', info = ' ', hint = ' ' }, + colored = false, + update_in_insert = false, + always_visible = false, + cond = hide_in_width, + } + + local diff = { + 'diff', + colored = false, + symbols = { added = ' ', modified = ' ', removed = ' ' }, -- changes diff symbols + cond = hide_in_width, + } + + require('lualine').setup { + options = { + icons_enabled = true, + theme = 'nord', -- Set theme based on environment variable + -- Some useful glyphs: + -- https://www.nerdfonts.com/cheat-sheet + --         + section_separators = { left = '', right = '' }, + component_separators = { left = '', right = '' }, + disabled_filetypes = { 'alpha', 'neo-tree' }, + always_divide_middle = true, + }, + sections = { + lualine_a = { mode }, + lualine_b = { 'branch' }, + lualine_c = { filename }, + lualine_x = { diagnostics, diff, { 'encoding', cond = hide_in_width }, { 'filetype', cond = hide_in_width } }, + lualine_y = { 'location' }, + lualine_z = { 'progress' }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { { 'filename', path = 1 } }, + lualine_x = { { 'location', padding = 0 } }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + extensions = { 'fugitive' }, + } + end, +} diff --git a/lua/plugins/misc.lua b/lua/plugins/misc.lua new file mode 100644 index 0000000..c9d4778 --- /dev/null +++ b/lua/plugins/misc.lua @@ -0,0 +1,44 @@ +-- Standalone plugins with less than 10 lines of config go here +return { + { + -- Tmux & split window navigation + 'christoomey/vim-tmux-navigator', + }, + { + -- Detect tabstop and shiftwidth automatically + 'tpope/vim-sleuth', + }, + { + -- Powerful Git integration for Vim + 'tpope/vim-fugitive', + }, + { + -- GitHub integration for vim-fugitive + 'tpope/vim-rhubarb', + }, + { + -- Hints keybinds + 'folke/which-key.nvim', + }, + { + -- Autoclose parentheses, brackets, quotes, etc. + 'windwp/nvim-autopairs', + event = 'InsertEnter', + config = true, + opts = {}, + }, + { + -- Highlight todo, notes, etc in comments + 'folke/todo-comments.nvim', + event = 'VimEnter', + dependencies = { 'nvim-lua/plenary.nvim' }, + opts = { signs = false }, + }, + { + -- High-performance color highlighter + 'norcalli/nvim-colorizer.lua', + config = function() + require('colorizer').setup() + end, + }, +} diff --git a/lua/plugins/neotree.lua b/lua/plugins/neotree.lua new file mode 100644 index 0000000..cbbdeba --- /dev/null +++ b/lua/plugins/neotree.lua @@ -0,0 +1,315 @@ +return { + 'nvim-neo-tree/neo-tree.nvim', + branch = 'v3.x', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', + 'MunifTanjim/nui.nvim', + '3rd/image.nvim', -- Optional image support in preview window: See `# Preview Mode` for more information + { + 's1n7ax/nvim-window-picker', + version = '2.*', + config = function() + require('window-picker').setup { + filter_rules = { + include_current_win = false, + autoselect_one = true, + -- filter using buffer options + bo = { + -- if the file type is one of following, the window will be ignored + filetype = { 'neo-tree', 'neo-tree-popup', 'notify' }, + -- if the buffer type is one of following, the window will be ignored + buftype = { 'terminal', 'quickfix' }, + }, + }, + } + end, + }, + }, + config = function() + -- If you want icons for diagnostic errors, you'll need to define them somewhere: + vim.fn.sign_define('DiagnosticSignError', { text = ' ', texthl = 'DiagnosticSignError' }) + vim.fn.sign_define('DiagnosticSignWarn', { text = ' ', texthl = 'DiagnosticSignWarn' }) + vim.fn.sign_define('DiagnosticSignInfo', { text = ' ', texthl = 'DiagnosticSignInfo' }) + vim.fn.sign_define('DiagnosticSignHint', { text = '󰌵', texthl = 'DiagnosticSignHint' }) + + require('neo-tree').setup { + close_if_last_window = false, -- Close Neo-tree if it is the last window left in the tab + popup_border_style = 'rounded', + enable_git_status = true, + enable_diagnostics = true, + -- enable_normal_mode_for_inputs = false, -- Enable normal mode for input dialogs. + open_files_do_not_replace_types = { 'terminal', 'trouble', 'qf' }, -- when opening files, do not use windows containing these filetypes or buftypes + sort_case_insensitive = false, -- used when sorting files and directories in the tree + sort_function = nil, -- use a custom function for sorting files and directories in the tree + -- sort_function = function (a,b) + -- if a.type == b.type then + -- return a.path > b.path + -- else + -- return a.type > b.type + -- end + -- end , -- this sorts files and directories descendantly + default_component_configs = { + container = { + enable_character_fade = true, + }, + indent = { + indent_size = 2, + padding = 1, -- extra padding on left hand side + -- indent guides + with_markers = true, + indent_marker = '│', + last_indent_marker = '└', + highlight = 'NeoTreeIndentMarker', + -- expander config, needed for nesting files + with_expanders = nil, -- if nil and file nesting is enabled, will enable expanders + expander_collapsed = '', + expander_expanded = '', + expander_highlight = 'NeoTreeExpander', + }, + icon = { + folder_closed = '', + folder_open = '', + folder_empty = '󰜌', + -- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there + -- then these will never be used. + default = '*', + highlight = 'NeoTreeFileIcon', + }, + modified = { + symbol = '[+]', + highlight = 'NeoTreeModified', + }, + name = { + trailing_slash = false, + use_git_status_colors = true, + highlight = 'NeoTreeFileName', + }, + git_status = { + symbols = { + -- Change type + added = '', -- or "✚", but this is redundant info if you use git_status_colors on the name + modified = '', -- or "", but this is redundant info if you use git_status_colors on the name + deleted = '✖', -- this can only be used in the git_status source + renamed = '󰁕', -- this can only be used in the git_status source + -- Status type + untracked = '', + ignored = '', + unstaged = '󰄱', + staged = '', + conflict = '', + }, + }, + -- If you don't want to use these columns, you can set `enabled = false` for each of them individually + file_size = { + enabled = true, + required_width = 64, -- min width of window required to show this column + }, + type = { + enabled = true, + required_width = 122, -- min width of window required to show this column + }, + last_modified = { + enabled = true, + required_width = 88, -- min width of window required to show this column + }, + created = { + enabled = true, + required_width = 110, -- min width of window required to show this column + }, + symlink_target = { + enabled = false, + }, + }, + -- A list of functions, each representing a global custom command + -- that will be available in all sources (if not overridden in `opts[source_name].commands`) + -- see `:h neo-tree-custom-commands-global` + commands = {}, + window = { + position = 'left', + width = 40, + mapping_options = { + noremap = true, + nowait = true, + }, + mappings = { + [''] = { + 'toggle_node', + nowait = false, -- disable `nowait` if you have existing combos starting with this char that you want to use + }, + ['<2-LeftMouse>'] = 'open', + [''] = 'open', + [''] = 'cancel', -- close preview or floating neo-tree window + ['P'] = { 'toggle_preview', config = { use_float = true } }, + ['l'] = 'open', + ['S'] = 'open_split', + ['s'] = 'open_vsplit', + -- ["S"] = "split_with_window_picker", + -- ["s"] = "vsplit_with_window_picker", + ['t'] = 'open_tabnew', + -- [""] = "open_drop", + -- ["t"] = "open_tab_drop", + ['w'] = 'open_with_window_picker', + --["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing + ['C'] = 'close_node', + -- ['C'] = 'close_all_subnodes', + ['z'] = 'close_all_nodes', + --["Z"] = "expand_all_nodes", + ['a'] = { + 'add', + -- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details + -- some commands may take optional config options, see `:h neo-tree-mappings` for details + config = { + show_path = 'none', -- "none", "relative", "absolute" + }, + }, + ['A'] = 'add_directory', -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion. + ['d'] = 'delete', + ['r'] = 'rename', + ['y'] = 'copy_to_clipboard', + ['x'] = 'cut_to_clipboard', + ['p'] = 'paste_from_clipboard', + ['c'] = 'copy', -- takes text input for destination, also accepts the optional config.show_path option like "add": + -- ["c"] = { + -- "copy", + -- config = { + -- show_path = "none" -- "none", "relative", "absolute" + -- } + --} + ['m'] = 'move', -- takes text input for destination, also accepts the optional config.show_path option like "add". + ['q'] = 'close_window', + ['R'] = 'refresh', + ['?'] = 'show_help', + ['<'] = 'prev_source', + ['>'] = 'next_source', + ['i'] = 'show_file_details', + }, + }, + nesting_rules = {}, + filesystem = { + filtered_items = { + visible = false, -- when true, they will just be displayed differently than normal items + hide_dotfiles = false, + hide_gitignored = false, + hide_hidden = false, -- only works on Windows for hidden files/directories + hide_by_name = { + '.DS_Store', + 'thumbs.db', + 'node_modules', + '__pycache__', + '.virtual_documents', + '.git', + '.python-version', + '.venv', + }, + hide_by_pattern = { -- uses glob style patterns + --"*.meta", + --"*/src/*/tsconfig.json", + }, + always_show = { -- remains visible even if other settings would normally hide it + --".gitignored", + }, + never_show = { -- remains hidden even if visible is toggled to true, this overrides always_show + --".DS_Store", + --"thumbs.db" + }, + never_show_by_pattern = { -- uses glob style patterns + --".null-ls_*", + }, + }, + follow_current_file = { + enabled = false, -- This will find and focus the file in the active buffer every time + -- -- the current file is changed while the tree is open. + leave_dirs_open = false, -- `false` closes auto expanded dirs, such as with `:Neotree reveal` + }, + group_empty_dirs = false, -- when true, empty folders will be grouped together + hijack_netrw_behavior = 'open_default', -- netrw disabled, opening a directory opens neo-tree + -- in whatever position is specified in window.position + -- "open_current", -- netrw disabled, opening a directory opens within the + -- window like netrw would, regardless of window.position + -- "disabled", -- netrw left alone, neo-tree does not handle opening dirs + use_libuv_file_watcher = false, -- This will use the OS level file watchers to detect changes + -- instead of relying on nvim autocmd events. + window = { + mappings = { + [''] = 'navigate_up', + ['.'] = 'set_root', + ['H'] = 'toggle_hidden', + ['/'] = 'fuzzy_finder', + ['D'] = 'fuzzy_finder_directory', + ['#'] = 'fuzzy_sorter', -- fuzzy sorting using the fzy algorithm + -- ["D"] = "fuzzy_sorter_directory", + ['f'] = 'filter_on_submit', + [''] = 'clear_filter', + ['[g'] = 'prev_git_modified', + [']g'] = 'next_git_modified', + ['o'] = { 'show_help', nowait = false, config = { title = 'Order by', prefix_key = 'o' } }, + ['oc'] = { 'order_by_created', nowait = false }, + ['od'] = { 'order_by_diagnostics', nowait = false }, + ['og'] = { 'order_by_git_status', nowait = false }, + ['om'] = { 'order_by_modified', nowait = false }, + ['on'] = { 'order_by_name', nowait = false }, + ['os'] = { 'order_by_size', nowait = false }, + ['ot'] = { 'order_by_type', nowait = false }, + }, + fuzzy_finder_mappings = { -- define keymaps for filter popup window in fuzzy_finder_mode + [''] = 'move_cursor_down', + [''] = 'move_cursor_down', + [''] = 'move_cursor_up', + [''] = 'move_cursor_up', + }, + }, + + commands = {}, -- Add a custom command or override a global one using the same function name + }, + buffers = { + follow_current_file = { + enabled = true, -- This will find and focus the file in the active buffer every time + -- -- the current file is changed while the tree is open. + leave_dirs_open = false, -- `false` closes auto expanded dirs, such as with `:Neotree reveal` + }, + group_empty_dirs = true, -- when true, empty folders will be grouped together + show_unloaded = true, + window = { + mappings = { + ['bd'] = 'buffer_delete', + [''] = 'navigate_up', + ['.'] = 'set_root', + ['o'] = { 'show_help', nowait = false, config = { title = 'Order by', prefix_key = 'o' } }, + ['oc'] = { 'order_by_created', nowait = false }, + ['od'] = { 'order_by_diagnostics', nowait = false }, + ['om'] = { 'order_by_modified', nowait = false }, + ['on'] = { 'order_by_name', nowait = false }, + ['os'] = { 'order_by_size', nowait = false }, + ['ot'] = { 'order_by_type', nowait = false }, + }, + }, + }, + git_status = { + window = { + position = 'float', + mappings = { + ['A'] = 'git_add_all', + ['gu'] = 'git_unstage_file', + ['ga'] = 'git_add_file', + ['gr'] = 'git_revert_file', + ['gc'] = 'git_commit', + ['gp'] = 'git_push', + ['gg'] = 'git_commit_and_push', + ['o'] = { 'show_help', nowait = false, config = { title = 'Order by', prefix_key = 'o' } }, + ['oc'] = { 'order_by_created', nowait = false }, + ['od'] = { 'order_by_diagnostics', nowait = false }, + ['om'] = { 'order_by_modified', nowait = false }, + ['on'] = { 'order_by_name', nowait = false }, + ['os'] = { 'order_by_size', nowait = false }, + ['ot'] = { 'order_by_type', nowait = false }, + }, + }, + }, + } + + vim.cmd [[nnoremap \ :Neotree reveal]] + vim.keymap.set('n', 'e', ':Neotree toggle position=left', { noremap = true, silent = true }) -- focus file explorer + vim.keymap.set('n', 'ngs', ':Neotree float git_status', { noremap = true, silent = true }) -- open git status window + end, +} diff --git a/lua/plugins/none-ls.lua b/lua/plugins/none-ls.lua new file mode 100644 index 0000000..e567583 --- /dev/null +++ b/lua/plugins/none-ls.lua @@ -0,0 +1,54 @@ +return { + 'nvimtools/none-ls.nvim', + dependencies = { + 'nvimtools/none-ls-extras.nvim', + 'jayp0521/mason-null-ls.nvim', -- ensure dependencies are installed + }, + config = function() + local null_ls = require 'null-ls' + local formatting = null_ls.builtins.formatting -- to setup formatters + local diagnostics = null_ls.builtins.diagnostics -- to setup linters + + -- Formatters & linters for mason to install + require('mason-null-ls').setup { + ensure_installed = { + 'prettier', -- ts/js formatter + 'stylua', -- lua formatter + 'eslint_d', -- ts/js linter + 'shfmt', -- Shell formatter + 'checkmake', -- linter for Makefiles + 'ruff', -- Python linter and formatter + }, + automatic_installation = true, + } + + local sources = { + diagnostics.checkmake, + formatting.prettier.with { filetypes = { 'html', 'json', 'yaml', 'markdown' } }, + formatting.stylua, + formatting.shfmt.with { args = { '-i', '4' } }, + formatting.terraform_fmt, + require('none-ls.formatting.ruff').with { extra_args = { '--extend-select', 'I' } }, + require 'none-ls.formatting.ruff_format', + } + + local augroup = vim.api.nvim_create_augroup('LspFormatting', {}) + null_ls.setup { + -- debug = true, -- Enable debug mode. Inspect logs with :NullLsLog. + sources = sources, + -- you can reuse a shared lspconfig on_attach callback here + on_attach = function(client, bufnr) + if client.supports_method 'textDocument/formatting' then + vim.api.nvim_clear_autocmds { group = augroup, buffer = bufnr } + vim.api.nvim_create_autocmd('BufWritePre', { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format { async = false } + end, + }) + end + end, + } + end, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..ec39068 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,113 @@ +return { + 'nvim-telescope/telescope.nvim', + event = 'VimEnter', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + { -- If encountering errors, see telescope-fzf-native README for installation instructions + 'nvim-telescope/telescope-fzf-native.nvim', + + -- `build` is used to run some command when the plugin is installed/updated. + -- This is only run then, not every time Neovim starts up. + build = 'make', + + -- `cond` is a condition used to determine whether this plugin should be + -- installed and loaded. + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + { 'nvim-telescope/telescope-ui-select.nvim' }, + + -- Useful for getting pretty icons, but requires a Nerd Font. + { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + }, + config = function() + -- Telescope is a fuzzy finder that comes with a lot of different things that + -- it can fuzzy find! It's more than just a "file finder", it can search + -- many different aspects of Neovim, your workspace, LSP, and more! + -- + -- The easiest way to use Telescope, is to start by doing something like: + -- :Telescope help_tags + -- + -- After running this command, a window will open up and you're able to + -- type in the prompt window. You'll see a list of `help_tags` options and + -- a corresponding preview of the help. + -- + -- Two important keymaps to use while in Telescope are: + -- - Insert mode: + -- - Normal mode: ? + -- + -- This opens a window that shows you all of the keymaps for the current + -- Telescope picker. This is really useful to discover what Telescope can + -- do as well as how to actually do it! + + -- [[ Configure Telescope ]] + -- See `:help telescope` and `:help telescope.setup()` + require('telescope').setup { + -- You can put your default mappings / updates / etc. in here + -- All the info you're looking for is in `:help telescope.setup()` + defaults = { + mappings = { + i = { + [''] = require('telescope.actions').move_selection_previous, -- move to prev result + [''] = require('telescope.actions').move_selection_next, -- move to next result + [''] = require('telescope.actions').select_default, -- open file + }, + }, + }, + pickers = { + find_files = { + file_ignore_patterns = { 'node_modules', '.git', '.venv' }, + hidden = true, + }, + }, + live_grep = { + file_ignore_patterns = { 'node_modules', '.git', '.venv' }, + additional_args = function(_) + return { '--hidden' } + end, + }, + extensions = { + ['ui-select'] = { + require('telescope.themes').get_dropdown(), + }, + }, + } + + -- Enable Telescope extensions if they are installed + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') + + -- See `:help telescope.builtin` + local builtin = require 'telescope.builtin' + vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + + -- Slightly advanced example of overriding default behavior and theme + vim.keymap.set('n', '/', function() + -- You can pass additional configuration to Telescope to change the theme, layout, etc. + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + + -- It's also possible to pass additional configuration options. + -- See `:help telescope.builtin.live_grep()` for information about particular keys + vim.keymap.set('n', 's/', function() + builtin.live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } + end, { desc = '[S]earch [/] in Open Files' }) + end, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..38d1d36 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,52 @@ +return { -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + main = 'nvim-treesitter.configs', -- Sets main module to use for opts + -- [[ Configure Treesitter ]] See `:help nvim-treesitter` + opts = { + ensure_installed = { + 'lua', + 'python', + 'javascript', + 'typescript', + 'vimdoc', + 'vim', + 'regex', + 'terraform', + 'sql', + 'dockerfile', + 'toml', + 'json', + 'java', + 'groovy', + 'go', + 'gitignore', + 'graphql', + 'yaml', + 'make', + 'cmake', + 'markdown', + 'markdown_inline', + 'bash', + 'tsx', + 'css', + 'html', + }, + -- Autoinstall languages that are not installed + auto_install = true, + highlight = { + enable = true, + -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. + -- If you are experiencing weird indenting issues, add the language to + -- the list of additional_vim_regex_highlighting and disabled languages for indent. + additional_vim_regex_highlighting = { 'ruby' }, + }, + indent = { enable = true, disable = { 'ruby' } }, + }, + -- There are additional nvim-treesitter modules that you can use to interact + -- with nvim-treesitter. You should go explore a few and see what interests you: + -- + -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` + -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context + -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects +}