commit 4dbc00732c201aa879b27df4afa4504e935b9005 Author: Thorben Höhne Date: Wed Apr 30 00:02:34 2025 +0200 Initial commit diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..44e7e9d --- /dev/null +++ b/init.lua @@ -0,0 +1,82 @@ +require("core.options") +require("core.keymaps") +require("core.autostart") + +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 ---@diagnostic disable-next-line: undefined-field +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ + + -- Neotree + require("plugins.neotree"), + + -- Colorscheme + require("plugins.colorscheme"), + + -- Bufferline + require("plugins.bufferline"), + + -- Lualine + require("plugins.lualine"), + + -- Treesitter + require("plugins.treesitter"), + + -- Telescope + require("plugins.telescope"), + + -- LSP + require("plugins.lsp"), + + -- Autocomplete + require("plugins.autocompletion"), + + -- Formatting + require("plugins.none-ls"), + + -- Gitsigns + require("plugins.gitsigns"), + + -- Indent blankline + require("plugins.indent-blankline"), + + -- Misc + require("plugins.misc"), + + -- Toggleterm + require("plugins.toggleterm"), + + -- Rest + require("plugins.rest"), + + -- md-preview + require("plugins.md-preview"), + + -- Session Manager + require("plugins.session-manager"), + + -- Alpha + require("plugins.alpha"), + + -- Leap + require("plugins.leap"), +}) + +-- Setup color scheme +require("catppuccin").setup() +vim.cmd.colorscheme("catppuccin-mocha") + +require("toggleterm").setup({ + open_mapping = [[]], + direction = "float", + border = "shadow", +}) + +require("peek").setup({ app = "browser" }) diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..a4e5b1f --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,50 @@ +{ + "LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" }, + "alpha-nvim": { "branch": "main", "commit": "de72250e054e5e691b9736ee30db72c65d560771" }, + "auto-session": { "branch": "main", "commit": "095b0b54d40c8cc7fe37f2ae4d948ec3069bb1c2" }, + "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, + "catppuccin": { "branch": "main", "commit": "5b5e3aef9ad7af84f463d17b5479f06b87d5c429" }, + "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, + "cmp-path": { "branch": "main", "commit": "c6635aae33a50d6010bf1aa756ac2398a2d54c32" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, + "friendly-snippets": { "branch": "main", "commit": "31f2a2657b6261724313281fe0d8ba6f43f4a4fa" }, + "gitsigns.nvim": { "branch": "main", "commit": "d600d3922c1d001422689319a8f915136bb64e1e" }, + "hererocks": { "branch": "master", "commit": "c9c5444dea1e07e005484014a8231aa667be30b6" }, + "image.nvim": { "branch": "master", "commit": "2e2d28b7734b5efdfc1219f4da8a46c761587bc2" }, + "image_preview.nvim": { "branch": "main", "commit": "3f3f46210ba13bf82b1eb750b2d6d90eb211ee24" }, + "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "leap.nvim": { "branch": "main", "commit": "8a0efa79133fee211017d769c8031512192008b3" }, + "lualine.nvim": { "branch": "master", "commit": "86fe39534b7da729a1ac56c0466e76f2c663dc42" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" }, + "mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "1255518cb067e038a4755f5cb3e980f79b6ab89c" }, + "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "9b5d67119c46e3262ffe1508fe6d8540b79ad75d" }, + "none-ls-extras.nvim": { "branch": "main", "commit": "1214d729e3408470a7b7a428415a395e5389c13c" }, + "none-ls.nvim": { "branch": "main", "commit": "fb50cf17e926a037c9f8d96d8db29ddbd04965d4" }, + "nui.nvim": { "branch": "main", "commit": "8d3bce9764e627b62b07424e0df77f680d47ffdb" }, + "nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" }, + "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, + "nvim-lspconfig": { "branch": "master", "commit": "1a3a429efec62af632dfd8fa9b52fa226f655ec2" }, + "nvim-treesitter": { "branch": "master", "commit": "684eeac91ed8e297685a97ef70031d19ac1de25a" }, + "nvim-web-devicons": { "branch": "master", "commit": "c90dee4e930ab9f49fa6d77f289bff335b49e972" }, + "nvim-window-picker": { "branch": "main", "commit": "6382540b2ae5de6c793d4aa2e3fe6dbb518505ec" }, + "peek.nvim": { "branch": "master", "commit": "5820d937d5414baea5f586dc2a3d912a74636e5b" }, + "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, + "rest.nvim": { "branch": "main", "commit": "2ded89dbda1fd3c1430685ffadf2df8beb28336d" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "master", "commit": "a4ed82509cecc56df1c7138920a1aeaf246c0ac5" }, + "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, + "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, + "vim-bbye": { "branch": "master", "commit": "25ef93ac5a87526111f43e5110675032dbcacf56" }, + "vim-fugitive": { "branch": "master", "commit": "4a745ea72fa93bb15dd077109afbb3d1809383f2" }, + "vim-rhubarb": { "branch": "master", "commit": "386daa2e9d98e23e27ad089afcbe5c5a903e488d" }, + "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "vim-tmux-navigator": { "branch": "master", "commit": "791dacfcfc8ccb7f6eb1c853050883b03e5a22fe" }, + "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } +} diff --git a/lua/core/autostart.lua b/lua/core/autostart.lua new file mode 100644 index 0000000..2ca5a6f --- /dev/null +++ b/lua/core/autostart.lua @@ -0,0 +1,19 @@ +os = require("os") + +-- Execute on startup +os.execute("sed -i -e s/padding=\\{x=15,y=15\\}/padding=\\{x=0,y=0\\}/g ~/.alacritty.toml") + +-- On Exit +function on_exit(args) + os.execute("sed -i -e s/padding=\\{x=0,y=0\\}/padding=\\{x=15,y=15\\}/g ~/.alacritty.toml") +end + +vim.api.nvim_create_autocmd({ "ExitPre" }, { + pattern = "*", + callback = on_exit, +}) + +vim.api.nvim_create_autocmd({ "BufWritePre" }, { + pattern = "*", + command = "%s/ / /ge", +}) diff --git a/lua/core/keymaps.lua b/lua/core/keymaps.lua new file mode 100644 index 0000000..7c9fd40 --- /dev/null +++ b/lua/core/keymaps.lua @@ -0,0 +1,77 @@ +-- 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 without auto-formatting +vim.keymap.set("n", "", "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) +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", "k", ":resize -2", opts) +vim.keymap.set("n", "j", ":resize +2", opts) +vim.keymap.set("n", "h", ":vertical resize -2", opts) +vim.keymap.set("n", "l", ":vertical resize +2", opts) + +-- Buffers +vim.keymap.set("n", "", ":bnext", opts) +vim.keymap.set("n", "", ":bprevious", opts) +vim.keymap.set("n", "q", ":bdelete!:bnext", 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' }) + +-- Move lines +vim.keymap.set("n", "", ":m -2", opts) +vim.keymap.set("n", "", ":m +1", opts) diff --git a/lua/core/options.lua b/lua/core/options.lua new file mode 100644 index 0000000..cd27dfe --- /dev/null +++ b/lua/core/options.lua @@ -0,0 +1,42 @@ +vim.wo.number = true -- Make line numbers default (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/plugins/alpha.lua b/lua/plugins/alpha.lua new file mode 100644 index 0000000..4e20e6e --- /dev/null +++ b/lua/plugins/alpha.lua @@ -0,0 +1,46 @@ +return { + "goolord/alpha-nvim", + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + + config = function() + local alpha = require("alpha") + local dashboard = require("alpha.themes.dashboard") + + dashboard.section.header.val = { + [[ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠠⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⡀⠀⠙⢶⣄⠀⠀⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⠀⢠⣶⣦⣤⣀⣀⣤⣤⣄⣀⠀⢀⣀⣴⠂⠀⠀⠀⠀⠀⠀⠀⠐⠉⠉⣉⣉⣽⣿⣿⣷⣾⣿⣷⣄⡸⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⠀⠿⠿⢿⣿⣿⣿⣭⣭⣿⣿⣿⣿⣟⣁⠀⠀⠀⠀⠀⠀⠀⠀⣠⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⠶⠤⠀⠀⢠⡾⢿⣿⣿⣿⣿⡿⠉⠀⠀⠀⠈⠙⢻⣿⣿⣿⡛⢻⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠋⠀⠀⠀⠉⠻⣿⣿⣿⣿⣦⡀⠀⠁⠀⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣦⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣯⡙⢦⠀⠀⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠙⠻⠿⠿⣿⣿⣿⣿⣶⣄⠀⠀⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⡄⠀⠀⣿⣿⣿⣿⣿⣿⣿⣦⠀⠀⠀⠀⠰⣄⠀⠀⠀⠀⠈⠛⢿⣿⡏⠀⠀⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⣿⣿⣿⡝⡇⠀⠀⠹⡇⠙⢿⣿⣿⣿⣿⣿⣶⣦⣄⣀⣈⣳⣶⣤⣤⣄⣀⠈⠋⠀⠀⠀⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⣿⣿⣿⡇⠁⠀⠀⠀⠙⣠⠤⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡛⠻⣷⣄⡀⠀⠀⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⠀⠈⢲⡄⠀⢀⡠⠔⠂⠀⠀⠀⠀⣸⣿⣿⣿⡿⢹⠇⠀⠀⠀⠀⠈⢀⣤⣶⣾⣿⣿⣿⣿⣿⣿⣿⡟⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⠀⠀⣾⣧⣾⣿⣶⣶⣶⣤⣀⠀⠀⣿⣿⣿⣿⠇⠋⠀⠀⠀⠀⢀⣴⣿⣿⣿⣿⣿⠟⠛⢿⣿⣿⣿⣿⡄⠀⠻⣿⡿⠿⠛⠛⠛⠛⠿⡿⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⢀⣼⣿⣿⣿⣿⣿⣿⣿⣷⣮⡁⠀⣿⣿⣿⣿⠀⠀⠀⠀⠀⢠⠞⣻⣿⣿⣿⡿⠁⠀⠀⠈⣿⣿⣿⣿⣧⠀⠀⠀⢀⡀⠀⠀⠀⣴⠀⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⢠⡿⢹⣿⣿⡋⠀⠈⢻⣿⣿⣿⡟⠆⢻⣿⣿⣿⡇⠀⠀⠀⠀⠀⢰⣿⣿⣿⣿⡇⠀⠀⠀⠀⢸⣿⣿⣿⣿⠀⠀⠀⣀⣭⣽⣶⣬⣿⡄⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⣰⣷⣿⣿⠿⠃⠀⠀⢸⣿⣿⣿⣿⡄⠘⣿⣿⣿⣿⣄⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣄⠀⠀⠀⣾⣿⣿⣿⣿⠀⠴⣻⣿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀ ]], + [[ ⠀⣴⣿⡿⠋⠀⠀⠀⠀⠀⣼⣿⣿⣿⢿⡇⠀⠘⣿⣿⣿⣿⣦⡀⠀⠀⢸⡟⢿⣿⣿⣿⣿⣧⡀⣰⣿⣿⣿⣿⡏⠀⣼⣿⣿⣿⠋⠀⠉⣿⣿⣌⣷⠀⠀⠀ ]], + [[ ⠀⠈⠛⠁⠀⠀⠀⠀⠀⢸⣿⣿⣿⡏⠘⠀⠀⠀⠈⢻⣿⣿⣿⣿⣷⣤⡀⠳⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠈⣿⣿⣿⣿⠀⠀⠈⠛⠻⢿⣿⣷⡄⠀ ]], + [[ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣇⠀⠀⠀⠀⠀⠀⠉⠻⣿⣿⣿⣿⣿⣷⣶⣤⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠀⣿⢿⣿⣿⣧⡀⠀⠀⠀⠀⠈⠿⠇⠀ ]], + [[ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀⠀⠈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠘⠌⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⣿⣿⣿⣶⣶⣤⣤⣤⣄⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠀⠀⠀⠀⢀⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⣀⣤⣤⣴⣾⣿⣿⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⡀⠀⠀⢤⣬⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⡁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ]], + [[ ⠀⠀⠀⠀⠀⠀⠠⠾⣿⣿⣿⣶⣤⣤⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣠⣶⣦⣄⡀⠀⠀⣶⢒⠲⣄ ]], + [[ ⣾⣥⣤⣼⣿⣶⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣾⣵⣾⡿ ]], + } + + dashboard.section.buttons.val = { + dashboard.button("", " Select Session", ":SessionSearch "), + dashboard.button("ff", " Open file", ":Neotree float "), + dashboard.button("fr", " Open recent files.", ":Telescope oldfiles "), + } + + alpha.setup(dashboard.opts) + end, +} diff --git a/lua/plugins/autocompletion.lua b/lua/plugins/autocompletion.lua new file mode 100644 index 0000000..a3c4578 --- /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..6d86149 --- /dev/null +++ b/lua/plugins/bufferline.lua @@ -0,0 +1,66 @@ +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", + offset = { + filetype = "neo-tree", + text = "Nvim Tree", + separator = true, + text_align = "left", + }, + }, + highlights = { + separator = { + fg = "#434C5E", + }, + buffer_selected = { + bold = true, + italic = false, + }, + -- separator_selected = {}, + -- tab_selected = {}, + -- background = {}, + -- indicator_selected = {}, + -- fill = {}, + }, + }) + end, +} diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..5b489f5 --- /dev/null +++ b/lua/plugins/colorscheme.lua @@ -0,0 +1,6 @@ +return { + "catppuccin/nvim", + name = "catppuccin", + priority = 1000, + lazy = false, +} diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..33fafb9 --- /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..c91d3d2 --- /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/leap.lua b/lua/plugins/leap.lua new file mode 100644 index 0000000..de1a4de --- /dev/null +++ b/lua/plugins/leap.lua @@ -0,0 +1,7 @@ +return { + "ggandor/leap.nvim", + config = function() + require("leap").set_default_keymaps() + require("leap").opts.case_sensitive = true + end, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..6367005 --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,248 @@ +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 + ts_ls = {}, -- tsserver is deprecated + 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 = {}, + jsonls = {}, + yamlls = {}, + clangd = {}, + ocamllsp = {}, + + 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..e261d55 --- /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/md-preview.lua b/lua/plugins/md-preview.lua new file mode 100644 index 0000000..2447da1 --- /dev/null +++ b/lua/plugins/md-preview.lua @@ -0,0 +1,10 @@ +return { + "toppair/peek.nvim", + event = { "VeryLazy" }, + build = "deno task --quiet build:fast", + config = function() + require("peek").setup() + vim.api.nvim_create_user_command("PeekOpen", require("peek").open, {}) + vim.api.nvim_create_user_command("PeekClose", require("peek").close, {}) + end, +} diff --git a/lua/plugins/misc.lua b/lua/plugins/misc.lua new file mode 100644 index 0000000..306c2f9 --- /dev/null +++ b/lua/plugins/misc.lua @@ -0,0 +1,52 @@ +-- Standalone plugins with less than 10 lines of config go here +return { + { + -- Image preview + "adelarsq/image_preview.nvim", + event = "VeryLazy", + config = function() + require("image_preview").setup() + end, + }, + { + -- 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..0a17ca8 --- /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..cf83806 --- /dev/null +++ b/lua/plugins/none-ls.lua @@ -0,0 +1,58 @@ +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 + "clangd", + }, + 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"), + formatting.clang_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/rest.lua b/lua/plugins/rest.lua new file mode 100644 index 0000000..92435c5 --- /dev/null +++ b/lua/plugins/rest.lua @@ -0,0 +1,10 @@ +return { + "rest-nvim/rest.nvim", + dependencies = { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + table.insert(opts.ensure_installed, "http") + end, + }, +} diff --git a/lua/plugins/session-manager.lua b/lua/plugins/session-manager.lua new file mode 100644 index 0000000..2d61e72 --- /dev/null +++ b/lua/plugins/session-manager.lua @@ -0,0 +1,18 @@ +return { + "rmagatti/auto-session", + config = function() + require("auto-session").setup({ + auto_session_suppress_dirs = { "~/", "~/Projects", "~/Downloads", "/" }, + session_lens = { + buftypes_to_ignore = {}, + load_on_setup = true, + theme_conf = { border = true }, + previewer = false, + }, + }) + + vim.keymap.set("n", "ls", require("auto-session.session-lens").search_session, { + noremap = true, + }) + end, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..d198f44 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,116 @@ +return { -- Fuzzy Finder (files, lsp, etc) + "nvim-telescope/telescope.nvim", + event = "VimEnter", + 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 = { [''] = 'to_fuzzy_refine' }, + -- }, + -- }, + -- pickers = {} + 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" }) + + -- Shortcut for searching your Neovim configuration files + vim.keymap.set("n", "sn", function() + builtin.find_files({ cwd = vim.fn.stdpath("config") }) + end, { desc = "[S]earch [N]eovim files" }) + end, +} diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua new file mode 100644 index 0000000..709fd79 --- /dev/null +++ b/lua/plugins/toggleterm.lua @@ -0,0 +1,10 @@ +return { + -- amongst your other plugins + "akinsho/toggleterm.nvim", + version = "*", + config = true, + + -- config = function() + -- vim.keymap.set("n", "tt", " ToggleTerm direction=float ", { noremap = true, silent = true }) + -- end, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..03adf62 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,33 @@ +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 = { + 'bash', + 'c', + 'cpp', + 'python', + 'javascript', + 'html', + 'css' + }, + -- 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 +}