diff --git a/.config/nvim/README.norg b/.config/nvim/README.norg index 57511ca..5043b08 100644 --- a/.config/nvim/README.norg +++ b/.config/nvim/README.norg @@ -4,11 +4,12 @@ -- Plugin spec: `./lua/plugin_spec.lua` -- Modular plugin configuration: `./lua/plugins/*.lua` - LSP & Completion - -- `lsp-config` with nvim-0.5 + -- `lsp-config`, `lspkind`, `lsp_signature` -- `nvim-cmp` -- Treesitter: context + textobjects - - Status line (SUBJECT TO CHANGE) - -- Lualine + - Status line: NONE + -- Ruler area when there's only one window + -- Together with incline.nvim when there are splits - Theme: Tundra - File explorer: NvimTree @@ -94,10 +95,9 @@ neovim version: 0.9 - UI - -- No fancy UI like message popups + -- No fancy UI like message popups. What are we in? GUI? -- Area of main source (code) should be as tall as possible on a laptop, - this means little possiblity for permanent winbar, tabline, or high - cmdheight. + this means sparingly little tabline/winbar or high cmdheight. -- Completion is turned off by default. This allows distraction free typing. The menu can be triggered with TAB. Unfortunately, nvim-cmp does not yet support ghost text + manual completion, unlike my emacs config @@ -114,4 +114,16 @@ -- Enough contrast where applicable to discern UI elements - Plugins - -- Preferably plugins with enough customizability and without feature-creep + -- Preferably plugins with enough customizability but without feature-creep + +** Meta todo + + - Emacs + -- ( ) Talk about lazy.nvim/packer vs elpaca/straight + use-package + +** Neovim todo + + - 'Statusline' set up + -- ( ) Add diagnostics to incline and ruler + -- ( ) Find a way to make ruler behave properly + -- ( ) Look into nougat diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 11c2d7a..515649b 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -6,8 +6,11 @@ vim.g.mapleader = [[ ]] -- Set envvar VIMHOME to, eg, ~/.config/nvim (has no trailing slash) vim.env.VIMHOME = vim.fn.expand(':p:h') +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + require('loadlazy') -require('general') -require('mappings') -require('autocmds') +require('config/general') +require('config/mappings') +require('config/autocmds') diff --git a/.config/nvim/lua/plugins/statusline.lua b/.config/nvim/lua/archive/statusline.lua similarity index 95% rename from .config/nvim/lua/plugins/statusline.lua rename to .config/nvim/lua/archive/statusline.lua index ff553ad..9b20255 100644 --- a/.config/nvim/lua/plugins/statusline.lua +++ b/.config/nvim/lua/archive/statusline.lua @@ -143,11 +143,3 @@ lualine.setup { inactive_winbar = {}, extensions = {'nvim-tree', competitest_line, 'symbols-outline'}, } - --- local map = function(...) vim.keymap.set(...) end --- local d = function(s) return { desc = s } end - --- map( --- "n", "mm", --- function() lualine.hide({ places = "statusline", unhide }) end --- ) diff --git a/.config/nvim/lua/autocmds.lua b/.config/nvim/lua/config/autocmds.lua similarity index 100% rename from .config/nvim/lua/autocmds.lua rename to .config/nvim/lua/config/autocmds.lua diff --git a/.config/nvim/lua/general.lua b/.config/nvim/lua/config/general.lua similarity index 75% rename from .config/nvim/lua/general.lua rename to .config/nvim/lua/config/general.lua index 0a0b00c..fb02df7 100644 --- a/.config/nvim/lua/general.lua +++ b/.config/nvim/lua/config/general.lua @@ -7,20 +7,29 @@ o.number = true o.relativenumber = true o.mouse = "a" -o.selectmode = "mouse" -- Use select mode when dragging with mouse +-- Use select mode when dragging with mouse. +-- This allows IDE-like quick substitution. If I need to use the mouse for +-- visual selection, I can select with mouse, then v +-- See mappings.lua for IDE-like pair wrapping in select mode. (Select text, +-- press an open bracket to have selection be wrapped immediately.) +o.selectmode = "mouse" + -- Changes to default: --- - Use vertical in all of command mode +-- - Use vertical in command mode o.guicursor = "n-v-sm:block,i-ci-ve-c:ver25,r-cr-o:hor20" -- o.cursorline = true -- Cursor line is rather distracting when trying to focus on the code. -- Especially so when typing in comments -- the background of the cursor line -- behind the already low-constrast comment fg color makes it hard to read (and --- write with) +-- write with) <-- this was back when using dracula. -- -- If I'm working on something with long lines and I need a visual indicator of -- alignment I can do visual line then to "blink" the cursor line, or -- enable this locally. +-- +-- Maybe I'll figure out a way in the future to dynamically enable cursorline +-- when screenline is wrapped. o.showcmd = true -- show incomplete commands o.hlsearch = true -- highlight search o.wildmenu = true -- command line's tab complete in a menu @@ -28,20 +37,28 @@ o.errorbells = false-- no beeps please o.visualbell = true -- flash screen instead o.title = true -- set window title to file name o.incsearch = true -- incrementally find next match while typing search -o.scrolloff = 6 -- screen lines to keep above and below cursor -o.sidescrolloff = 8 -- screen columns to keep on left and right of cursor +-- Having scrolloff positive means I can't have cursor at the very top/bottom +-- whilst referring to some content on the other side of the same buffer +o.scrolloff = 0 +o.sidescrolloff = 0 o.confirm = true o.showmatch = true o.showmode = false -- Don't show messages when switching modes + -- It's such an integral part of (n)vim, I know what I'm doing :) o.encoding = "utf-8" -o.mat = 2 +o.matchtime = 1 -- deci second to show matching pair while typing o.inccommand = "nosplit" -- neovim only o.autoindent = true o.fileformat = "unix" o.splitbelow = true --- o.exrc = true -- Could be potentially dangerous +o.splitright = true +if vim.fn.has("nvim-0.9") == 1 then + -- Could be potentially dangerous before the exrc PR is merged. + -- In 0.9 they can open files securely using trust DB + o.exrc = true +end vim.o.autochdir = true o.expandtab = true -- AIUI, tab -> spaces diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/config/mappings.lua similarity index 64% rename from .config/nvim/lua/mappings.lua rename to .config/nvim/lua/config/mappings.lua index ef57f58..b635ea8 100644 --- a/.config/nvim/lua/mappings.lua +++ b/.config/nvim/lua/config/mappings.lua @@ -1,9 +1,9 @@ -- Note that plugins config may set more mappings. local silent = { silent = true } +local map = vim.keymap.set +local au = vim.api.nvim_create_autocmd local function d(s) return { desc = s } end -local function map(...) vim.keymap.set(...) end -local function au(...) vim.api.nvim_create_autocmd(...) end local function mapbuf(a, b, c) vim.api.nvim_buf_set_keymap(0, a, b, c, { noremap=true }) end --------------------- @@ -12,28 +12,29 @@ local function mapbuf(a, b, c) vim.api.nvim_buf_set_keymap(0, a, b, c, { noremap map("n", "rn", "set relativenumber!", d "toggle rel num") map("n", "z", "zR", d "zA (toggle all folds)") -- The 3 mappings that I use most often out of all vim mappings :D -map("n", "w", "w", d "write") -map("n", "x", "xa", d "x all") -map("n", "q", "qa", d "quit all") +map("n", "w", "w", d ":w") +map("n", "x", "xa", d ":xa") +map("n", "q", "qa", d ":qa") map("n", "nh", "noh", d ":noh") map("n", "p", "\"+p", d "System clipboard paste") --- XXX: Decide whether to deprecate this in favor of :Telescope registers -map("n", "rg", "registers", d "Show registers, also fR") -map("n", "u", "gul") -map("n", "U", "gUl") -map("n", "", "") -map("n", "", "") +-- Deprecated in favor of telescope registers because you can use to edit +-- select register, how cool is that! +-- map("n", "rg", "registers", d "Show registers, also fR") +map("n", "u", "gul", d "Lower current char") +map("n", "U", "gUl", d "Upper current char") +map("n", "", ":", d "Like @: but does not ") ----------------------------------- -- Normal and Universal Mappings -- ----------------------------------- -- Close a buffer, useful when doing PlugInstall and then closing that --- Or is it close a window? frame? DAMN all this emacs terminology got me so --- confused -map("n", "Q", "q") +-- Or is it close a window? frame? I'll admit all this emacs terminology got me +-- so confused. +map("n", "Q", "q", d":q") --- NOTE: These mappings Just Work in wsl so no need the extra binding like --- in vimrc, this is why you use neovim instead of vim ;) +-- Legacy comment incomming +-- > These mappings Just Work in wsl so no need the extra binding like in vimrc, +-- > this is why you use neovim instead of vim ;) map("n", "", "m+1==", d "Move line down") map("n", "", "m-2==", d "Move line up") map("n", "", "t.==", d "Copy line down") @@ -99,7 +100,7 @@ else map("", "", "split term://fishresize -7i", d "Open terminal below" ) end -map("t", "", "", d "Esc in terminal mode") +map("t", "", "") -------------------------------------- -- Insert/Command Editting Mappings -- @@ -121,8 +122,34 @@ map("i", "", "") -------------------------------- -- Filetype specific mappings -- -------------------------------- - au("FileType", { - pattern = {"help"}, - callback = function () mapbuf("n", "q", "q") end + pattern = {"help", "qf"}, + callback = function() mapbuf("n", "q", "q") end }) + + +-------------------------- +-- Select mode mappings -- +-------------------------- +-- Requires 'mini.surround' for 'sa' and Comment.nvim for 'gb' +map("s", '(', "sa(gvll", {remap = true}) +map("s", ')', "sa)gvll", {remap = true}) +map("s", '\'', "sa'gvll", {remap = true}) +map("s", '"', 'sa"gvll', {remap = true}) +map("s", '`', "sa`gvll", {remap = true}) +map("s", '', "vgb", {remap = true}) + +-- Select mode tips (:h Select) +-- * Ctrl-G toggles Visual and Select mode +-- * Ctrl-R let's you put what ever you replaced into register +-- Visual mode mappings apply to select mode unless it is a printable character +-- or , or above key sequences and +-- +-- Visual mode tips +-- * You can use 'p' on selection and it will be replaced by paste +-- * 'P' is same except it does not overwrite registers +-- * gn/gN select match +-- * ~ Switch case (or u/U) +-- Visual block +-- * I/A can be used in place of i/a +-- * >/< shift can be used! diff --git a/.config/nvim/lua/loadlazy.lua b/.config/nvim/lua/loadlazy.lua index e0cc8ce..df048b8 100644 --- a/.config/nvim/lua/loadlazy.lua +++ b/.config/nvim/lua/loadlazy.lua @@ -1,3 +1,5 @@ +-- Bootstrap and set up lazy.nvim +-- Lazy.nvim is one of the things to keeps me from emacs ๐Ÿ’” local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system({ @@ -15,42 +17,17 @@ vim.cmd [[ filetype indent on ]] -require("lazy").setup("plugin_spec", { +require("lazy").setup("plugins", { install = { colorscheme = { "tundra" }, }, change_detection = { - -- I still have to quit and reopen nvim after a new plugin install anyway, - -- so this feature is useless and annoying. - enabled = false, + enabled = true, notify = false, }, ui = { -- a number <1 is a percentage., >1 is a fixed size - size = { width = 1, height = 1 }, - icons = { - cmd = "๎ฏ‡ ", - config = "๏€“", - event = "๎ช†", - ft = "๏€– ", - init = "๏€“ ", - import = "๎‰ฝ ", - keys = "๏„œ ", - lazy = "๓ฐ’ฒ ", - loaded = "โ—", - not_loaded = "โ—‹", - plugin = "๏’‡ ", - runtime = "๎žฅ", - require = "๓ฐขฑ ", - source = "๏„ก ", - start = "๎ซ“", - task = "โœ” ", - list = { - "โ—", - "โžœ", - "โ˜…", - "โ€’", - }, - }, + size = { width = 0.8, height = 0.9 }, + border = "rounded", }, }) diff --git a/.config/nvim/lua/plugin_spec.lua b/.config/nvim/lua/plugin_spec.lua deleted file mode 100644 index 1a2d0b9..0000000 --- a/.config/nvim/lua/plugin_spec.lua +++ /dev/null @@ -1,643 +0,0 @@ --- Used by Lazy.nvim in loadlazy.lua --- --- Note on styling: --- { "plugin src", <-- ugly, but useful --- option = value, --- option = value, --- } --- The "plugin src" is joined on the same line as opening brace so --- treesitter-context can show the plugin name. Useful since some of the plugin --- specs could be long. -return { - { "dracula/vim", - name = "dracula", lazy = false, priority = 10000, - config = function() vim.cmd("colorscheme dracula") end, - enabled = false, -- LOL I've switched to tundra semi-temporarily - }, - -- The thing about using dracula theme in nvim here is the annoyance of - -- having to use lua APIs to interact with something that was designed for - -- vimscript. With "modern" nvim plugins where the themes are written in 100% - -- lua, configuring everything else (such as statusline colors) reusing - -- values defined in these themes provide a much smoother, cleaner - -- configuration. - -- - -- This is by no means a /political/ (ahem) statement suggesting my - -- abandoning of the holy dracula theme. I just, well, decided to try - -- something new since I sort of realized there is no "perfect" or "best" - -- theme. - -- - -- After hours of blood, pain, and tears of trying to tweak dracula colors to - -- be easier on the eyes and have greater contrast, I took one look at the - -- carousel of themes from NvChad and fell in love with tundra... - { "sam4llis/nvim-tundra", lazy = false, priority = 10000, - config = function () require("plugins/tundra") end, - }, - -- Use 'gf' with dot.separated.modules in lua. - -- Put the cursor at the argument in "require" and press "gf" to see the effect. - "sam4llis/nvim-lua-gf", - { "nvim-tree/nvim-tree.lua", - cmd = {"NvimTreeOpen", "NvimTreeToggle", "NvimTreeFindFile", "NvimTreeFocus", "NvimTreeFindFileToggle"}, - keys = { "e" }, - config = function () - vim.keymap.set("n", "e", "NvimTreeToggle", - { desc = "NvimTreeToggle" }) - require("nvim-tree").setup { - view = { width = 20, }, - -- renderer = { group_empty = true, }, - -- filters = { dotfiles = true, }, - } - end, - }, - -- "jreybert/vimagit", -- emacs' magit โœจ - -- So anyways apparently almost every plugin that was popular in vim had to - -- be rewritten in lua. - { "NeogitOrg/neogit", - cmd = "Neogit", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-telescope/telescope.nvim", - "sindrets/diffview.nvim", -- optional - -- "ibhagwan/fzf-lua", -- optional - }, - opts = { - integrations = { - -- Use telescope for menu selection rather than vim.ui.select. - -- Allows multi-select and some things that vim.ui.select doesn't. - telescope = true, - -- The diffview integration enables the diff popup. - diffview = true, - }, - } - }, - -- "tpope/vim-surround", -- quoting and parenthesizing manipulation - -- "tpope/vim-commentary", -- I'd rather not clog mappings with nerd commentor - -- Sorry tpope! It's more convenient to configure in lua than in vim... - -- * nvim-comment is lighter but doesn't, AFAIK, support block comments. - -- * mini.surround let's you add quotes easily (defined above) - { "numToStr/Comment.nvim", opts = {} }, - { "lewis6991/gitsigns.nvim", - -- "Be the diff you wish see in the gutter" -- Doom Emacs - -- Also see comparison with vim-gitgutter: - -- https://github.com/lewis6991/gitsigns.nvim?tab=readme-ov-file#comparison-with-vim-gitgutter - enabled = vim.fn.has("nvim-0.8") == 1, - opts = { - -- NO WAY! โค๏ธ - yadm = { enable = true }, - }, - }, - { "folke/trouble.nvim", - enabled = vim.fn.has("nvim-0.7.2") == 1, - cmd = "Trouble", - dependencies = { "nvim-tree/nvim-web-devicons" }, - opts = { - signs = { - -- icons / text used for a diagnostic - error = "E:", - warning = "W:", - hint = "H:", - information = "I:", - other = "X:", - }, - fold_open = "๏‘ผ", -- icon used for open folds - fold_closed = "๏‘ ", -- icon used for closed folds - }, - }, - { 'stevearc/aerial.nvim', - enabled = false, - opts = { - filter_kind = false, - }, - -- Optional dependencies - dependencies = { - "nvim-treesitter/nvim-treesitter", - "nvim-tree/nvim-web-devicons" - }, - }, - { dir = "~/projects/markdown-toc.nvim", ft = "markdown", - opts = { - -- fences = false, - toc_list = { - -- indent_size = function() return vim.bo.shiftwidth end, - } - }, - }, - { dir = "~/projects/outline.nvim", -- See https://github.com/hedyhli/outline.nvim - -- Switched to this from tagbar because it does not require exctags, and it - -- lists the items in order as defined in source code. - enabled = vim.fn.has("nvim-0.7") == 1, - cmd = { "Outline", "OutlineOpen" }, - keys = { - { "tt", "Outline", desc = "Toggle outline window" }, - { "tT", "Outline!", desc = "Toggle outline window without focus" }, - { "tf", "OutlineFollow", desc = "Focus & follow outline window" }, - }, - config = function() require "plugins/outline" end, - }, - -- "bling/vim-bufferline", -- I prefer this over taking over the tabline space thanks - -- Fair well vim-bufferline! You have served my vim and nvim experience well. - -- I've since decided to set cmdheight to 1 and put the buffers in my status - -- bar :') - -- See plugins/statusline.lua. - -- TODO: Check if this is still needed - "tpope/vim-endwise", -- Add those 'endif'/'fi'/'done' - { "moll/vim-bbye", -- smart buffer closer - config = function() - local function d(s) return { desc = s } end - local function map(...) vim.keymap.set(...) end - map("n", "bd", "Bdelete", d"Bdelete") - map("n", "bx", "Bwipeout", d"like bd but removes from jumplist") - end - }, - { "nvim-tree/nvim-web-devicons", lazy = true, - enabled = vim.fn.has("nvim-0.7") == 1, - config = function() require('plugins/icons') end, - pin = true, - commit = 'cde67b5d5427daeecfd7c77cf02ded23a26980bb', - }, - { -- STATUS LINE - "nvim-lualine/lualine.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - config = function() require("plugins/statusline") end, - enabled = false, - }, - { "b0o/incline.nvim", - config = function() require("plugins/incline") end, - }, - { "tiagovla/scope.nvim", - -- Tab-local buffer list. - -- Similar to beframe (by prot) from emacs! - config = true - }, - { 'nvim-telescope/telescope.nvim', tag = '0.1.4', - enabled = vim.fn.has("nvim-0.9") == 1, - dependencies = { - 'nvim-lua/plenary.nvim', - { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, - }, - config = function() require('plugins/telescope') end, - }, - { "folke/todo-comments.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, - opts = { - highlight = { - multiline = false, - -- The 3 lines below tunes down the coloring of the highlights. The - -- color schemes and treesitter nowdays are already way too vibrant for - -- my liking, and for someone who litters todo/fixme way too much - -- everywhere, adding *wide* *bg* highlighting to them is just WAY TOO - -- MUCH EYE CANDY AAAA - before = "", - keyword = "fg", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. - after = "", -- "fg" or "bg" or empty - - pattern = [[.*<(KEYWORDS)\s*]], -- (vim regex) - comments_only = true, -- uses treesitter to match keywords in comments only - max_line_len = 200, - exclude = {}, -- filetypes - }, - } - }, - { "echasnovski/mini.files", - -- Neat popout window to browse dirs and manipulate within the editor! - cmd = "MiniFiles", - dependencies = { "nvim-tree/nvim-web-devicons" }, - config = function() - require('mini.files').setup() - vim.api.nvim_create_user_command('MiniFiles', function() - MiniFiles.open() - end, { desc = "Calls lua MiniFiles.open()" }) - end, - }, - { "echasnovski/mini.surround", version = '*', - opts = { - -- Duration (in ms) of highlight when calling `MiniSurround.highlight()` - highlight_duration = 500, - -- Module mappings. Use `''` (empty string) to disable one. - mappings = { - add = 'sa', -- Add surrounding in Normal and Visual modes - delete = 'ds', -- Delete surrounding -- Using "ds" for muscle memory compat - find = 'sf', -- Find surrounding (to the right) - find_left = 'sF', -- Find surrounding (to the left) - highlight = 'sh', -- Highlight surrounding - replace = 'cs', -- Replace surrounding -- muscle memory compat - update_n_lines = 'sn', -- Update `n_lines` - - suffix_last = 'l', -- Suffix to search with "prev" method - suffix_next = 'n', -- Suffix to search with "next" method - }, - -- Number of lines within which surrounding is searched - n_lines = 20, - -- Whether to respect selection type: - -- - Place surroundings on separate lines in linewise mode. - -- - Place surroundings on each line in blockwise mode. - respect_selection_type = false, - -- How to search for surrounding (first inside current line, then inside - -- neighborhood). One of 'cover', 'cover_or_next', 'cover_or_prev', - -- 'cover_or_nearest', 'next', 'prev', 'nearest'. For more details, - -- see `:h MiniSurround.config`. - search_method = 'cover', - -- Whether to disable showing non-error feedback - silent = false, - }, - }, - { "echasnovski/mini.splitjoin", - opts = { - mappings = { -- both n/v modes - toggle = 'gS', - split = '', - join = '', - }, - detect = { - -- Array of Lua patterns to detect region with arguments. - -- Default: { '%b()', '%b[]', '%b{}' } - brackets = nil, - -- String Lua pattern defining argument separator - separator = ',', - -- Array of Lua patterns for sub-regions to exclude separators from. - -- Enables correct detection in presence of nested brackets and quotes. - -- Default: { '%b()', '%b[]', '%b{}', '%b""', "%b''" } - exclude_regions = nil, - }, - -- Split options - split = { - hooks_pre = {}, - hooks_post = {}, - }, - -- Join options - join = { - hooks_pre = {}, - hooks_post = {}, - }, - } - }, - { "echasnovski/mini.trailspace", - config = true, - }, - { "lukas-reineke/indent-blankline.nvim", name = "ibl", - -- https://github.com/lukas-reineke/indent-blankline.nvim/wiki/Migrate-to-version-3 - -- Not documented but it appears new version requires nvim nightly. - -- Upgraded to nvim 0.9.4 and the new version worked with showing context - -- without needing treesitter! ๐ŸŽ‰ - after = "sam4llis/nvim-tundra", - main = vim.fn.has("nvim-0.9") == 1 and "ibl", - version = vim.fn.has("nvim-0.9") == 1 and "*" or "2.20.8", - pin = vim.fn.has("nvim-0.9") == 0, - opts = { - -- scope = { - -- highlight = "ErrorMsg", - -- }, - exclude = { - filetypes = { - "help", - "NvimTree", - "Trouble", - "trouble", - "lazy", - "mason", - "notify", - "toggleterm", - "lazyterm", - "Outline" - }, - }, - }, - }, - { "RRethy/vim-illuminate", - config = function () - require("illuminate").configure{} - vim.cmd([[hi def IlluminatedWordText guibg=Gray]]) - end, - enabled = false, -- Somehow wasn't working for me - }, - - --- File type, syntax, language helper plugins --- - { url = "https://git.sr.ht/~torresjrjr/gemini.vim", ft = "gemini" }, - { "cespare/vim-toml", ft = "toml" }, - { "blankname/vim-fish", ft = "fish", - config = function () - vim.opt_local.shiftwidth = 4 - vim.opt_local.textwidth = 79 - vim.opt_local.foldmethod = "expr" - vim.opt_local.expandtab = true - vim.opt_local.tabstop = 4 - end, - }, - { url = "https://git.rawtext.club/slope-lang/slope-vim-syntax", - ft = "slope", - enabled = false; - }, - { "mzlogin/vim-markdown-toc", ft = "markdown", - }, - { "leafo/moonscript-vim", ft = "moon", - config = function () - vim.opt_local.tabstop = 2 - vim.opt_local.softtabstop = 2 - vim.opt_local.shiftwidth = 2 - end - }, - - ------ LSP and autopair plugins ------ - -- This plugin below is really good, but whenever I'm on a commented line, - -- press o, press backspace, the line below is joined up above. You won't - -- believe how long it took me to debug this problem and finally realize it's - -- because of this plugin. - -- "jiangmiao/auto-pairs", - -- - -- So now I'm using this instead: - -- windwp/nvim-autopairs - extremely customizable, written in lua - - -- integrates wth hrsh7th/nvim-cmp - -- For nvim < 0.5, use: townk/vim-autoclose - { "mfussenegger/nvim-lint", - enabled = vim.fn.has("nvim-0.6") == 1, - config = function() require("plugins/linting") end, - }, - { "windwp/nvim-autopairs", - commit = vim.fn.has("nvim-0.7") == 1 and "b7672cd", - config = function() require("plugins/autopair") end, - }, - - -- Best IDE autocomplete setup ever - -- INSANE level of customizability within an environment as confortable as - -- lua and with stability as solid as an obsidian. - { "neovim/nvim-lspconfig", - config = function() - require('plugins/lsp') - end - }, - { "ray-x/lsp_signature.nvim", - event = "VeryLazy", - config = function(_, opts) require'lsp_signature'.setup(opts) end, - opts = { - doc_lines = 10, - -- set to 0 if you DO NOT want any API comments be shown - -- This setting only take effect in insert mode, it does not affect signature help in normal - -- mode, 10 by default - max_height = 12, - max_width = 80, - noice = false, - wrap = true, - floating_window = false, - floating_window_above_cur_line = true, - floating_window_off_x = 1, - floating_window_off_y = 0, -- -2 move window up 2 lines; 2 move down 2 lines - -- can be either number or function, see examples - close_timeout = 4000, - fix_pos = false, -- don't auto-close the floating window all parameters finished - hint_enable = true, -- virtual hint - hint_prefix = "๎ชซ ", - hint_scheme = "String", - hint_inline = function() return vim.fn.has('nvim-0.10') == 1 end, - hi_parameter = "LspSignatureActiveParameter", - handler_opts = { border = "rounded" }, - always_trigger = false, - auto_close_after = nil, - extra_trigger_chars = {","}, - zindex = 200, - padding = '', - transparency = nil, -- 1~100 - timer_interval = 200, -- lower to reduce latency - toggle_key = '', -- toggle floating window key (must set below to true) - toggle_key_flip_floatwin_setting = true, - select_signature_key = '', -- next signature for (eg) overloads - }, - }, - -- Treesitter! - { "nvim-treesitter/nvim-treesitter", - enabled = vim.fn.has('nvim-0.9') == 1, - build = ":TSUpdate", - version = false, - event = "VeryLazy", - cmd = { "TSUpdateSync", "TSUpdate", "TSInstall", "Inspect", "InspectTree" }, - config = function() require("plugins/treesitter") end, - }, - -- Setting these as dependencies of nvim-treesitter causes error of invalid - -- query. - { "nvim-treesitter/nvim-treesitter-context", - enabled = vim.fn.has('nvim-0.9') == 1, - after = "nvim-treesitter/nvim-treesitter", - }, - { "nvim-treesitter/nvim-treesitter-textobjects", - enabled = vim.fn.has('nvim-0.9') == 1, - after = "nvim-treesitter/nvim-treesitter", - }, - { "windwp/nvim-ts-autotag", - -- Automatically add closing tags for HTML and JSX - ft = { "html", "tsx", "jsx" }, - opts = {}, - }, - -- End of treesitter - -- Begin completion framework - -- Please see ./lua/plugins/complete.lua - { "hrsh7th/nvim-cmp", - event = { "InsertEnter", "CmdlineEnter" }, - config = function() require('plugins/complete') end, - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-path", -- File paths - "hrsh7th/cmp-cmdline", -- Fire your way through the neovim cmd line - "hrsh7th/cmp-calc", -- Somehwat useful.. But emacs M-x calc FTW! - "hrsh7th/cmp-emoji", -- ๐Ÿ˜ :smirk: - "mtoohey31/cmp-fish", - "petertriho/cmp-git", - "kdheepak/cmp-latex-symbols", -- ฯ„ long live \tau - -- "dcampos/nvim-snippy", -- Adding it here does not apply opts - "dcampos/cmp-snippy", - }, - }, - { "dcampos/nvim-snippy", - opts = { - -- mappings to navigate expansion fields are merged in plugins/complete.lua - mappings = { - is = {}, - nx = { - ['sx'] = 'cut_text', - }, - }, - } - }, - { "onsails/lspkind.nvim", - }, - { "https://git.sr.ht/~whynothugo/lsp_lines.nvim", - config = function() - require("lsp_lines").setup() - - vim.diagnostic.config({ virtual_lines = false }) - vim.api.nvim_create_autocmd("BufReadPost", { - pattern = "*", - callback = function() - vim.b.lsp_lines_enabled = false - end - }) - - vim.keymap.set("n", "ll", function() - require("lsp_lines").toggle() - -- Disable virtual_text since it's redundant due to lsp_lines. - if vim.b.lsp_lines_enabled then - -- IT was enabled, now it's disabled. - vim.diagnostic.config({ virtual_text = true }) - vim.b.lsp_lines_enabled = false - else - vim.diagnostic.config({ virtual_text = false }) - vim.b.lsp_lines_enabled = true - end - end , {desc = "Toggle Lsp Lines"}) - end, - }, - { "xeluxee/competitest.nvim", - dependencies = "MunifTanjim/nui.nvim", - config = function() require("plugins/competitest") end, - }, - { "nvim-neorg/neorg", - -- Org... and better? I sure hope so! - cmd = "Neorg", - ft = "norg", - build = ":Neorg sync-parsers", - dependencies = { "nvim-lua/plenary.nvim", "nvim-treesitter/nvim-treesitter" }, - config = function() - require("neorg").setup { - load = { - ["core.defaults"] = {}, -- Loads default behaviour - ["core.concealer"] = { - config = { - folds = true, - } - }, - ["core.dirman"] = { -- Manages Neorg workspaces - config = { - workspaces = { neorg = "~/neorg" }, - default_workspace = "neorg" - }, - }, - ["core.completion"] = { - config = { - engine = "nvim-cmp", - name = "๎ด€ " - }, - }, - ["core.highlights"] = { - config = { - highlights = { - tags = { - ranged_verbatim = { - parameters = "guifg=#9ca3af", - begin = "guifg=#9ca3af", - ["end"] = "guifg=#9ca3af", - name = { - word = "guifg=#9ca3af", - }, - }, - }, - }, - }, - }, - }, - } - end, - }, - { "folke/which-key.nvim", - -- The most mind blowing steal from ever - - event = "VeryLazy", - enabled = false, - init = function() - vim.o.timeout = true - vim.o.timeoutlen = 600 - end, - opts = { - plugins = { - marks = true, -- shows a list of your marks on ' and ` - registers = false, -- Slightly annoying - -- Although it reminds me of my calculator giving me a similar preview - -- of stored variables upon the "recall" key haha - spelling = { - enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions - suggestions = 20, -- how many suggestions should be shown in the list? - }, - presets = { - operators = true, -- adds help for operators like d, y, ... - motions = true, -- adds help for motions - text_objects = true, -- help for text objects triggered after entering an operator - windows = true, -- default bindings on - nav = true, -- misc bindings to work with windows - z = true, -- bindings for folds, spelling and others prefixed with z - g = true, -- bindings for prefixed with g - }, - }, - -- add operators that will trigger motion and text object completion - -- to enable all native operators, set the preset / operators plugin above - operators = { gc = "Comments" }, - key_labels = { - -- [""] = "SPC", - -- [""] = "RET", - -- [""] = "TAB", - }, - motions = { count = true, }, - icons = { - breadcrumb = "ยป", -- symbol used in the command line area that shows your active key combo - separator = "=", -- symbol used between a key and it's label - group = "+", -- symbol prepended to a group - }, - popup_mappings = { - scroll_down = "", -- binding to scroll down inside the popup - scroll_up = "", -- binding to scroll up inside the popup - }, - window = { - border = "shadow", -- none, single, double, shadow - position = "bottom", -- bottom, top - margin = { 0, 0, 0, 0 }, -- extra window margin [top, right, bottom, left]. When between 0 and 1, will be treated as a percentage of the screen size. - padding = { 0, 1, 0, 1 }, -- extra window padding [top, right, bottom, left] - winblend = 0, -- value between 0-100 0 for fully opaque and 100 for fully transparent - zindex = 1000, -- positive value to position WhichKey above other floating windows. - }, - layout = { - height = { min = 4, max = 20 }, -- min and max height of the columns - width = { min = 20, max = 50 }, -- min and max width of the columns - spacing = 2, -- spacing between columns - align = "left", -- align columns left, center or right - }, - ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label - -- hide mapping boilerplate - hidden = { "", "", "", "", "^:", "^ ", "^call ", "^lua " }, - show_help = true, -- show a help message in the command line for using WhichKey - show_keys = true, -- show the currently pressed key and its label as a message in the command line - triggers = "auto", -- automatically setup triggers - -- triggers = {""} -- or specifiy a list manually - -- list of triggers, where WhichKey should not wait for timeoutlen and show immediately - triggers_nowait = { - -- marks - "`", - "'", - "g`", - "g'", - -- registers - -- '"', - -- "", - -- spelling - "z=", - }, - triggers_blacklist = { - -- list of mode / prefixes that should never be hooked by WhichKey - -- this is mostly relevant for keymaps that start with a native binding - i = { "j", "k" }, - v = { "j", "k" }, - }, - -- disable the WhichKey popup for certain buf types and file types. - -- Disabled by default for Telescope - disable = { - buftypes = {}, - filetypes = {}, - }, - } - }, - "folke/neodev.nvim", - -- TODO: check nvim version - { "mfussenegger/nvim-dap", - config = function() require("plugins/dap") end, - }, - { "theHamsta/nvim-dap-virtual-text", - dependencies = {"mfussenegger/nvim-dap"}, - }, - { "rcarriga/nvim-dap-ui", - dependencies = {"mfussenegger/nvim-dap"}, - }, -} diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua new file mode 100644 index 0000000..736c3f8 --- /dev/null +++ b/.config/nvim/lua/plugins.lua @@ -0,0 +1,165 @@ +-- Used by Lazy.nvim in loadlazy.lua +-- +-- These are plugins that don't have their own dedicated config +-- file in plugins/ +return { + -- Use 'gf' with dot.separated.modules in lua. + -- Put the cursor at the argument in "require" and press "gf" to see the effect. + "sam4llis/nvim-lua-gf", + + { "nvim-tree/nvim-tree.lua", + cmd = {"NvimTreeOpen", "NvimTreeToggle", "NvimTreeFindFile", "NvimTreeFocus", "NvimTreeFindFileToggle"}, + keys = { { "e", "NvimTreeToggle", desc = ":NvimTreeToggle" } }, + config = function () + require("nvim-tree").setup { + view = { width = 20, }, + -- renderer = { group_empty = true, }, + -- filters = { dotfiles = true, }, + } + end, + }, + -- "jreybert/vimagit", -- emacs' magit โœจ + -- So anyways apparently almost every plugin that was popular in vim had to + -- be rewritten in lua. + { "NeogitOrg/neogit", + cmd = "Neogit", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope.nvim", + "sindrets/diffview.nvim", -- optional + -- "ibhagwan/fzf-lua", -- optional + }, + opts = { + integrations = { + telescope = true, + -- The diffview integration enables the diff popup. + diffview = true, + }, + } + }, + -- "tpope/vim-surround", -- quoting and parenthesizing manipulation + -- "tpope/vim-commentary", -- I'd rather not clog mappings with nerd commentor + -- Sorry tpope! It's more convenient to configure in lua than in vim... + -- * nvim-comment is lighter but doesn't, AFAIK, support block comments. + -- * mini.surround let's you add quotes easily (defined above) + { "numToStr/Comment.nvim", config = true }, + { "lewis6991/gitsigns.nvim", + -- "Be the diff you wish see in the gutter" -- Doom Emacs + -- Also see comparison with vim-gitgutter: + -- https://github.com/lewis6991/gitsigns.nvim?tab=readme-ov-file#comparison-with-vim-gitgutter + enabled = vim.fn.has("nvim-0.8") == 1, + opts = { + -- No way โค๏ธ + yadm = { enable = true }, + }, + }, + { "folke/trouble.nvim", + enabled = vim.fn.has("nvim-0.7.2") == 1, + cmd = "Trouble", + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = { + signs = { + -- icons / text used for a diagnostic + error = "E:", + warning = "W:", + hint = "H:", + information = "I:", + other = "X:", + }, + fold_open = "๏‘ผ", -- icon used for open folds + fold_closed = "๏‘ ", -- icon used for closed folds + }, + }, + -- Full disclosure: I'm the maintainer of outline.nvim (see plugins/outline), + -- just trying out aerial for fun :) + { 'stevearc/aerial.nvim', + enabled = true, + cmd = { "AerialOpen", "AerialToggle", "AerialNavToggle" }, + opts = { + -- Doesn't seem to work + filter_kind = false, + }, + -- Optional dependencies + dependencies = { + "nvim-treesitter/nvim-treesitter", + "nvim-tree/nvim-web-devicons" + }, + }, + -- "bling/vim-bufferline", -- I prefer this over taking over the tabline space thanks + -- Fair well vim-bufferline! You have served my vim and nvim experience well. + -- I've since decided to set cmdheight to 1 and put the buffers in my status + -- bar :') + -- See archived/statusline.lua. + -- Now I've abandoned the notion of having to know opened buffers all the + -- time. If I need it I can use bp/bn/bd and telescope buffers. + -- TODO: Check if this is still needed + "tpope/vim-endwise", -- Add those 'endif'/'fi'/'done' + { "moll/vim-bbye", -- smart buffer closer + config = function() + local function d(s) return { desc = s } end + local map = vim.keymap.set + map("n", "bd", "Bdelete", d"Bdelete") + map("n", "bx", "Bwipeout", d"like bd but removes from jumplist") + end + }, + { "carbon-steel/detour.nvim" }, + { "tiagovla/scope.nvim", + -- Tab-local buffer list. + -- Similar to beframe (by prot) from emacs! + config = true + }, + { "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = { + highlight = { + multiline = false, + -- The 3 lines below tunes down the coloring of the highlights. The + -- color schemes and treesitter nowdays are already way too vibrant for + -- my liking, and for someone who litters todo/fixme way too much + -- everywhere, adding *wide* *bg* highlighting to them is just WAY too + -- much eye candy. + before = "", + keyword = "fg", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. + after = "", -- "fg" or "bg" or empty + -- Require only one space before keyword so we don't match keywords + -- in the middle of comments. + pattern = [[\s<(KEYWORDS)\s*]], -- (vim regex) + comments_only = true, -- uses treesitter to match keywords in comments only + max_line_len = 200, + exclude = {}, -- filetypes + }, + } + }, + { "lukas-reineke/indent-blankline.nvim", name = "ibl", + -- https://github.com/lukas-reineke/indent-blankline.nvim/wiki/Migrate-to-version-3 + -- Not documented but it appears new version requires a higher version of nvim. + -- Upgraded to nvim 0.9.4 and the new version worked with showing context + -- without needing treesitter ๐ŸŽ‰ + main = vim.fn.has("nvim-0.9") == 1 and "ibl", + version = vim.fn.has("nvim-0.9") == 1 and "*" or "2.20.8", + pin = vim.fn.has("nvim-0.9") == 0, + opts = { + exclude = { + filetypes = { + "help", + "NvimTree", + "Trouble", + "trouble", + "lazy", + "mason", + "notify", + "toggleterm", + "lazyterm", + "Outline", + }, + }, + }, + }, + + { "windwp/nvim-ts-autotag", + -- Automatically add closing tags for HTML and JSX + ft = { "html", "tsx", "jsx" }, + opts = {}, + }, + "folke/neodev.nvim", +} diff --git a/.config/nvim/lua/plugins/autopair.lua b/.config/nvim/lua/plugins/autopair.lua index b202ba2..16bc146 100644 --- a/.config/nvim/lua/plugins/autopair.lua +++ b/.config/nvim/lua/plugins/autopair.lua @@ -1,5 +1,24 @@ +local function config() require('nvim-autopairs').setup({ enable_check_bracket_line = false, -- Don't close pair when next char is a closing pair ignored_next_char = "[%w%.]", -- will ignore alphanumeric and `.` symbol fast_wrap = {}, }) +end + +-- This plugin below is really good, but whenever I'm on a commented line, +-- press o, press backspace, the line below is joined up above. You won't +-- believe how long it took me to debug this problem and finally realize it's +-- because of this plugin. +-- "jiangmiao/auto-pairs", +-- +-- So now I'm using this instead: +-- windwp/nvim-autopairs - extremely customizable, written in lua - +-- integrates wth hrsh7th/nvim-cmp +-- For nvim < 0.5, use: townk/vim-autoclose +return { + "windwp/nvim-autopairs", + commit = vim.fn.has("nvim-0.7") == 1 and "b7672cd", + config = config, + event = "InsertEnter", +} diff --git a/.config/nvim/lua/plugins/competitest.lua b/.config/nvim/lua/plugins/competitest.lua index 4f297b7..46b5d29 100644 --- a/.config/nvim/lua/plugins/competitest.lua +++ b/.config/nvim/lua/plugins/competitest.lua @@ -1,3 +1,4 @@ +local function config() vim.api.nvim_create_autocmd( { "FileType" }, { pattern = "CompetiTest", @@ -208,3 +209,11 @@ require('competitest').setup { open_received_contests = true, replace_received_testcases = false, } +end + +return { + "xeluxee/competitest.nvim", + dependencies = "MunifTanjim/nui.nvim", + config = config, + ft = "cpp", +} diff --git a/.config/nvim/lua/plugins/complete.lua b/.config/nvim/lua/plugins/complete.lua index 573dd00..166634b 100644 --- a/.config/nvim/lua/plugins/complete.lua +++ b/.config/nvim/lua/plugins/complete.lua @@ -1,4 +1,5 @@ -- https://github.com/hrsh7th/nvim-cmp +local function config() local has_words_before = function() unpack = unpack or table.unpack local line, col = unpack(vim.api.nvim_win_get_cursor(0)) @@ -207,3 +208,35 @@ cmp.event:on( function _G.CmpDisable() cmp.setup.buffer { enabled = false } end +end + +return { + { "hrsh7th/nvim-cmp", + event = { "InsertEnter", "CmdlineEnter" }, + config = config, + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", -- File paths + "hrsh7th/cmp-cmdline", -- Fire your way through the neovim cmd line + "hrsh7th/cmp-calc", -- Somehwat useful.. But emacs M-x calc FTW! + "hrsh7th/cmp-emoji", -- ๐Ÿ˜ :smirk: + "mtoohey31/cmp-fish", + "petertriho/cmp-git", + "kdheepak/cmp-latex-symbols", -- ฯ„ long live \tau + -- "dcampos/nvim-snippy", -- Adding it here does not apply opts + "dcampos/cmp-snippy", + }, + }, + { "dcampos/nvim-snippy", + event = "InsertEnter", + opts = { + -- mappings to navigate expansion fields are merged in plugins/complete.lua + mappings = { + is = {}, + nx = { + ['sx'] = 'cut_text', + }, + }, + } + }, +} diff --git a/.config/nvim/lua/plugins/dap.lua b/.config/nvim/lua/plugins/dap.lua index b3b8cd3..be3cf64 100644 --- a/.config/nvim/lua/plugins/dap.lua +++ b/.config/nvim/lua/plugins/dap.lua @@ -1,3 +1,4 @@ +local function config() local dap = require('dap') dap.adapters.python = function(cb, config) if config.request == 'attach' then @@ -79,3 +80,23 @@ vim.api.nvim_create_user_command( nargs = '?', complete = function() return {'sidebar', 'tray'} end, }) +end + +return { + -- TODO: check nvim version + { "mfussenegger/nvim-dap", + config = config, + lazy = true, + cmd = {"DapToggleBreakpoint", "DapContinue"}, + }, + { "theHamsta/nvim-dap-virtual-text", + lazy = true, + cmd = {"DapToggleBreakpoint", "DapContinue"}, + dependencies = {"mfussenegger/nvim-dap"}, + }, + { "rcarriga/nvim-dap-ui", + lazy = true, + cmd = {"DapToggleBreakpoint", "DapContinue"}, + dependencies = {"mfussenegger/nvim-dap"}, + }, +} diff --git a/.config/nvim/lua/plugins/ft.lua b/.config/nvim/lua/plugins/ft.lua new file mode 100644 index 0000000..b14d577 --- /dev/null +++ b/.config/nvim/lua/plugins/ft.lua @@ -0,0 +1,35 @@ +return { + --- File type, syntax, language helper plugins --- + { url = "https://git.sr.ht/~torresjrjr/gemini.vim", ft = "gemini" }, + { "cespare/vim-toml", ft = "toml" }, + { "blankname/vim-fish", ft = "fish", + config = function () + vim.opt_local.shiftwidth = 4 + vim.opt_local.textwidth = 79 + vim.opt_local.foldmethod = "expr" + vim.opt_local.expandtab = true + vim.opt_local.tabstop = 4 + end, + }, + { url = "https://git.rawtext.club/slope-lang/slope-vim-syntax", + ft = "slope", + enabled = false; + }, + { "mzlogin/vim-markdown-toc", ft = "markdown", + }, + { dir = "~/projects/markdown-toc.nvim", ft = "markdown", + opts = { + -- fences = false, + toc_list = { + -- indent_size = function() return vim.bo.shiftwidth end, + } + }, + }, + { "leafo/moonscript-vim", ft = "moon", + config = function () + vim.opt_local.tabstop = 2 + vim.opt_local.softtabstop = 2 + vim.opt_local.shiftwidth = 2 + end + }, +} diff --git a/.config/nvim/lua/plugins/icons.lua b/.config/nvim/lua/plugins/icons.lua index dcb8f15..fea662b 100644 --- a/.config/nvim/lua/plugins/icons.lua +++ b/.config/nvim/lua/plugins/icons.lua @@ -3,6 +3,7 @@ -- Used by lazy, nvim-tree, and others -- https://github.com/nvim-tree/nvim-web-devicons +local function config() require'nvim-web-devicons'.setup { -- your personnal icons can go here (to override) -- you can specify color or cterm_color instead of specifying both of them @@ -38,3 +39,12 @@ require'nvim-web-devicons'.setup { } }, } +end + +return { + "nvim-tree/nvim-web-devicons", lazy = true, + enabled = vim.fn.has("nvim-0.7") == 1, + config = function() require('plugins/icons') end, + pin = true, + commit = 'cde67b5d5427daeecfd7c77cf02ded23a26980bb', +} diff --git a/.config/nvim/lua/plugins/incline.lua b/.config/nvim/lua/plugins/incline.lua index 6ed9177..94791a2 100644 --- a/.config/nvim/lua/plugins/incline.lua +++ b/.config/nvim/lua/plugins/incline.lua @@ -1,3 +1,5 @@ +local function config() + local cp = require('nvim-tundra.palette.arctic') local a = vim.api local f = vim.fn @@ -144,3 +146,9 @@ require('incline').setup { zindex = 50 } } +end + +return { + "b0o/incline.nvim", + config = config, +} diff --git a/.config/nvim/lua/plugins/linting.lua b/.config/nvim/lua/plugins/linting.lua index 50bfc3b..e11b01a 100644 --- a/.config/nvim/lua/plugins/linting.lua +++ b/.config/nvim/lua/plugins/linting.lua @@ -1,4 +1,6 @@ -- https://github.com/errata-ai/vale/releases + +local function config() local lint = require('lint') lint.linters_by_ft = { markdown = {'codespell'}, @@ -10,3 +12,11 @@ lint.linters_by_ft = { } vim.api.nvim_create_autocmd("BufWritePost", { pattern = "*", callback = function() lint.try_lint() end }) +end + +return { + "mfussenegger/nvim-lint", + enabled = vim.fn.has("nvim-0.6") == 1, + config = config, + event = {"BufWritePost", "InsertEnter"} +} diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 4a6de20..2e6a2da 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -1,3 +1,4 @@ +local function config() -- IMPORTANT: make sure to setup neodev BEFORE lspconfig require("neodev").setup({ setup_jsonls = false, @@ -137,3 +138,74 @@ lspconfig.lua_ls.setup { }, }, } +end + +return { + { "neovim/nvim-lspconfig", + config = config, + ft = {"python", "go", "markdown", "lua", "vim", "bash"}, + }, + { "ray-x/lsp_signature.nvim", + event = "VeryLazy", + opts = { + doc_lines = 10, + -- set to 0 if you DO NOT want any API comments be shown + -- This setting only take effect in insert mode, it does not affect signature help in normal + -- mode, 10 by default + max_height = 12, + max_width = 80, + noice = false, + wrap = true, + floating_window = false, + floating_window_above_cur_line = true, + floating_window_off_x = 1, + floating_window_off_y = 0, -- -2 move window up 2 lines; 2 move down 2 lines + -- can be either number or function, see examples + close_timeout = 4000, + fix_pos = false, -- don't auto-close the floating window all parameters finished + hint_enable = true, -- virtual hint + hint_prefix = "๎ชซ ", + hint_scheme = "String", + hint_inline = function() return vim.fn.has('nvim-0.10') == 1 end, + hi_parameter = "LspSignatureActiveParameter", + handler_opts = { border = "rounded" }, + always_trigger = false, + auto_close_after = nil, + extra_trigger_chars = {","}, + zindex = 200, + padding = '', + transparency = nil, -- 1~100 + timer_interval = 200, -- lower to reduce latency + toggle_key = '', -- toggle floating window key (must set below to true) + toggle_key_flip_floatwin_setting = true, + select_signature_key = '', -- next signature for (eg) overloads + }, + }, + { "onsails/lspkind.nvim" }, + { "https://git.sr.ht/~whynothugo/lsp_lines.nvim", + config = function() + require("lsp_lines").setup() + + vim.diagnostic.config({ virtual_lines = false }) + vim.api.nvim_create_autocmd("BufReadPost", { + pattern = "*", + callback = function() + vim.b.lsp_lines_enabled = false + end + }) + + vim.keymap.set("n", "ll", function() + require("lsp_lines").toggle() + -- Disable virtual_text since it's redundant due to lsp_lines. + if vim.b.lsp_lines_enabled then + -- IT was enabled, now it's disabled. + vim.diagnostic.config({ virtual_text = true }) + vim.b.lsp_lines_enabled = false + else + vim.diagnostic.config({ virtual_text = false }) + vim.b.lsp_lines_enabled = true + end + end , {desc = "Toggle Lsp Lines"}) + end, + }, +} diff --git a/.config/nvim/lua/plugins/mini.lua b/.config/nvim/lua/plugins/mini.lua new file mode 100644 index 0000000..b4b2a62 --- /dev/null +++ b/.config/nvim/lua/plugins/mini.lua @@ -0,0 +1,130 @@ +-- Ordered in discovery date of these high-quality, self-contained and +-- minimalist plugins. Finding myself using switching to more of more of +-- ones from the library and eventually found the need to extract it to a +-- dedicated file. + +return { + { "echasnovski/mini.files", + -- Neat popout window to browse dirs and manipulate within the editor! + cmd = "MiniFiles", + keys = { { "E", "MiniFiles", desc = ":MiniFiles" } }, + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require('mini.files').setup{} + vim.api.nvim_create_user_command('MiniFiles', function() + require('mini.files').open(nil, false) + end, { desc = ":lua MiniFiles.open()" }) + end, + }, + { "echasnovski/mini.surround", version = '*', + opts = { + -- Duration (in ms) of highlight when calling `MiniSurround.highlight()` + highlight_duration = 500, + -- Module mappings. Use `''` (empty string) to disable one. + mappings = { + add = 'sa', + delete = 'ds', -- Using "ds" for muscle memory compat + find = 'sf', -- Find surrounding (to the right) + find_left = 'sF', -- Find surrounding (to the left) + highlight = 'sh', -- Highlight surrounding + replace = 'cs', -- Replace surrounding -- muscle memory compat + update_n_lines = 'sn', -- Update `n_lines` + + suffix_last = 'l', -- Suffix to search with "prev" method + suffix_next = 'n', -- Suffix to search with "next" method + }, + -- Number of lines within which surrounding is searched + n_lines = 20, + -- Whether to respect selection type: + -- - Place surroundings on separate lines in linewise mode. + -- - Place surroundings on each line in blockwise mode. + respect_selection_type = false, + -- How to search for surrounding (first inside current line, then inside + -- neighborhood). One of 'cover', 'cover_or_next', 'cover_or_prev', + -- 'cover_or_nearest', 'next', 'prev', 'nearest'. For more details, + -- see `:h MiniSurround.config`. + search_method = 'cover', + -- Whether to disable showing non-error feedback + silent = false, + }, + }, + { "echasnovski/mini.splitjoin", + opts = { + mappings = { -- both n/v modes + toggle = 'gS', + split = '', + join = '', + }, + detect = { + -- Array of Lua patterns to detect region with arguments. + -- Default: { '%b()', '%b[]', '%b{}' } + brackets = nil, + -- String Lua pattern defining argument separator + separator = ',', + -- Array of Lua patterns for sub-regions to exclude separators from. + -- Enables correct detection in presence of nested brackets and quotes. + -- Default: { '%b()', '%b[]', '%b{}', '%b""', "%b''" } + exclude_regions = nil, + }, + -- Split options + split = { + hooks_pre = {}, + hooks_post = {}, + }, + -- Join options + join = { + hooks_pre = {}, + hooks_post = {}, + }, + } + }, + { "echasnovski/mini.trailspace", + config = true, + }, + { "echasnovski/mini.clue", + enabled = false, + config = function() + local miniclue = require "mini.clue" + miniclue.setup { + triggers = { + { mode = 'n', keys = '' }, + { mode = 'x', keys = '' }, + { mode = 'n', keys = 'g' }, + { mode = 'x', keys = 'g' }, + -- Marks + { mode = 'n', keys = "'" }, + { mode = 'n', keys = '`' }, + { mode = 'x', keys = "'" }, + { mode = 'x', keys = '`' }, + -- Registers + { mode = 'n', keys = '"' }, + { mode = 'x', keys = '"' }, + { mode = 'i', keys = '' }, + { mode = 'c', keys = '' }, + + { mode = 'n', keys = '' }, + { mode = 'n', keys = 'z' }, + { mode = 'x', keys = 'z' }, + }, + + clues = { + -- Enhance this by adding descriptions for mapping groups + miniclue.gen_clues.builtin_completion(), + miniclue.gen_clues.g(), + miniclue.gen_clues.marks(), + miniclue.gen_clues.registers(), + miniclue.gen_clues.windows(), + miniclue.gen_clues.z(), + }, + window = { + config = { + width = 50, + }, + delay = 800, + scroll_down = '', + scroll_up = '', + }, + } + end + } +} diff --git a/.config/nvim/lua/plugins/norg.lua b/.config/nvim/lua/plugins/norg.lua new file mode 100644 index 0000000..47fd310 --- /dev/null +++ b/.config/nvim/lua/plugins/norg.lua @@ -0,0 +1,49 @@ +-- Org... and better? I sure hope so! + +return { + "nvim-neorg/neorg", + cmd = "Neorg", + ft = "norg", + build = ":Neorg sync-parsers", + dependencies = { "nvim-lua/plenary.nvim", "nvim-treesitter/nvim-treesitter" }, + config = function() + require("neorg").setup { + load = { + ["core.defaults"] = {}, -- Loads default behaviour + ["core.concealer"] = { + config = { + folds = true, + } + }, + ["core.dirman"] = { -- Manages Neorg workspaces + config = { + workspaces = { neorg = "~/neorg" }, + default_workspace = "neorg" + }, + }, + ["core.completion"] = { + config = { + engine = "nvim-cmp", + name = "๎ด€ " + }, + }, + ["core.highlights"] = { + config = { + highlights = { + tags = { + ranged_verbatim = { + parameters = "guifg=#9ca3af", + begin = "guifg=#9ca3af", + ["end"] = "guifg=#9ca3af", + name = { + word = "guifg=#9ca3af", + }, + }, + }, + }, + }, + }, + }, + } + end, +} diff --git a/.config/nvim/lua/plugins/outline.lua b/.config/nvim/lua/plugins/outline.lua index 01e867a..bea4e99 100644 --- a/.config/nvim/lua/plugins/outline.lua +++ b/.config/nvim/lua/plugins/outline.lua @@ -1,24 +1,55 @@ -require('outline').setup { - preview_window = { - border = 'rounded', - open_hover_on_preview = false, +-- https://github.com/simrat39/symbols-outline.nvim +-- Switched to this from tagbar because it does not require exctags, and it +-- lists the items in order as defined in source code. +-- Then I ended up forking it... +-- https://github.com/hedyhli/outline.nvim + +return { + dir = "~/projects/outline.nvim", + enabled = vim.fn.has("nvim-0.7") == 1, + cmd = { "Outline", "OutlineOpen" }, + keys = { + { "tt", "Outline", desc = "Toggle outline window" }, + { "t", "Outline!", desc = "Toggle outline window without focus" }, + { "tf", "OutlineFollow", desc = "Focus & follow outline window" }, }, - symbol_folding = { - autofold_depth = 1, - auto_unfold_hover = true, - }, - guides = { - enabled = true, - }, - outline_window = { - show_cursorline = true, - hide_cursor = true, - winhl = "OutlineDetails:LineNr,OutlineLineno:LineNr,OutlineGuides:Comment", - }, - keymaps = { - close = "q", - }, - symbols = { - icon_source = "lspkind", + opts = { + preview_window = { + border = 'rounded', + open_hover_on_preview = false, + }, + symbol_folding = { + -- Auto fold all but current hover + autofold_depth = 1, + auto_unfold_hover = true, + }, + guides = { + -- Keep only guides that indicate siblings that might span multiple lines (vertical) + markers = { + middle = ' ', + bottom = ' ', + } + }, + outline_window = { + show_cursorline = true, + -- Beautiful, but not very good in indicating window focus (I don't use a + -- statusline), plus at the time of writing preview window breaks this + -- feature... But still beautiful nonetheless! + hide_cursor = true, + winhl = "OutlineDetails:LineNr,OutlineLineno:LineNr,OutlineGuides:Comment", + }, + symbols = { + icon_fetcher = function(k) + local buf = vim.api.nvim_win_get_buf(require('outline').state.code_win) + local ft = vim.api.nvim_buf_get_option(buf, "ft") + -- There can only be kind String in markdown so... let's not have the + -- eye candy here + if ft == 'markdown' and k == 'String' then + return "" + end + return false + end, + icon_source = "lspkind", + }, }, } diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index a15e459..b2137ad 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -1,14 +1,8 @@ +local function config() + local function d(s) return { desc = s } end local function map(...) vim.keymap.set(...) end -map("n", "ff", "Telescope find_files", d"Telescope find_files") -map("n", "fr", "Telescope oldfiles", d"Telescope oldfiles") -map("n", "fg", "Telescope live_grep", d"Telescope live_grep") -map("n", "fb", "Telescope buffers", d"Telescope buffers") -map("n", "bb", "Telescope buffers", d"Telescope buffers") -map("n", "fh", "Telescope help_tags", d"Telescope help_tags") -map("n", "fR", "Telescope registers", d"Telescope registers (also see rg)") - -- Go to dir of selected entry local goto_dir = function(prompt_bufnr) local selection = require("telescope.actions.state").get_selected_entry() @@ -65,6 +59,14 @@ local reprompt_from_git_root = function(picker, prompt_bufnr) end end +map("n", "ff", "Telescope find_files", d"Telescope find_files") +map("n", "fr", "Telescope oldfiles", d"Telescope oldfiles") +map("n", "fg", "Telescope live_grep", d"Telescope live_grep") +map("n", "fb", "Telescope buffers", d"Telescope buffers") +map("n", "bb", "Telescope buffers", d"Telescope buffers") +map("n", "fh", "Telescope help_tags", d"Telescope help_tags") +map("n", "fR", "Telescope registers", d"Telescope registers (also see rg)") + require('telescope').setup({ defaults = { -- layout_config = { @@ -104,3 +106,14 @@ require('telescope').setup({ }, }) require('telescope').load_extension('fzf') +end + +return { + 'nvim-telescope/telescope.nvim', tag = '0.1.4', + enabled = vim.fn.has("nvim-0.9") == 1, + dependencies = { + 'nvim-lua/plenary.nvim', + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, + }, + config = config, +} diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index deb7662..a7a45c2 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -1,3 +1,4 @@ +local function config() local configs = require("nvim-treesitter.configs") configs.setup({ ensure_installed = { @@ -7,33 +8,33 @@ configs.setup({ highlight = { enable = true }, indent = { enable = true }, -- Textobjects, see below as well - -- textobjects = { - -- select = { - -- enable = true, - -- -- Automatically jump forward to textobj, similar to targets.vim - -- lookahead = true, - -- keymaps = { - -- -- You can use the capture groups defined in textobjects.scm - -- ["af"] = { query = "@function.outer", desc = "Around function" }, - -- ["if"] = { query = "@function.inner", desc = "Inside function" }, - -- ["ac"] = { query = "@class.outer", desc = "Around class" }, - -- ["ic"] = { query = "@class.inner", desc = "Inside class" }, - -- -- You can also use captures from other query groups like `locals.scm` - -- ["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" }, - -- }, - -- include_surrounding_whitespace = false, - -- }, - -- move = { - -- enable = true, - -- set_jumps = true, - -- goto_next = { - -- ["]p"] = "@parameter.outer", - -- }, - -- goto_previous = { - -- ["[p"] = "@parameter.outer", - -- }, - -- } - -- }, + textobjects = { + select = { + enable = true, + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["af"] = { query = "@function.outer", desc = "Around function" }, + ["if"] = { query = "@function.inner", desc = "Inside function" }, + ["ac"] = { query = "@class.outer", desc = "Around class" }, + ["ic"] = { query = "@class.inner", desc = "Inside class" }, + -- You can also use captures from other query groups like `locals.scm` + ["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" }, + }, + include_surrounding_whitespace = false, + }, + move = { + enable = true, + set_jumps = true, + goto_next = { + ["]p"] = "@parameter.outer", + }, + goto_previous = { + ["[p"] = "@parameter.outer", + }, + } + }, }) -- TS context @@ -89,3 +90,23 @@ vim.keymap.set({ "n", "x", "o" }, "f", ts_repeat_move.builtin_f) vim.keymap.set({ "n", "x", "o" }, "F", ts_repeat_move.builtin_F) vim.keymap.set({ "n", "x", "o" }, "t", ts_repeat_move.builtin_t) vim.keymap.set({ "n", "x", "o" }, "T", ts_repeat_move.builtin_T) +end + +return { + { "nvim-treesitter/nvim-treesitter", + enabled = vim.fn.has('nvim-0.9') == 1, + build = ":TSUpdate", + version = false, + event = "VeryLazy", + cmd = { "TSUpdateSync", "TSUpdate", "TSInstall", "Inspect", "InspectTree" }, + config = config, + }, + -- Setting these as dependencies of nvim-treesitter causes error of invalid + -- query. + { "nvim-treesitter/nvim-treesitter-context", + enabled = vim.fn.has('nvim-0.9') == 1, + }, + { "nvim-treesitter/nvim-treesitter-textobjects", + enabled = vim.fn.has('nvim-0.9') == 1, + }, +} diff --git a/.config/nvim/lua/plugins/tundra.lua b/.config/nvim/lua/plugins/tundra.lua index c8f5684..a0557fa 100644 --- a/.config/nvim/lua/plugins/tundra.lua +++ b/.config/nvim/lua/plugins/tundra.lua @@ -1,3 +1,25 @@ +-- { "dracula/vim", +-- name = "dracula", lazy = false, priority = 10000, +-- config = function() vim.cmd("colorscheme dracula") end, +-- enabled = false, -- LOL I've switched to tundra semi-temporarily +-- }, +-- The thing about using dracula theme in nvim here is the annoyance of having +-- to use lua APIs to interact with something that was designed for vimscript. +-- With "modern" nvim plugins where the themes are written in 100% lua, +-- configuring everything else (such as statusline colors) reusing values +-- defined in these themes provide a much smoother, cleaner configuration. +-- +-- This is by no means a /political/ (ahem) statement suggesting my abandoning +-- of the holy dracula theme. I just, well, decided to try something new since +-- I sort of realized there is no "perfect" or "best" theme. +-- +-- After hours of blood, pain, and tears of trying to tweak dracula colors to +-- be easier on the eyes and have greater contrast, I took one look at the +-- carousel of themes from NvChad and fell in love with tundra... +-- +-- So I did find dracula.nvim, but I've already integrated tundra well. + +local function config() local s = require('nvim-tundra.stylesheet.arctic') -- See also: statusline.lua for statusline colors (which I also use tundra's @@ -46,9 +68,7 @@ require("nvim-tundra").setup { overwrite = { colors = {}, highlights = { - TreesitterContext = { bg = s.cp.gray._700 }, - -- FIXME: Line number hl doesn't work - TreesitterContextLineNumber = { fg = s.cp.gray._500, bg = s.cp.gray._700 }, + TreesitterContext = { bg = "#283343" }, Folded = { fg = s.cp.gray._400, bg = s.cp.gray._700 @@ -67,3 +87,10 @@ require("nvim-tundra").setup { vim.o.background = "dark" vim.cmd("colorscheme tundra") +end + +return { + -- Must be loaded before ibl! + "sam4llis/nvim-tundra", lazy = false, priority = 10000, + config = config, +}