From 31196f132c5486446a3a3bfb798e8dcb07295c33 Mon Sep 17 00:00:00 2001 From: Ray Andrew Date: Wed, 7 Aug 2024 20:31:24 -0500 Subject: [PATCH] change to new code --- .gitignore | 8 - .neoconf.json | 15 - .stylua.toml | 6 - after/ftplugin/latex.lua | 1 - after/ftplugin/tex.lua | 3 - after/ftplugin/text.lua | 11 - init.lua | 194 ++++++++++- lazy-lock.json | 102 +++--- lua/rayandrew/autocmds.lua | 127 -------- lua/rayandrew/commands.lua | 141 ++++++-- lua/rayandrew/filetype.lua | 53 --- lua/rayandrew/init.lua | 15 - lua/rayandrew/lazy.lua | 53 --- lua/rayandrew/neovide.lua | 5 - lua/rayandrew/plugins/editor.lua | 252 --------------- lua/rayandrew/plugins/file.lua | 217 ------------- lua/rayandrew/plugins/general.lua | 70 ---- lua/rayandrew/plugins/lsp.lua | 462 ++++++++++++++------------- lua/rayandrew/plugins/telescope.lua | 208 +++++------- lua/rayandrew/plugins/treesitter.lua | 154 ++------- lua/rayandrew/plugins/ui.lua | 142 -------- lua/rayandrew/plugins/utilities.lua | 391 ----------------------- lua/rayandrew/remap.lua | 213 ------------ lua/rayandrew/root.lua | 205 ------------ lua/rayandrew/set.lua | 94 ------ lua/rayandrew/statusline.lua | 132 -------- lua/rayandrew/theme.lua | 104 ------ lua/rayandrew/tools.lua | 104 ------ lua/rayandrew/util.lua | 265 --------------- stylua.toml | 3 - 30 files changed, 698 insertions(+), 3052 deletions(-) delete mode 100644 .gitignore delete mode 100644 .neoconf.json delete mode 100644 .stylua.toml delete mode 100644 after/ftplugin/latex.lua delete mode 100644 after/ftplugin/tex.lua delete mode 100644 after/ftplugin/text.lua delete mode 100644 lua/rayandrew/autocmds.lua delete mode 100644 lua/rayandrew/filetype.lua delete mode 100644 lua/rayandrew/init.lua delete mode 100644 lua/rayandrew/lazy.lua delete mode 100644 lua/rayandrew/neovide.lua delete mode 100644 lua/rayandrew/plugins/editor.lua delete mode 100644 lua/rayandrew/plugins/file.lua delete mode 100644 lua/rayandrew/plugins/general.lua delete mode 100644 lua/rayandrew/plugins/ui.lua delete mode 100644 lua/rayandrew/plugins/utilities.lua delete mode 100644 lua/rayandrew/remap.lua delete mode 100644 lua/rayandrew/root.lua delete mode 100644 lua/rayandrew/set.lua delete mode 100644 lua/rayandrew/statusline.lua delete mode 100644 lua/rayandrew/theme.lua delete mode 100644 lua/rayandrew/tools.lua delete mode 100644 lua/rayandrew/util.lua delete mode 100644 stylua.toml diff --git a/.gitignore b/.gitignore deleted file mode 100644 index cc5457a..0000000 --- a/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -tt.* -.tests -doc/tags -debug -.repro -foo.* -*.log -data diff --git a/.neoconf.json b/.neoconf.json deleted file mode 100644 index 31f8873..0000000 --- a/.neoconf.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "neodev": { - "library": { - "enabled": true, - "plugins": true - } - }, - "neoconf": { - "plugins": { - "lua_ls": { - "enabled": true - } - } - } -} diff --git a/.stylua.toml b/.stylua.toml deleted file mode 100644 index 6090f42..0000000 --- a/.stylua.toml +++ /dev/null @@ -1,6 +0,0 @@ -column_width = 120 -line_endings = "Unix" -indent_type = "Spaces" -indent_width = 2 -quote_style = "AutoPreferDouble" -call_parentheses = "Always" diff --git a/after/ftplugin/latex.lua b/after/ftplugin/latex.lua deleted file mode 100644 index 66003d7..0000000 --- a/after/ftplugin/latex.lua +++ /dev/null @@ -1 +0,0 @@ -vim.cmd([[runtime! ftplugin/tex.lua]]) diff --git a/after/ftplugin/tex.lua b/after/ftplugin/tex.lua deleted file mode 100644 index c0e027a..0000000 --- a/after/ftplugin/tex.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.opt_local.wrap = true -vim.opt_local.breakindent = true -vim.opt_local.breakindentopt = "shift:2" diff --git a/after/ftplugin/text.lua b/after/ftplugin/text.lua deleted file mode 100644 index 99f53e1..0000000 --- a/after/ftplugin/text.lua +++ /dev/null @@ -1,11 +0,0 @@ -vim.opt_local.tabstop = 4 -vim.opt_local.softtabstop = 4 -vim.opt_local.shiftwidth = 4 -vim.opt_local.expandtab = false -vim.opt_local.wrap = true --- disable indentation -vim.opt_local.autoindent = false -vim.opt_local.smartindent = false -vim.opt_local.cindent = false --- vim.opt_local.indentexpr = "" --- vim.opt_local.paste = true diff --git a/init.lua b/init.lua index dbf763f..dde09e1 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,193 @@ -local ray = require("rayandrew") +-- Set as the leader key +-- See `:help mapleader` +-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' -ray.setup() +-- Set to true if you have a Nerd Font installed and selected in the terminal +vim.g.have_nerd_font = true + +-- [[ Setting options ]] +-- See `:help vim.opt` +-- NOTE: You can change these options as you wish! +-- For more options, you can see `:help option-list` + +vim.opt.number = true +vim.opt.relativenumber = true + +-- Enable mouse mode, can be useful for resizing splits for example! +vim.opt.mouse = 'a' + +-- Don't show the mode, since it's already in the status line +vim.opt.showmode = false + +-- Sync clipboard between OS and Neovim. +-- Schedule the setting after `UiEnter` because it can increase startup-time. +-- Remove this option if you want your OS clipboard to remain independent. +-- See `:help 'clipboard'` +vim.schedule(function() + vim.opt.clipboard = 'unnamedplus' +end) + +-- Enable break indent +vim.opt.breakindent = true + +-- Save undo history +vim.opt.undofile = true + +-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term +vim.opt.ignorecase = true +vim.opt.smartcase = true + +-- Keep signcolumn on by default +vim.opt.signcolumn = 'yes' + +-- Decrease update time +vim.opt.updatetime = 250 + +-- Decrease mapped sequence wait time +-- Displays which-key popup sooner +vim.opt.timeoutlen = 300 + +-- Configure how new splits should be opened +vim.opt.splitright = true +vim.opt.splitbelow = true + +-- Sets how neovim will display certain whitespace characters in the editor. +-- See `:help 'list'` +-- and `:help 'listchars'` +vim.opt.list = true +vim.opt.listchars = { tab = 'ยป ', trail = 'ยท', nbsp = 'โฃ' } + +-- Preview substitutions live, as you type! +vim.opt.inccommand = 'split' + +-- Show which line your cursor is on +vim.opt.cursorline = true + +-- Minimal number of screen lines to keep above and below the cursor. +-- vim.opt.scrolloff = 10 + +-- [[ Basic Keymaps ]] +-- See `:help vim.keymap.set()` + +-- Clear highlights on search when pressing in normal mode +-- See `:help hlsearch` +vim.keymap.set('n', '', 'nohlsearch') + +-- Diagnostic keymaps +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) + +-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier +-- for people to discover. Otherwise, you normally need to press , which +-- is not what someone will guess without a bit more experience. +-- +-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping +-- or just use to exit terminal mode +vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) + +-- [[ Basic Autocommands ]] +-- See `:help lua-guide-autocommands` + +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.highlight.on_yank()` +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) + +-- [[ Install `lazy.nvim` plugin manager ]] +-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info +local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +if not vim.uv.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) + +-- [[ Configure and install plugins ]] +require('lazy').setup({ + 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically + + { -- Useful plugin to show you pending keybinds. + 'folke/which-key.nvim', + event = 'VimEnter', -- Sets the loading event to 'VimEnter' + config = function() -- This is the function that runs, AFTER loading + require('which-key').setup() + + -- Document existing key chains + require('which-key').add { + { 'c', group = '[C]ode' }, + { 'd', group = '[D]ocument' }, + { 'r', group = '[R]ename' }, + { 's', group = '[S]earch' }, + { 'w', group = '[W]orkspace' }, + { 't', group = '[T]oggle' }, + { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + } + end, + }, + + -- Highlight todo, notes, etc in comments + { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, + + { import = 'rayandrew.plugins' }, +}, { + checker = { + enabled = true, + notify = false, + frequency = 3600 * 12, + }, + change_detection = { + enabled = true, + notify = false, + }, + ui = { + -- If you are using a Nerd Font: set icons to an empty table which will use the + -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table + icons = vim.g.have_nerd_font and {} or { + cmd = 'โŒ˜', + config = '๐Ÿ› ', + event = '๐Ÿ“…', + ft = '๐Ÿ“‚', + init = 'โš™', + keys = '๐Ÿ—', + plugin = '๐Ÿ”Œ', + runtime = '๐Ÿ’ป', + require = '๐ŸŒ™', + source = '๐Ÿ“„', + start = '๐Ÿš€', + task = '๐Ÿ“Œ', + lazy = '๐Ÿ’ค ', + }, + }, + performance = { + cache = { + enabled = true, + }, + reset_packpath = true, + rtp = { + -- disable some rtp plugins + disabled_plugins = { + 'gzip', + -- "matchit", + -- "matchparen", + 'netrwPlugin', + 'tarPlugin', + 'tohtml', + 'tutor', + 'zipPlugin', + }, + }, + }, +}) + +-- The line beneath this is called `modeline`. See `:help modeline` +-- vim: ts=2 sts=2 sw=2 et diff --git a/lazy-lock.json b/lazy-lock.json index aef69d5..1fff697 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,68 +1,68 @@ { - "LuaSnip": { "branch": "master", "commit": "ce0a05ab4e2839e1c48d072c5236cce846a387bc" }, - "bufresize.nvim": { "branch": "master", "commit": "3b19527ab936d6910484dcc20fb59bdb12322d8b" }, - "chezmoi.nvim": { "branch": "main", "commit": "e5d2b2f534d2a1701ea2f9a8849732b28ea4c8c3" }, - "chezmoi.vim": { "branch": "main", "commit": "abf37336437867cbd99ce2f8849b717415391cc3" }, - "cloak.nvim": { "branch": "main", "commit": "648aca6d33ec011dc3166e7af3b38820d01a71e4" }, + "LuaSnip": { "branch": "master", "commit": "b84eeb3641b08324287587b426ec974b888390d9" }, + "adwaita.nvim": { "branch": "main", "commit": "c9379097755701ab597140bafd097fbaff3dd517" }, + "aerial.nvim": { "branch": "master", "commit": "e75a3df2c20b3a98c786f5e61587d74a7a6b61d6" }, + "baleia.nvim": { "branch": "main", "commit": "fb3aff021b2b64ef820d0230d2c22ebfaf71bb6a" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, - "conform.nvim": { "branch": "master", "commit": "25d48271e3d4404ba017cb92a37d3a681c1ad149" }, - "copilot.vim": { "branch": "release", "commit": "25f73977033c597d530c7ab0e211d99b60927d2d" }, - "everforest": { "branch": "main", "commit": "8fdccd1e45088be3309aaf82072b1f7fec2f6f2c" }, - "focus.nvim": { "branch": "master", "commit": "4135f976afe5d6e1fe66dff121db9d06643f439f" }, - "fzf": { "branch": "master", "commit": "af4917dbb643a7991c50091ec55ec25acb7d28cb" }, - "fzf.vim": { "branch": "master", "commit": "f7c7b44764a601e621432b98c85709c9a53a7be8" }, - "gitsigns.nvim": { "branch": "main", "commit": "f074844b60f9e151970fbcdbeb8a2cd52b6ef25a" }, - "glow.nvim": { "branch": "main", "commit": "238070a686c1da3bccccf1079700eb4b5e19aea4" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "compile-mode.nvim": { "branch": "latest", "commit": "8608fce76777d01b820ffe355a7881fc74209b82" }, + "conform.nvim": { "branch": "master", "commit": "eff40c4f5fdf7ae8f269b258047d1bd7cee50f02" }, + "copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" }, + "copilot.lua": { "branch": "master", "commit": "86537b286f18783f8b67bccd78a4ef4345679625" }, + "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, + "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, + "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, + "fzf-lua": { "branch": "main", "commit": "e9413dc2b6e8ab7f62385c972df1dceba483492d" }, + "git-conflict.nvim": { "branch": "main", "commit": "bfd9fe6fba9a161fc199771d85996236a0d0faad" }, + "gitsigns.nvim": { "branch": "main", "commit": "58bd9e98d8e3c5a1c98af312e85247ee1afd3ed2" }, "gruber-darker.nvim": { "branch": "main", "commit": "1793c0929ca965430410f7ec578272a4af9226ee" }, "harpoon": { "branch": "master", "commit": "ccae1b9bec717ae284906b0bf83d720e59d12b91" }, - "hydra.nvim": { "branch": "master", "commit": "55de54543d673824435930ecf533256eea2e565b" }, - "image.nvim": { "branch": "master", "commit": "61c76515cfc3cdac8123ece9e9761b20c3dc1315" }, - "indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" }, + "hybrid.nvim": { "branch": "master", "commit": "8838621a2e299582a0af5b8b96d5515f27b5d058" }, + "hydra.nvim": { "branch": "main", "commit": "8578056a2226ed49fc608167edc143a87f75d809" }, + "indent-blankline.nvim": { "branch": "master", "commit": "3fe94b8034dd5241cb882bb73847303b58857ecf" }, + "kanagawa.nvim": { "branch": "master", "commit": "e5f7b8a804360f0a48e40d0083a97193ee4fcc87" }, "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, - "lsp-zero.nvim": { "branch": "v3.x", "commit": "56db3d5ce5476b183783160e6045f7337ba12b83" }, - "lualine.nvim": { "branch": "master", "commit": "544dd1583f9bb27b393f598475c89809c4d5e86b" }, - "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "ba9c2f0b93deb48d0a99ae0e8d8dd36f7cc286d6" }, + "lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" }, + "lsp_signature.nvim": { "branch": "master", "commit": "a38da0a61c172bb59e34befc12efe48359884793" }, + "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, + "markview.nvim": { "branch": "main", "commit": "9e5275f3b7507da51deab9bc985e9154d0b6af28" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "62360f061d45177dda8afc1b0fd1327328540301" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "meh": { "branch": "master", "commit": "41dd74e2d5afc6c1e975b01c84512a8951a39569" }, + "mini-git": { "branch": "main", "commit": "c5daa5556c1798b6ef6595a3011af3ca5f7a2fd8" }, + "mini.ai": { "branch": "main", "commit": "a9b992b13d22a8db8df6beac25afa59a10b5584d" }, "mini.bufremove": { "branch": "main", "commit": "1ee294a97e091d3cf967974df622c0d887890dc2" }, - "mini.comment": { "branch": "main", "commit": "03c13e37318bdb18481311c0ac1adc9ed731caf1" }, + "mini.icons": { "branch": "main", "commit": "fe63fe080e76d80713557e5f0c65bc15b14b152d" }, + "mini.indentscope": { "branch": "main", "commit": "1222393d9c5e8d92b913ccab6701a7164b21781c" }, + "mini.statusline": { "branch": "main", "commit": "ec7e2c509c7262fef85a28a772f60ebe146297db" }, + "mini.surround": { "branch": "main", "commit": "57caca9525cec0ea771a67326b0ee637d056078a" }, "multicursors.nvim": { "branch": "main", "commit": "782820896b1691ed664e4c24f1cd9793dcb33dfb" }, - "nabla.nvim": { "branch": "master", "commit": "27a6ea9ed7452bb9e0b19eb0942b5bcf7d051b2f" }, - "neo-tree.nvim": { "branch": "v3.x", "commit": "29f7c215332ba95e470811c380ddbce2cebe2af4" }, + "neo-tree.nvim": { "branch": "main", "commit": "8c75e8a2949cd6cd35525799200a8d34471ee9eb" }, + "neogit": { "branch": "master", "commit": "2b74a777b963dfdeeabfabf84d5ba611666adab4" }, "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, - "nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" }, - "nvim-cmp": { "branch": "main", "commit": "d818fd0624205b34e14888358037fb6f5dc51234" }, - "nvim-lint": { "branch": "master", "commit": "efc6fc83f0772283e064c53a8f9fb5645bde0bc0" }, - "nvim-lspconfig": { "branch": "master", "commit": "fdc44768a09a65140aa00c92872a5381ad486485" }, - "nvim-spectre": { "branch": "master", "commit": "ba7fb777edff6c1fbbeffd343e113af64c04e90a" }, - "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" }, - "nvim-treesitter": { "branch": "master", "commit": "65310b64eee19a6e74e1b6f607a9f46f751290fe" }, - "nvim-treesitter-context": { "branch": "master", "commit": "2aba92ceb1479485953007f4d5adf34d0b66917e" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "6b5f95aa4d24f2c629a74f2c935c702b08dbde62" }, - "nvim-web-devicons": { "branch": "master", "commit": "5be6c4e685618b99c3210a69375b38a1202369b4" }, + "numb.nvim": { "branch": "master", "commit": "3f7d4a74bd456e747a1278ea1672b26116e0824d" }, + "nvim-autopairs": { "branch": "master", "commit": "e38c5d837e755ce186ae51d2c48e1b387c4425c6" }, + "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-lspconfig": { "branch": "master", "commit": "6c505d4220b521f3b0e7b645f6ce45fa914d0eed" }, + "nvim-osc52": { "branch": "main", "commit": "04cfaba1865ae5c53b6f887c3ca7304973824fb2" }, + "nvim-treesitter": { "branch": "master", "commit": "e28614cb1a5712166afef80081f68c28db92e3e0" }, + "nvim-ufo": { "branch": "main", "commit": "7dcb8fea3e7b3ccdb50f2c3ae7c248cdf6fe1ae1" }, + "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, "oil.nvim": { "branch": "master", "commit": "fcca212c2e966fc3dec1d4baf888e670631d25d1" }, + "outline.nvim": { "branch": "main", "commit": "2175b6da5b7b5be9de14fd3f54383a17f5e4609c" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, - "rasmus": { "branch": "main", "commit": "86d608bd1d12a53b39d9b4b2847cd7c3ea81d473" }, + "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "a727bd368e70808125b7cf589328cc595faf3d5a" }, "readline.nvim": { "branch": "main", "commit": "5cb27349bc01cdcdb3d3494e5337d8b3834aef1a" }, - "rose-pine": { "branch": "main", "commit": "e4b08d74b7272cb21e4e9c71b8b9e0830fd722fe" }, - "smart-splits.nvim": { "branch": "master", "commit": "209c136a5bee236094245196986ce94920dd3fdf" }, - "snakemake": { "branch": "main", "commit": "e8735c1477a2a82110757ba86bbd1ccbcaf327ba" }, - "symbols-outline.nvim": { "branch": "master", "commit": "564ee65dfc9024bdde73a6621820866987cbb256" }, + "sg.nvim": { "branch": "master", "commit": "8bdd4d19da2268072708d5fe18fda9c23e16509d" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, - "telescope.nvim": { "branch": "master", "commit": "10b8a82b042caf50b78e619d92caf0910211973d" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "todo-comments.nvim": { "branch": "main", "commit": "8f45f353dc3649cb9b44cecda96827ea88128584" }, - "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" }, + "typewriter": { "branch": "main", "commit": "d1b3aa53d4805120674b26554e027d5f10350419" }, "undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" }, - "venn.nvim": { "branch": "main", "commit": "b09c2f36ddf70b498281845109bedcf08a7e0de0" }, - "vim-dispatch": { "branch": "master", "commit": "4c695bc052cad2ae6b980aebbe48d046466e27ae" }, - "vim-fugitive": { "branch": "master", "commit": "0444df68cd1cdabc7453d6bd84099458327e5513" }, - "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, - "vim-startuptime": { "branch": "master", "commit": "ac2cccb5be617672add1f4f3c0a55ce99ba34e01" }, + "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, "vim-tmux-navigator": { "branch": "master", "commit": "5b3c701686fb4e6629c100ed32e827edf8dad01e" }, - "vimtex": { "branch": "master", "commit": "5ac62e0315c6f54f53a7d6da7c485cf8e9cf7240" }, - "which-key.nvim": { "branch": "main", "commit": "6c1584eb76b55629702716995cca4ae2798a9cca" }, - "zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" } -} \ No newline at end of file + "which-key.nvim": { "branch": "main", "commit": "6c1584eb76b55629702716995cca4ae2798a9cca" } +} diff --git a/lua/rayandrew/autocmds.lua b/lua/rayandrew/autocmds.lua deleted file mode 100644 index ffe0767..0000000 --- a/lua/rayandrew/autocmds.lua +++ /dev/null @@ -1,127 +0,0 @@ --- Taken from --- https://github.com/LazyVim/LazyVim/blob/566049aa4a26a86219dd1ad1624f9a1bf18831b6/lua/lazyvim/config/autocmds.lua - -local augroup = require("rayandrew.util").augroup - -local autocmd = vim.api.nvim_create_autocmd - --- Check if we need to reload the file when it changed -autocmd({ "FocusGained", "TermClose", "TermLeave" }, { - group = augroup("checktime"), - command = "checktime", -}) - --- Highlight on yank -autocmd("TextYankPost", { - group = augroup("highlight_yank"), - callback = function() - vim.highlight.on_yank() - end, -}) - --- resize splits if window got resized -autocmd({ "VimResized" }, { - group = augroup("resize_splits"), - callback = function() - vim.cmd("tabdo wincmd =") - end, -}) - --- go to last loc when opening a buffer -autocmd("BufReadPost", { - group = augroup("last_loc"), - callback = function() - local exclude = { "gitcommit" } - local buf = vim.api.nvim_get_current_buf() - if vim.tbl_contains(exclude, vim.bo[buf].filetype) then - return - end - local mark = vim.api.nvim_buf_get_mark(buf, '"') - local lcount = vim.api.nvim_buf_line_count(buf) - if mark[1] > 0 and mark[1] <= lcount then - pcall(vim.api.nvim_win_set_cursor, 0, mark) - end - end, -}) - --- close some filetypes with -autocmd("FileType", { - group = augroup("close_with_q"), - pattern = { - "PlenaryTestPopup", - "help", - "lspinfo", - "man", - "notify", - "qf", - "spectre_panel", - "startuptime", - "tsplayground", - "neotest-output", - "checkhealth", - "neotest-summary", - "neotest-output-panel", - }, - callback = function(event) - vim.bo[event.buf].buflisted = false - vim.keymap.set("n", "q", "close", { buffer = event.buf, silent = true }) - end, -}) - --- wrap and check for spell in text filetypes -autocmd("FileType", { - group = augroup("wrap_spell"), - pattern = { "gitcommit", "markdown" }, - callback = function() - vim.opt_local.wrap = true - vim.opt_local.spell = true - end, -}) - --- Auto create dir when saving a file, in case some intermediate directory does not exist -autocmd({ "BufWritePre" }, { - group = augroup("auto_create_dir"), - callback = function(event) - if event.match:match("^%w%w+://") then - return - end - local file = vim.loop.fs_realpath(event.match) or event.match - vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") - end, -}) - --- autocmd({ "BufWritePre" }, { --- group = augroup("remove_trailing_whitespace"), --- pattern = "*", --- callback = function() --- if vim.b.disable_whitespace or vim.g.disable_whitespace then --- return --- end --- vim.cmd([[%s/\s\+$//e]]) --- end, --- -- command = [[%s/\s\+$//e]], --- }) - --- vim.api.nvim_create_autocmd({ "WinNew", "WinClosed", "WinEnter" }, { --- group = vim.api.nvim_create_augroup("on_demand_wrap", {}), --- callback = function() --- local should_wrap = vim.api.nvim_win_get_width(0) ~= vim.o.columns --- vim.api.nvim_win_set_option(0, "wrap", should_wrap) --- end, --- }) - -autocmd({ "VimLeave" }, { - callback = function() - vim.fn.jobstart('notify-send "hello"', { detach = true }) - end, -}) - --- set *.smk and Snakefile to filetype=snakemake -autocmd({ "BufRead", "BufNewFile" }, { - group = augroup("snakemake_filetype"), - pattern = { "*.smk", "Snakefile" }, - callback = function() - vim.bo.filetype = "snakemake" - vim.bo.commentstring = "# %s" - end, -}) diff --git a/lua/rayandrew/commands.lua b/lua/rayandrew/commands.lua index 3fbd39d..fc09717 100644 --- a/lua/rayandrew/commands.lua +++ b/lua/rayandrew/commands.lua @@ -1,7 +1,7 @@ --- [[ Conform ]] commands -- https://github.com/stevearc/conform.nvim/blob/master/doc/recipes.md#lazy-loading-with-lazynvim -vim.api.nvim_create_user_command("FormatDisable", function(args) +vim.api.nvim_create_user_command('FormatDisable', function(args) if args.bang then -- FormatDisable! will disable formatting just for this buffer vim.b.disable_autoformat = true @@ -9,48 +9,137 @@ vim.api.nvim_create_user_command("FormatDisable", function(args) vim.g.disable_autoformat = true end end, { - desc = "Disable autoformat-on-save", + desc = 'Disable autoformat-on-save', bang = true, }) -- https://github.com/stevearc/conform.nvim/blob/master/doc/recipes.md#lazy-loading-with-lazynvim -vim.api.nvim_create_user_command("FormatEnable", function() +vim.api.nvim_create_user_command('FormatEnable', function() vim.b.disable_autoformat = false vim.g.disable_autoformat = false end, { - desc = "Re-enable autoformat-on-save", + desc = 'Re-enable autoformat-on-save', }) -- https://github.com/stevearc/conform.nvim/blob/master/doc/recipes.md#format-command -vim.api.nvim_create_user_command("Format", function(args) +vim.api.nvim_create_user_command('Format', function(args) local range = nil if args.count ~= -1 then local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1] range = { start = { args.line1, 0 }, - ["end"] = { args.line2, end_line:len() }, + ['end'] = { args.line2, end_line:len() }, } end - require("conform").format({ async = true, lsp_fallback = true, range = range }) + require('conform').format { async = true, lsp_fallback = true, range = range } end, { range = true }) ---- [[ WhiteSpace ]] commands +local function run_command(cmd) + local job_id + local output = {} --- vim.api.nvim_create_user_command("RemoveWhiteSpaceEnable", function() --- vim.b.disable_whitespace = false --- vim.g.disable_whitespace = false --- end, { --- desc = "Re-enable whitespace removal on save", --- }) --- --- vim.api.nvim_create_user_command("RemoveWhiteSpaceDisable", function(args) --- if args.bang then --- -- RemoveWhiteSpaceDisable! will disable whitespace removal just for this buffer --- vim.b.disable_whitespace = true --- else --- vim.g.disable_whitespace = true --- end --- end, { --- desc = "Disable whitespace removal on save", --- bang = true, --- }) + local function on_stdout(_, data, _) + if data then + for _, line in ipairs(data) do + table.insert(output, line) + end + end + end + + local function on_exit(_, exit_code, _) + if exit_code == 0 then + vim.fn.setqflist({}, ' ', { + title = 'Command Output', + lines = output, + efm = '%f:%l:%c: %m', + }) + vim.cmd 'copen' + else + print('Command exited with code ' .. exit_code) + end + end + + job_id = vim.fn.jobstart(cmd, { + stdout_buffered = true, + on_stdout = on_stdout, + on_exit = on_exit, + }) + + if job_id <= 0 then + print 'Failed to start job' + end +end + +local function run_shell_command(shell_cmd) + local job_id + local output = {} + + local function on_stdout(_, data, _) + if data then + for _, line in ipairs(data) do + -- Trim leading and trailing whitespace + line = line:gsub('^%s*(.-)%s*$', '%1') + if line ~= '' then + table.insert(output, 'shell_output:1:1: ' .. line) + end + end + end + end + + local function on_exit(_, exit_code, _) + if exit_code == 0 then + vim.fn.setqflist({}, ' ', { + title = 'Shell Command Output', + lines = output, + efm = '%f:%l:%c: %m', + }) + vim.cmd 'copen' + else + print('Shell command exited with code ' .. exit_code) + end + end + + -- Run the command using a shell + job_id = vim.fn.jobstart({ 'sh', '-c', shell_cmd }, { + stdout_buffered = true, + on_stdout = on_stdout, + on_exit = on_exit, + }) + + if job_id <= 0 then + print 'Failed to start job' + end +end + +-- create compile command similar to emacs +vim.api.nvim_create_user_command('Compile', function(args) + -- get command from args + -- print(vim.inspect(args)) + local cmd = args.args + local oil = require 'oil' + local get_current_dir = oil.get_current_dir(vim.api.nvim_get_current_buf()) + -- local ok, get_current_dir = pcall(require('oil').get_current_dir, vim.api.nvim_get_current_buf()) + -- if not ok then + -- get_current_dir = vim.fn.getcwd() + -- end + local cmd = { + 'cd', + get_current_dir, + '&&', + } + + -- append args.fargs table to cmd_table + vim.list_extend(cmd, args.fargs) + + local shell_cmd = table.concat(cmd, ' ') + print('Executing command: ' .. shell_cmd) + + run_shell_command(shell_cmd) + + -- print('Executing command: ' .. table.concat(cmd, '')) + + -- run_command(cmd) +end, { + nargs = '*', + desc = 'Run compile command', +}) diff --git a/lua/rayandrew/filetype.lua b/lua/rayandrew/filetype.lua deleted file mode 100644 index 4397410..0000000 --- a/lua/rayandrew/filetype.lua +++ /dev/null @@ -1,53 +0,0 @@ --- using nvim autocommands - -local autocmd = vim.api.nvim_create_autocmd -local augroup = require("rayandrew.util").augroup - -local M = {} - -function M.setup() - local group = augroup("filetype") - -- set tabs=4 and use tabs in txt files - autocmd("filetype", { - pattern = "text", - -- pattern = "BufEnter *.txt", - group = group, - callback = function() - vim.bo.tabstop = 4 - vim.bo.softtabstop = 4 - vim.bo.shiftwidth = 4 - vim.bo.expandtab = false - vim.opt_local.wrap = true - -- disable indentation - vim.opt_local.autoindent = false - vim.opt_local.smartindent = false - vim.opt_local.cindent = false - vim.opt_local.indentexpr = "" - vim.opt_local.paste = true - end, - }) - - -- tex/latex wrap true - autocmd("filetype", { - pattern = "tex", - group = group, - callback = function() - vim.opt_local.wrap = true - vim.opt_local.breakindent = true - vim.opt_local.breakindentopt = "shift:2" - end, - }) - - autocmd("filetype", { - pattern = "latex", - group = group, - callback = function() - -- set wrap and breakindent - vim.opt_local.wrap = true - vim.opt_local.breakindent = true - vim.opt_local.breakindentopt = "shift:2" - end, - }) -end - -return M diff --git a/lua/rayandrew/init.lua b/lua/rayandrew/init.lua deleted file mode 100644 index 00086d7..0000000 --- a/lua/rayandrew/init.lua +++ /dev/null @@ -1,15 +0,0 @@ -local M = {} - -function M.setup() - require("rayandrew.set") - require("rayandrew.lazy") - require("rayandrew.autocmds") - require("rayandrew.remap") - require("rayandrew.theme").setup() - require("rayandrew.commands") - require("rayandrew.neovide") - -- require("rayandrew.filetype").setup() - -- require("rayandrew.statusline").setup() -end - -return M diff --git a/lua/rayandrew/lazy.lua b/lua/rayandrew/lazy.lua deleted file mode 100644 index b242f27..0000000 --- a/lua/rayandrew/lazy.lua +++ /dev/null @@ -1,53 +0,0 @@ -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) -end - -vim.opt.rtp:prepend(lazypath) - -require("rayandrew.util").setup() - -require("lazy").setup({ - spec = { - { import = "rayandrew.plugins" }, - }, - defaults = { - lazy = false, - version = false, - }, - checker = { - enabled = true, - notify = false, - frequency = 3600 * 12, - }, - change_detection = { - enabled = true, - notify = false, - }, - performance = { - cache = { - enabled = true, - }, - reset_packpath = true, - rtp = { - -- disable some rtp plugins - disabled_plugins = { - "gzip", - -- "matchit", - -- "matchparen", - "netrwPlugin", - "tarPlugin", - "tohtml", - "tutor", - "zipPlugin", - }, - }, - }, -}) diff --git a/lua/rayandrew/neovide.lua b/lua/rayandrew/neovide.lua deleted file mode 100644 index 9bf387c..0000000 --- a/lua/rayandrew/neovide.lua +++ /dev/null @@ -1,5 +0,0 @@ -if vim.g.neovide then - -- set the font - vim.o.guifont = "InconsolataGo Nerd Font Mono:h18" - vim.cmd("cd ~/Personal") -end diff --git a/lua/rayandrew/plugins/editor.lua b/lua/rayandrew/plugins/editor.lua deleted file mode 100644 index 145171b..0000000 --- a/lua/rayandrew/plugins/editor.lua +++ /dev/null @@ -1,252 +0,0 @@ -return { - { - "folke/todo-comments.nvim", - cmd = { "TodoTrouble", "TodoTelescope" }, - event = { "BufReadPost", "BufNewFile" }, - config = true, - -- stylua: ignore - keys = { - { "]t", function() require("todo-comments").jump_next() end, desc = "Next todo comment" }, - { "[t", function() require("todo-comments").jump_prev() end, desc = "Previous todo comment" }, - { "xt", "TodoTrouble", desc = "Todo (Trouble)" }, - { "xT", "TodoTrouble keywords=TODO,FIX,FIXME", desc = "Todo/Fix/Fixme (Trouble)" }, - { "st", "TodoTelescope", desc = "Todo" }, - { "sT", "TodoTelescope keywords=TODO,FIX,FIXME", desc = "Todo/Fix/Fixme" }, - }, - }, - - { - "jbyuki/venn.nvim", - keys = { - { - "nv", - function() - function Toggle_venn() - local venn_enabled = vim.inspect(vim.b.venn_enabled) - if venn_enabled == "nil" then - vim.b.venn_enabled = true - vim.cmd([[setlocal ve=all]]) - -- draw a line on HJKL keystrokes - vim.api.nvim_buf_set_keymap(0, "n", "J", "j:VBox", { noremap = true }) - vim.api.nvim_buf_set_keymap(0, "n", "K", "k:VBox", { noremap = true }) - vim.api.nvim_buf_set_keymap(0, "n", "L", "l:VBox", { noremap = true }) - vim.api.nvim_buf_set_keymap(0, "n", "H", "h:VBox", { noremap = true }) - -- draw a box by pressing "f" with visual selection - vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox", { noremap = true }) - else - vim.cmd([[setlocal ve=]]) - vim.cmd([[mapclear ]]) - vim.b.venn_enabled = nil - end - end - - Toggle_venn() - end, - desc = "Open Venn panel", - }, - }, - }, - - { - "ellisonleao/glow.nvim", - config = true, - cmd = "Glow", - ft = "markdown", - keys = { - { - "pm", - "Glow", - desc = "Preview Markdown", - }, - }, - }, - - { - "jbyuki/nabla.nvim", - lazy = true, - -- ft = { "tex", "latex", "markdown" }, - -- opts = { - -- autogen = true, -- auto-regenerate ASCII art when exiting insert mode - -- silent = true, -- silents error messages - -- }, - -- config = function() - -- local nabla = require("nabla") - -- nabla.enable_virt() - -- end, - keys = { - { - "pe", - function() - require("nabla").toggle_virt() - end, - desc = "Preview Math Equation", - }, - }, - }, - - { - "lervag/vimtex", - config = function() - -- vim.g.vimtex_compiler_progname = "nvr" - -- vim.g.vimtex_view_method = "zathura" - end, - }, - - { - "3rd/image.nvim", - enabled = not vim.g.neovide, - opts = { - backend = "kitty", - integrations = { - markdown = { - enabled = true, - clear_in_insert_mode = false, - download_remote_images = true, - only_render_image_at_cursor = false, - filetypes = { "markdown", "vimwiki" }, -- markdown extensions (ie. quarto) can go here - }, - neorg = { - enabled = true, - clear_in_insert_mode = false, - download_remote_images = true, - only_render_image_at_cursor = false, - filetypes = { "norg" }, - }, - }, - max_width = nil, - max_height = nil, - max_width_window_percentage = nil, - max_height_window_percentage = 50, - window_overlap_clear_enabled = false, -- toggles images when windows are overlapped - window_overlap_clear_ft_ignore = { "cmp_menu", "cmp_docs", "" }, - editor_only_render_when_focused = false, -- auto show/hide images when the editor gains/looses focus - tmux_show_only_in_active_window = false, -- auto show/hide images in the correct Tmux window (needs visual-activity off) - hijack_file_patterns = { "*.png", "*.jpg", "*.jpeg", "*.gif", "*.webp" }, -- render image files as images when opened - }, - config = true, - }, - - { - "laytan/cloak.nvim", - event = { - "BufEnter .env", - "BufEnter .env.*", - }, - cmd = { - "CloakEnable", - "CloakDisable", - "CloakToggle", - }, - opts = { - enabled = true, - cloak_character = "*", - -- The applied highlight group (colors) on the cloaking, see `:h highlight`. - highlight_group = "Comment", - patterns = { - { - file_pattern = { - ".env", - ".env.*", - ".dev.vars", - }, - cloak_pattern = "=.+", - }, - }, - }, - config = function(_, opts) - require("cloak").setup(opts) - end, - }, - - -- chezmoi - { - "alker0/chezmoi.vim", - lazy = false, - init = function() - -- This option is required. - vim.g["chezmoi#use_tmp_buffer"] = true - -- add other options here if needed. - end, - }, - - { - "xvzc/chezmoi.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, - -- branch = "refactor", - opts = { - edit = { - watch = true, -- Set true to automatically apply on save. - force = true, -- Set true to force apply. Works only when watch = true. - }, - notification = { - on_open = false, -- vim.notify when start editing chezmoi-managed file. - on_save = true, -- vim.notify on apply. - on_watch = true, - }, - }, - config = function(_, opts) - -- local chezmoi_dir = os.getenv("HOME") .. "/.config/dotfiles" - local dotfiles_dir = os.getenv("HOME") .. "/Code/dotfiles" - local chezmoi_dir = dotfiles_dir .. "/chezmoi" - local Util = require("rayandrew.util") - local telescope_ok, telescope = pcall(require, "telescope") - if telescope_ok then - telescope.load_extension("chezmoi") - -- check if current directory is a chezmoi directory - local cwd = vim.fn.getcwd() - if cwd == chezmoi_dir then - Util.map("n", "ff", telescope.extensions.chezmoi.find_files, { noremap = true, silent = true }) - Util.map("n", "fc", Util.telescope("files", { cwd = false }), { noremap = true, silent = true }) - else - Util.map("n", "fc", telescope.extensions.chezmoi.find_files, { noremap = true, silent = true }) - Util.map("n", "ff", Util.telescope("files", { cwd = false }), { noremap = true, silent = true }) - end - end - - vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { - -- pattern = { os.getenv("HOME") .. "/.local/share/chezmoi/*" }, - pattern = { chezmoi_dir .. "/*" }, - -- pattern = { require("chezmoi").source_path }, - callback = function() - -- invoke with vim.schedule() for better startup time - vim.schedule(require("chezmoi.commands.__edit").watch) - end, - }) - end, - }, - - { - "snakemake/snakemake", - ft = "snakemake", - config = function(plugin) - vim.opt.rtp:append(plugin.dir .. "/misc/vim") - end, - }, - - { - "iamcco/markdown-preview.nvim", - cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, - ft = { "markdown" }, - build = function() - vim.fn["mkdp#util#install"]() - end, - }, - - { - "smoka7/multicursors.nvim", - event = "VeryLazy", - dependencies = { - "smoka7/hydra.nvim", - }, - opts = {}, - cmd = { "MCstart", "MCvisual", "MCclear", "MCpattern", "MCvisualPattern", "MCunderCursor" }, - keys = { - { - mode = { "v", "n" }, - "", - "MCstart", - desc = "Create a selection for selected text or word under the cursor", - }, - }, - }, -} diff --git a/lua/rayandrew/plugins/file.lua b/lua/rayandrew/plugins/file.lua deleted file mode 100644 index a8af0e6..0000000 --- a/lua/rayandrew/plugins/file.lua +++ /dev/null @@ -1,217 +0,0 @@ -local Util = require("rayandrew.util") - -return { - ------------------------------ - -- File Management - ------------------------------ - - { - "nvim-neo-tree/neo-tree.nvim", - branch = "v3.x", - cmd = "Neotree", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information - }, - opts = { - sources = { "filesystem", "buffers", "git_status", "document_symbols" }, - open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" }, - filesystem = { - bind_to_cwd = false, - follow_current_file = { enabled = true }, - use_libuv_file_watcher = true, - hijack_netrw_behavior = "open_current", - }, - window = { - mappings = { - [""] = "none", - -- ["C"] = "copy", - ["C"] = { - "copy", - config = { - show_path = "absolute", -- "none", "relative", "absolute" - }, - }, - ["R"] = "rename", - ["y"] = function(state) - local node = state.tree:get_node() - -- get relative path - local filepath = node:get_id() - local filename = vim.fn.fnamemodify(filepath, ":.") - -- local filename = node.name - vim.fn.setreg("+", filename) - vim.notify("Copied: " .. filename) - end, - ["Y"] = function(state) - local node = state.tree:get_node() - local filepath = node:get_id() - vim.fn.setreg("+", filepath) - vim.notify("Copied: " .. filepath) - end, - ["O"] = { - command = function(state) - local node = state.tree:get_node() - local filepath = node.path - local osType = os.getenv("OS") - - local command - - if osType == "Windows_NT" then - command = "start " .. filepath - elseif osType == "Darwin" then - command = "open " .. filepath - else - command = "xdg-open " .. filepath - end - os.execute(command) - end, - desc = "open_with_system_defaults", - }, - }, - }, - default_component_configs = { - indent = { - with_expanders = true, -- if nil and file nesting is enabled, will enable expanders - expander_collapsed = "๏‘ ", - expander_expanded = "๏‘ผ", - expander_highlight = "NeoTreeExpander", - }, - }, - }, - keys = { - -- { - -- "E", - -- function() - -- vim.cmd("Neotree toggle position=current") - -- end, - -- desc = "Toggle NeoTree as Buffer", - -- }, - { - "fe", - function() - vim.cmd("Neotree toggle") - end, - desc = "Toggle NeoTree", - }, - }, - deactivate = function() - vim.cmd([[Neotree close]]) - end, - -- init = function() - -- if vim.fn.argc(-1) == 1 then - -- local stat = vim.loop.fs_stat(vim.fn.argv(0)) - -- if stat and stat.type == "directory" then - -- require("neo-tree") - -- end - -- end - -- end, - config = function(_, opts) - local function on_move(data) - -- Util.lsp.on_rename(data.source, data.destination) - end - - local events = require("neo-tree.events") - opts.event_handlers = opts.event_handlers or {} - vim.list_extend(opts.event_handlers, { - { event = events.FILE_MOVED, handler = on_move }, - { event = events.FILE_RENAMED, handler = on_move }, - }) - require("neo-tree").setup(opts) - vim.api.nvim_create_autocmd("TermClose", { - pattern = "*lazygit", - callback = function() - if package.loaded["neo-tree.sources.git_status"] then - require("neo-tree.sources.git_status").refresh() - end - end, - }) - end, - }, - - { - "stevearc/oil.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - cmd = { "Oil" }, - keys = { - -- { - -- "e", - -- function() - -- -- disable in oil filetype - -- if vim.bo.filetype == "oil" then - -- return - -- end - -- require("oil").open_float() - -- end, - -- desc = "Open current directory", - -- }, - { - "fE", - function() - -- disable in oil filetype - if vim.bo.filetype == "oil" then - return - end - require("oil").open(".") - end, - desc = "Open current directory", - }, - }, - opts = { - columns = { - -- "icon", - -- "permissions", - -- "size", - -- "mtime", - }, - default_file_explorer = true, - restore_win_options = true, - float = { - padding = 2, - max_width = 240, - max_height = 70, - -- width = 0.2, - -- max_height = 0.5, - border = "rounded", - win_options = { - winblend = 10, - }, - }, - keymaps = { - [""] = { - callback = function() - if vim.bo.filetype == "oil" then - local oil = require("oil") - vim.g.oil_show_info = not vim.g.oil_show_info - if vim.g.oil_show_info then - oil.set_columns({ - "permissions", - "size", - "mtime", - "icon", - }) - else - oil.set_columns({}) - end - return - end - end, - desc = "Toggle info", - }, - ["q"] = "actions.close", - [""] = "actions.toggle_hidden", - ["?"] = "actions.show_help", - }, - }, - init = function() - vim.g.oil_show_info = false - if vim.fn.argc() == 1 then - local stat = vim.loop.fs_stat(vim.fn.argv(0)) - if stat and stat.type == "directory" then - require("oil") - end - end - end, - }, -} diff --git a/lua/rayandrew/plugins/general.lua b/lua/rayandrew/plugins/general.lua deleted file mode 100644 index ca407ee..0000000 --- a/lua/rayandrew/plugins/general.lua +++ /dev/null @@ -1,70 +0,0 @@ -return { - { "folke/lazy.nvim", version = "*" }, - { "nvim-lua/plenary.nvim", lazy = true }, - - { - "dstein64/vim-startuptime", - cmd = "StartupTime", - init = function() - vim.g.startuptime_tries = 10 - end, - }, - - ------------------------------ - -- Color Scheme - ------------------------------ - { - "rose-pine/neovim", - name = "rose-pine", - lazy = true, - }, - - { - "davidosomething/vim-colors-meh", - name = "meh", - lazy = true, - }, - - { - "kvrohit/rasmus.nvim", - name = "rasmus", - lazy = true, - }, - - { - "neanias/everforest-nvim", - lazy = true, - name = "everforest", - opts = { - background = "hard", - }, - }, - - { - "thimc/gruber-darker.nvim", - lazy = true, - opts = { - transparent = true, - }, - }, - - - { "junegunn/fzf.vim", dependencies = { "junegunn/fzf" } }, - - -- { - -- "f-person/auto-dark-mode.nvim", - -- config = { - -- update_interval = 1000, - -- set_dark_mode = function() - -- vim.o.background = "dark" - -- -- vim.api.nvim_set_option("background", "dark") - -- -- vim.cmd("colorscheme gruvbox") - -- end, - -- set_light_mode = function() - -- vim.o.background = "light" - -- -- vim.api.nvim_set_option("background", "light") - -- -- vim.cmd("colorscheme gruvbox") - -- end, - -- }, - -- }, -} diff --git a/lua/rayandrew/plugins/lsp.lua b/lua/rayandrew/plugins/lsp.lua index 21dfa2d..09643a6 100644 --- a/lua/rayandrew/plugins/lsp.lua +++ b/lua/rayandrew/plugins/lsp.lua @@ -1,240 +1,256 @@ ------------------------------- --- LSP CONFIGURATION -- ------------------------------- - -local tools = require("rayandrew.tools") -local slow_format_filetypes = {} - return { { - { - "VonHeikemen/lsp-zero.nvim", - branch = "v3.x", - lazy = true, - config = false, - init = function() - -- Disable automatic setup, we are doing it manually - vim.g.lsp_zero_extend_cmp = 0 - vim.g.lsp_zero_extend_lspconfig = 0 - end, - }, + -- 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', - { - "williamboman/mason.nvim", - lazy = false, - config = true, - }, + -- Useful status updates for LSP. + -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` + { 'j-hui/fidget.nvim', opts = {} }, - -- Autocompletion - { - "hrsh7th/nvim-cmp", - event = "InsertEnter", - dependencies = { - { "L3MON4D3/LuaSnip" }, - }, - config = function() - -- Here is where you configure the autocompletion settings. - local lsp_zero = require("lsp-zero") - lsp_zero.extend_cmp() + -- Allows extra capabilities provided by nvim-cmp + 'hrsh7th/cmp-nvim-lsp', - -- And you can configure cmp even more, if you want to. - local cmp = require("cmp") - local cmp_action = lsp_zero.cmp_action() - - cmp.setup({ - formatting = lsp_zero.cmp_format(), - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp_action.luasnip_jump_forward(), - [""] = cmp_action.luasnip_jump_backward(), - }), - }) - end, - }, - - -- LSP - { - "neovim/nvim-lspconfig", - cmd = { "LspInfo", "LspInstall", "LspStart" }, - event = { "BufReadPre", "BufNewFile" }, - dependencies = { - { "hrsh7th/cmp-nvim-lsp" }, - { "williamboman/mason-lspconfig.nvim" }, - }, - config = function() - -- This is where all the LSP shenanigans will live - local lsp_zero = require("lsp-zero") - lsp_zero.extend_lspconfig() - - lsp_zero.on_attach(function(client, bufnr) - -- see :help lsp-zero-keybindings - -- to learn the available actions - lsp_zero.default_keymaps({ buffer = bufnr, preserve_mappings = true }) - end) - - require("mason-lspconfig").setup({ - ensure_installed = {}, - handlers = { - lsp_zero.default_setup, - lua_ls = function() - -- (Optional) Configure lua language server for neovim - local lua_opts = lsp_zero.nvim_lua_ls() - require("lspconfig").lua_ls.setup(lua_opts) - end, - }, - }) - end, - }, - }, - - -- Formatter - { - "stevearc/conform.nvim", - event = { "BufWritePre" }, - cmd = { "ConformInfo" }, - keys = { { - -- Customize or remove this keymap to your liking - "cf", - function() - require("conform").format({ async = true, lsp_fallback = true }) - end, - mode = "", - desc = "Format buffer", + 'ray-x/lsp_signature.nvim', + event = 'VeryLazy', + -- config = function(_, opts) + -- require('lsp_signature').setup(opts) + -- end, }, + + -- { 'SmiteshP/nvim-navic', opts = { + -- auto_attach = true, + -- } }, }, - opts = { - formatters_by_ft = tools.formatters, - format_on_save = function(bufnr) - if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then - return - end - - if slow_format_filetypes[vim.bo[bufnr].filetype] then - return - end - local function on_format(err) - if err and err:match("timeout$") then - slow_format_filetypes[vim.bo[bufnr].filetype] = true - end - end - - return { timeout_ms = 200, lsp_fallback = true }, on_format - end, - format_after_save = function(bufnr) - if not slow_format_filetypes[vim.bo[bufnr].filetype] then - return - end - return { lsp_fallback = true } - end, - formatters = { - shfmt = { - prepend_args = { "-i", "2" }, - }, - }, - }, - init = function() - -- If you want the formatexpr, here is the place to set it - vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" - end, - }, - - { - "folke/trouble.nvim", - cmd = { "TroubleToggle", "Trouble" }, - opts = { use_diagnostic_signs = true }, - keys = { - { - "xx", - "TroubleToggle document_diagnostics", - desc = "Document Diagnostics (Trouble)", - }, - { - "xX", - "TroubleToggle workspace_diagnostics", - desc = "Workspace Diagnostics (Trouble)", - }, - { - "xL", - "TroubleToggle loclist", - desc = "Location List (Trouble)", - }, - { - "xQ", - "TroubleToggle quickfix", - desc = "Quickfix List (Trouble)", - }, - { - "[q", - function() - if require("trouble").is_open() then - require("trouble").previous({ skip_groups = true, jump = true }) - else - local ok, err = pcall(vim.cmd.cprev) - if not ok then - vim.notify(err, vim.log.levels.ERROR) - end - end - end, - desc = "Previous trouble/quickfix item", - }, - { - "]q", - function() - if require("trouble").is_open() then - require("trouble").next({ skip_groups = true, jump = true }) - else - local ok, err = pcall(vim.cmd.cnext) - if not ok then - vim.notify(err, vim.log.levels.ERROR) - end - end - end, - desc = "Next trouble/quickfix item", - }, - }, - }, - - { -- Linter integration - "mfussenegger/nvim-lint", - event = "VeryLazy", config = function() - local lint = require("lint") - lint.linters_by_ft = tools.linters + -- 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` - lint.linters.shellcheck.args = { "--shell=bash", "--format=json", "-" } - lint.linters.markdownlint.args = { - "--disable=no-trailing-spaces", -- not disabled in config, so it's enabled for formatting - "--disable=no-multiple-blanks", - } - lint.linters["editorconfig-checker"].args = { - "-no-color", - "-disable-max-line-length", -- only rule of thumb - "-disable-trim-trailing-whitespace", -- will be formatted anyway - } - end, - }, + -- 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) + vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end - { -- auto-install missing linters & formatters - "WhoIsSethDaniel/mason-tool-installer.nvim", - event = "VeryLazy", - keys = { - { "pM", vim.cmd.MasonToolsUpdate, desc = "๏’‡ Mason Update" }, - }, - dependencies = { "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim" }, - config = function() - local tools_to_install = tools.getToolsToInstall() + -- -- 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') - require("mason-tool-installer").setup({ - ensure_installed = tools_to_install, - run_on_start = false, -- triggered manually, since not working with lazy-loading + -- fzf lua + map('gd', require('fzf-lua').lsp_definitions, '[G]oto [D]efinition') + map('gr', require('fzf-lua').lsp_references, '[G]oto [R]eferences') + map('gI', require('fzf-lua').lsp_implementations, '[G]oto [I]mplementation') + map('D', require('fzf-lua').lsp_typedefs, 'Type [D]efinition') + map('ds', require('fzf-lua').lsp_document_symbols, '[D]ocument [S]ymbols') + map('ws', require('fzf-lua').lsp_live_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') + + -- 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 + + require('lsp_signature').on_attach({}, event.buf) + + -- if client and client.server_capabilities.documentSymbolProvider then + -- local navic = require 'nvim-navic' + -- navic.attach(client, event.buf) + -- end + end, }) - -- clean unused & install missing - vim.defer_fn(vim.cmd.MasonToolsInstall, 500) - vim.defer_fn(vim.cmd.MasonToolsClean, 1000) -- delayed, so noice.nvim is loaded before + -- LSP servers and clients are able to communicate to each other what features they support. + -- By default, Neovim doesn't support everything that is in the LSP specification. + -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. + -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) + + -- Enable the following language servers + -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. + -- + -- Add any additional override configuration in the following tables. Available keys are: + -- - cmd (table): Override the default command used to start the server + -- - filetypes (table): Override the default list of associated filetypes for the server + -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. + -- - settings (table): Override the default settings passed when initializing the server. + -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + local servers = { + clangd = {}, + -- gopls = {}, + pyright = {}, + rust_analyzer = {}, + -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs + -- + -- Some languages (like typescript) have entire language plugins that can be useful: + -- https://github.com/pmizio/typescript-tools.nvim + -- + -- But for many setups, the LSP (`tsserver`) will work just fine + -- tsserver = {}, + -- + + lua_ls = { + -- cmd = {...}, + -- filetypes = { ...}, + -- capabilities = {}, + settings = { + Lua = { + completion = { + callSnippet = 'Replace', + }, + -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- diagnostics = { disable = { 'missing-fields' } }, + }, + }, + }, + } + + -- 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, }, + + -- LSP Plugins + { + -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins + -- used for completion, annotations and signatures of Neovim apis + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = { + -- Load luvit types when the `vim.uv` word is found + { path = 'luvit-meta/library', words = { 'vim%.uv' } }, + }, + }, + }, + { 'Bilal2453/luvit-meta', lazy = true }, } diff --git a/lua/rayandrew/plugins/telescope.lua b/lua/rayandrew/plugins/telescope.lua index fcf5b20..cbf217a 100644 --- a/lua/rayandrew/plugins/telescope.lua +++ b/lua/rayandrew/plugins/telescope.lua @@ -1,143 +1,91 @@ ------------------------------- --- Telescope -- ------------------------------- - return { - - { - "nvim-telescope/telescope.nvim", - cmd = "Telescope", + { -- Fuzzy Finder (files, lsp, etc) + 'nvim-telescope/telescope.nvim', + event = 'VimEnter', + branch = '0.1.x', dependencies = { - "nvim-lua/plenary.nvim", - { - "nvim-telescope/telescope-fzf-native.nvim", - -- NOTE: If you are having trouble with this installation, - -- refer to the README for telescope-fzf-native for more instructions. - build = "make", + '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 + 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 }, }, - version = false, - opts = { - pickers = { - buffers = { + config = function() + -- [[ 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 = { - [""] = function(prompt_bufnr) - local actions = require("telescope.actions") - actions.delete_buffer(prompt_bufnr) - actions.move_to_top(prompt_bufnr) - end, - [""] = false, - }, - n = { - ["d"] = "delete_buffer", + [''] = 'close', + [''] = 'close', + [''] = 'to_fuzzy_refine', }, }, }, - }, - }, - keys = { - { - "sp", - function() - local Util = require("rayandrew.util") - local fn = Util.telescope("live_grep", { cwd = vim.loop.cwd() }) - fn() - end, - desc = "Find in Files (Grep)", - }, - { - "ps", - function() - local Util = require("rayandrew.util") - local fn = Util.telescope("grep_string", { - search = vim.fn.input("Grep > "), - }) - fn() - end, - desc = "Find in Files (Grep)", - }, - { - "bb", - function() - local Util = require("rayandrew.util") - local fn = Util.telescope("buffers") - fn() - end, - desc = "List all opened buffers", - }, - { - "fF", - function() - local utils = require("telescope.utils") - local Util = require("rayandrew.util") - local fn = Util.telescope("files", { cwd = utils.buffer_dir() }) - fn() - end, - desc = "Find Files (root dir)", - }, - { - "ff", - function() - local Util = require("rayandrew.util") - local fn = Util.telescope("files", { cwd = false }) - fn() - end, - desc = "Find Files (cwd)", - }, - { - "fh", - function() - local Util = require("rayandrew.util") - local fn = Util.telescope("files", { cwd = false, hidden = true }) - fn() - end, - desc = "Find Files with Hidden (cwd)", - }, - { - "sm", - function() - local Util = require("rayandrew.util") - local fn = Util.telescope("man_pages") - fn() - end, - desc = "Find Manual", - }, - { - "sh", - function() - local Util = require("rayandrew.util") - local fun = Util.telescope("help_tags") - fun() - end, - desc = "Find Help Tags", - }, - { - "/", - function() - -- require("telescope.builtin").current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ - -- winblend = 10, - -- previewer = false, - -- })) - local Util = require("rayandrew.util") - local fn = Util.telescope("current_buffer_fuzzy_find", { - winblend = 10, - previewer = false, - }) - fn() - end, - }, - { - "sd", - function() - local Util = require("rayandrew.util") - local fn = Util.telescope("diagnostics") - fn() - end, - }, - }, + -- pickers = {} + 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/rayandrew/plugins/treesitter.lua b/lua/rayandrew/plugins/treesitter.lua index e37af0f..d411b7d 100644 --- a/lua/rayandrew/plugins/treesitter.lua +++ b/lua/rayandrew/plugins/treesitter.lua @@ -1,140 +1,32 @@ return { - ------------------------------ - -- TreeSitter - ------------------------------ - { - "nvim-treesitter/nvim-treesitter", - version = false, -- last release is way too old and doesn't work on Windows - build = ":TSUpdate", - event = { "VeryLazy" }, - lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline - init = function(plugin) - -- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early - -- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which - -- no longer trigger the **nvim-treesitter** module to be loaded in time. - -- Luckily, the only things that those plugins need are the custom queries, which we make available - -- during startup. - require("lazy.core.loader").add_to_rtp(plugin) - require("nvim-treesitter.query_predicates") - end, - cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" }, - keys = { - { "", desc = "Increment Selection" }, - { "", desc = "Decrement Selection", mode = "x" }, - }, - ---@type TSConfig - ---@diagnostic disable-next-line: missing-fields + { -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', opts = { - highlight = { enable = true }, - indent = { enable = true }, - ensure_installed = { - "bash", - "c", - "diff", - "html", - "javascript", - "jsdoc", - "json", - "jsonc", - "lua", - "luadoc", - "luap", - "markdown", - "markdown_inline", - "python", - "query", - "regex", - "toml", - "tsx", - "typescript", - "vim", - "vimdoc", - "xml", - "yaml", - }, - incremental_selection = { + ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + -- Autoinstall languages that are not installed + auto_install = true, + highlight = { enable = true, - keymaps = { - init_selection = "", - node_incremental = "", - scope_incremental = false, - node_decremental = "", - }, - }, - textobjects = { - move = { - enable = true, - goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" }, - goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" }, - goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" }, - goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" }, - }, + -- 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' } }, }, - ---@param opts TSConfig config = function(_, opts) - if type(opts.ensure_installed) == "table" then - ---@type table - local added = {} - opts.ensure_installed = vim.tbl_filter(function(lang) - if added[lang] then - return false - end - added[lang] = true - return true - end, opts.ensure_installed) - end - require("nvim-treesitter.configs").setup(opts) - -- vim.schedule(function() - -- require("lazy").load({ plugins = { "nvim-treesitter-textobjects" } }) - -- end) + -- [[ Configure Treesitter ]] See `:help nvim-treesitter` + + ---@diagnostic disable-next-line: missing-fields + require('nvim-treesitter.configs').setup(opts) + + -- 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 end, }, - - -- { - -- "nvim-treesitter/playground", - -- }, - { - "nvim-treesitter/nvim-treesitter-textobjects", - lazy = true, - config = function() - -- When in diff mode, we want to use the default - -- vim text objects c & C instead of the treesitter ones. - local move = require("nvim-treesitter.textobjects.move") ---@type table - local configs = require("nvim-treesitter.configs") - for name, fn in pairs(move) do - if name:find("goto") == 1 then - move[name] = function(q, ...) - if vim.wo.diff then - local config = configs.get_module("textobjects.move")[name] ---@type table - for key, query in pairs(config or {}) do - if q == query and key:find("[%]%[][cC]") then - vim.cmd("normal! " .. key) - return - end - end - end - return fn(q, ...) - end - end - end - end, - }, - - { - "nvim-treesitter/nvim-treesitter-context", - opts = { - multiline_threshold = 1, - }, - config = true, - }, - - { - "simrat39/symbols-outline.nvim", - opts = {}, - cmd = { "SymbolsOutline", "SymbolsOutlineOpen", "SymbolsOutlineClose" }, - keys = { - { "so", "SymbolsOutline", desc = "Symbols Outline" }, - }, - }, } diff --git a/lua/rayandrew/plugins/ui.lua b/lua/rayandrew/plugins/ui.lua deleted file mode 100644 index 01d72e5..0000000 --- a/lua/rayandrew/plugins/ui.lua +++ /dev/null @@ -1,142 +0,0 @@ ------------------------------- --- User Interface ------------------------------- - -return { - { - "nvim-lualine/lualine.nvim", - event = "VeryLazy", - opts = function() - local icons = require("rayandrew.theme").icons - local Util = require("rayandrew.util") - - return { - options = { - theme = "auto", - globalstatus = true, - disabled_filetypes = { statusline = { "dashboard", "alpha" } }, - }, - sections = { - lualine_a = { - { - "mode", - fmt = function(str) - return str:sub(1, 1) - end, - }, - }, - lualine_b = { "branch" }, - lualine_c = { - { - "diagnostics", - symbols = { - error = icons.diagnostics.Error, - warn = icons.diagnostics.Warn, - info = icons.diagnostics.Info, - hint = icons.diagnostics.Hint, - }, - }, - { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, - { "filename", path = 1, symbols = { modified = " ๏ƒถ ", readonly = "", unnamed = "" } }, - }, - lualine_x = { - { require("lazy.status").updates, cond = require("lazy.status").has_updates, color = Util.fg("Special") }, - { - "diff", - symbols = { - added = icons.git.added, - modified = icons.git.modified, - removed = icons.git.removed, - }, - }, - }, - lualine_y = {}, - lualine_z = { - function() - return "๏บ " .. os.date("%R") - end, - }, - }, - extensions = { "neo-tree", "lazy" }, - } - end, - }, - - { - "lukas-reineke/indent-blankline.nvim", - main = "ibl", - event = { "BufReadPost", "BufNewFile" }, - opts = { - -- char = "โ–", - indent = { - char = "โ”‚", - }, - exclude = { - filetypes = { - "help", - "alpha", - "dashboard", - "neo-tree", - "Trouble", - "lazy", - "mason", - "notify", - "toggleterm", - "lazyterm", - "qf", - }, - buftypes = { - "terminal", - "nofile", - "quickfix", - "prompt", - }, - }, - scope = { - enabled = true, - }, - -- show_trailing_blankline_indent = false, - }, - }, - - { "kevinhwang91/nvim-bqf", ft = "qf" }, - - -- icons - { "nvim-tree/nvim-web-devicons", lazy = true }, - - { - "lewis6991/gitsigns.nvim", - event = { "BufReadPre", "BufNewFile" }, - opts = { - signs = { - add = { text = "โ–Ž" }, - change = { text = "โ–Ž" }, - delete = { text = "๏ƒš" }, - topdelete = { text = "๏ƒš" }, - changedelete = { text = "โ–Ž" }, - untracked = { text = "โ–Ž" }, - }, - on_attach = function(buffer) - local gs = package.loaded.gitsigns - - local function map(mode, l, r, desc) - vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) - end - - -- stylua: ignore start - map("n", "]h", gs.next_hunk, "Next Hunk") - map("n", "[h", gs.prev_hunk, "Prev Hunk") - map({ "n", "v" }, "ghs", ":Gitsigns stage_hunk", "Stage Hunk") - map({ "n", "v" }, "ghr", ":Gitsigns reset_hunk", "Reset Hunk") - map("n", "ghS", gs.stage_buffer, "Stage Buffer") - map("n", "ghu", gs.undo_stage_hunk, "Undo Stage Hunk") - map("n", "ghR", gs.reset_buffer, "Reset Buffer") - map("n", "ghp", gs.preview_hunk, "Preview Hunk") - map("n", "ghb", function() gs.blame_line({ full = true }) end, "Blame Line") - map("n", "ghd", gs.diffthis, "Diff This") - map("n", "ghD", function() gs.diffthis("~") end, "Diff This ~") - map({ "o", "x" }, "ih", ":Gitsigns select_hunk", "GitSigns Select Hunk") - end, - }, - }, -} diff --git a/lua/rayandrew/plugins/utilities.lua b/lua/rayandrew/plugins/utilities.lua deleted file mode 100644 index 530d818..0000000 --- a/lua/rayandrew/plugins/utilities.lua +++ /dev/null @@ -1,391 +0,0 @@ ------------------------------- --- Utilities ------------------------------- - -return { - { - "nvim-focus/focus.nvim", - version = "*", - opts = {}, - cmd = { "FocusToggle", "FocusSplitNicely", "FocusSplitCycle", "FocusSplitCycleReverse" }, - keys = { - { - "wf", - "FocusToggle", - desc = "Toggle Focus", - }, - }, - }, - - { - "kylechui/nvim-surround", - version = "*", - event = "VeryLazy", - opts = {}, - }, - - { - "RRethy/vim-illuminate", - event = { "BufReadPost", "BufNewFile" }, - opts = { - delay = 200, - large_file_cutoff = 2000, - large_file_overrides = { - providers = { "lsp" }, - }, - }, - config = function(_, opts) - require("illuminate").configure(opts) - - local function map(key, dir, buffer) - vim.keymap.set("n", key, function() - require("illuminate")["goto_" .. dir .. "_reference"](false) - end, { - desc = dir:sub(1, 1):upper() .. dir:sub(2) .. " Reference", - buffer = buffer, - }) - end - - map("]]", "next") - map("[[", "prev") - - -- also set it after loading ftplugins, since a lot overwrite [[ and ]] - vim.api.nvim_create_autocmd("FileType", { - callback = function() - local buffer = vim.api.nvim_get_current_buf() - map("]]", "next", buffer) - map("[[", "prev", buffer) - end, - }) - end, - keys = { - { "]]", desc = "Next Reference" }, - { "[[", desc = "Prev Reference" }, - }, - }, - - -- comments - { - "echasnovski/mini.comment", - event = "VeryLazy", - dependencies = { - { "JoosepAlviste/nvim-ts-context-commentstring", lazy = true }, - }, - opts = { - options = { - custom_commentstring = function() - return require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring - end, - }, - }, - }, - - -- RSI compatibility - -- { - -- "tpope/vim-rsi", - -- }, - { - "assistcontrol/readline.nvim", - event = "VeryLazy", - keys = { - { - "", - function() - require("readline").forward_word() - end, - mode = "!", - }, - { - "", - function() - require("readline").backward_word() - end, - mode = "!", - }, - { - "", - function() - require("readline").kill_word() - end, - mode = "!", - }, - { - "", - function() - require("readline").backward_kill_word() - end, - mode = "!", - }, - { - "", - function() - require("readline").unix_word_rubout() - end, - mode = "!", - }, - { - "", - function() - require("readline").kill_line() - end, - mode = "!", - }, - { - "", - function() - require("readline").backward_kill_line() - end, - mode = "!", - }, - { - "", - function() - require("readline").beginning_of_line() - end, - mode = "!", - }, - { - "", - function() - require("readline").end_of_line() - end, - mode = "!", - }, - { "", "", mode = "!" }, -- forward-char - { "", "", mode = "!" }, -- backward-char - { "", "", mode = "!" }, -- next-line - { "", "", mode = "!" }, -- previous-line - { "", "", mode = "!" }, -- delete-char - { "", "", mode = "!" }, -- backward-delete-char - { "", "", mode = "!" }, -- abort - }, - }, - - { - "tpope/vim-fugitive", - cmd = { "Git" }, - }, - - { - "theprimeagen/harpoon", - event = "VeryLazy", - keys = { - { - "ha", - function() - local mark = require("harpoon.mark") - mark.add_file() - vim.print("Added to Harpoon " .. vim.fn.expand("%")) - end, - desc = "Harpoon Add File", - }, - { - "he", - function() - local ui = require("harpoon.ui") - ui.toggle_quick_menu() - end, - desc = "Harpoon UI", - }, - { - "h1", - function() - local ui = require("harpoon.ui") - ui.nav_file(1) - end, - }, - { - "h2", - function() - local ui = require("harpoon.ui") - ui.nav_file(2) - end, - }, - { - "h3", - function() - local ui = require("harpoon.ui") - ui.nav_file(3) - end, - }, - { - "h4", - function() - local ui = require("harpoon.ui") - ui.nav_file(4) - end, - }, - { - "h5", - function() - local ui = require("harpoon.ui") - ui.nav_file(5) - end, - }, - }, - }, - - { - "github/copilot.vim", - init = function() - -- vim.g.copilot_no_tab_map = true - -- vim.g.copilot_assume_mapped = true - -- vim.g.copilot_tab_fallback = "" - vim.g.copilot_filetypes = { - ["*"] = true, - ["text"] = false, - } - end, - }, - - { - "mbbill/undotree", - cmd = { "UndotreeToggle" }, - }, - - { - "folke/which-key.nvim", - event = "VeryLazy", - opts = { - plugins = { spelling = true }, - defaults = { - mode = { "n", "v" }, - ["g"] = { name = "+goto" }, - ["gz"] = { name = "+surround" }, - ["]"] = { name = "+next" }, - ["["] = { name = "+prev" }, - [""] = { name = "+tabs" }, - ["b"] = { name = "+buffer" }, - ["c"] = { name = "+code" }, - ["f"] = { name = "+file/find" }, - ["g"] = { name = "+git" }, - ["n"] = { name = "+note" }, - ["gh"] = { name = "+hunks" }, - ["q"] = { name = "+quit/session" }, - ["s"] = { name = "+search" }, - ["u"] = { name = "+ui" }, - ["w"] = { name = "+windows" }, - ["x"] = { name = "+diagnostics/quickfix" }, - }, - }, - config = function(_, opts) - local wk = require("which-key") - wk.setup(opts) - wk.register(opts.defaults) - end, - }, - - -- zen - { - "folke/zen-mode.nvim", - opts = { - window = { - width = 100, - }, - plugins = { - tmux = { - enabled = true, - }, - }, - on_open = function() - vim.wo.wrap = false - vim.wo.number = false - vim.wo.rnu = false - vim.wo.signcolumn = "no" - end, - on_close = function() - vim.wo.wrap = true - vim.wo.number = true - vim.wo.rnu = true - vim.wo.signcolumn = "yes" - end, - }, - keys = { - { - "z", - function() - require("zen-mode").toggle() - require("rayandrew.theme").recolor() - end, - }, - }, - }, - - -- Tmux - { - "mrjones2014/smart-splits.nvim", - lazy = true, - -- event = "VeryLazy", - dependencies = { - { - "kwkarlwang/bufresize.nvim", - opts = {}, - }, - }, - config = function() - require("smart-splits").setup({ - resize_mode = { - hooks = { - on_leave = require("bufresize").register, - }, - }, - }) - end, - }, - - { - "christoomey/vim-tmux-navigator", - cmd = { - "TmuxNavigateLeft", - "TmuxNavigateDown", - "TmuxNavigateUp", - "TmuxNavigateRight", - }, - keys = { "", "", "", "" }, - config = function() - vim.g.tmux_navigator_no_wrap = 1 - end, - }, - - -- search/replace in multiple files - { - "nvim-pack/nvim-spectre", - cmd = "Spectre", - opts = { open_cmd = "noswapfile vnew" }, - keys = { - { - "sr", - function() - require("spectre").open() - end, - desc = "Replace in files (Spectre)", - }, - }, - }, - - -- buffer remove - { - "echasnovski/mini.bufremove", - -- stylua: ignore - keys = { - { "bd", function() require("mini.bufremove").delete(0, false) end, desc = "Delete Buffer" }, - { "bD", function() require("mini.bufremove").delete(0, true) end, desc = "Delete Buffer (Force)" }, - }, - }, - - { - "tpope/vim-dispatch", - commands = { "Make", "Dispatch", "Copen" }, - keys = { - { - "cc", - function() - local input = vim.fn.input("Command: ") - vim.cmd("Dispatch " .. input) - end, - desc = "AsyncRun", - }, - { "ck", desc = "AsyncStop" }, - }, - }, -} diff --git a/lua/rayandrew/remap.lua b/lua/rayandrew/remap.lua deleted file mode 100644 index a2333cc..0000000 --- a/lua/rayandrew/remap.lua +++ /dev/null @@ -1,213 +0,0 @@ -local Util = require("rayandrew.util") - ------------------------------- --- Buffers ------------------------------- - -Util.map("n", "fs", "w", { desc = "Save file" }) - --- Util.map({ "i", "v", "n", "s" }, "", "w", { desc = "Save file" }) - --- Move Lines -Util.map("n", "", "m .+1==", { desc = "Move down" }) -Util.map("n", "", "m .-2==", { desc = "Move up" }) -Util.map("i", "", "m .+1==gi", { desc = "Move down" }) -Util.map("i", "", "m .-2==gi", { desc = "Move up" }) -Util.map("v", "", ":m '>+1gv=gv", { desc = "Move down" }) -Util.map("v", "", ":m '<-2gv=gv", { desc = "Move up" }) - ------------------------------- --- Windowing + Navigation ------------------------------- - --- better up/down -Util.map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) -Util.map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) - --- resize -Util.map("n", "", "resize +2", { desc = "Increase window height" }) -Util.map("n", "", "resize -2", { desc = "Decrease window height" }) -Util.map("n", "", "vertical resize -2", { desc = "Decrease window width" }) -Util.map("n", "", "vertical resize +2", { desc = "Increase window width" }) - --- split -Util.map("n", "ws", "split", { desc = "[W]indow Horizontal [S]plit" }) -- split horizontal -Util.map("n", "wv", "vsplit", { desc = "[W]indow [V]ertical Split" }) -- split vertical - --- move --- Util.map("n", "wh", "TmuxNavigateLeft", { desc = "Go to Left [W]indow" }) --- Util.map("n", "wj", "TmuxNavigateDown", { desc = "Go to [W]indow Below" }) --- Util.map("n", "wk", "TmuxNavigateUp", { desc = "Go to Top [W]indow" }) --- Util.map("n", "wl", "TmuxNavigateRight", { desc = "Go to Right [W]indow" }) - -if Util.has("bufferline.nvim") then - Util.map("n", "", "BufferLineCyclePrev", { desc = "Prev buffer" }) - Util.map("n", "", "BufferLineCycleNext", { desc = "Next buffer" }) - Util.map("n", "[b", "BufferLineCyclePrev", { desc = "Prev buffer" }) - Util.map("n", "]b", "BufferLineCycleNext", { desc = "Next buffer" }) -else - Util.map("n", "", "bprevious", { desc = "Prev buffer" }) - Util.map("n", "", "bnext", { desc = "Next buffer" }) - Util.map("n", "[b", "bprevious", { desc = "Prev buffer" }) - Util.map("n", "]b", "bnext", { desc = "Next buffer" }) -end - -Util.map("n", "wh", function() - require("smart-splits").resize_left() -end, { desc = "Window Resize Left" }) -Util.map("n", "wj", function() - require("smart-splits").resize_down() -end, { desc = "Window Resize Down" }) -Util.map("n", "wk", function() - require("smart-splits").resize_up() -end, { desc = "Window Resize Up" }) -Util.map("n", "wl", function() - require("smart-splits").resize_right() -end, { desc = "Window Resize Right" }) --- moving between splits --- Util.map("n", "", function() --- require("smart-splits").move_cursor_left() --- end, { desc = "Focus to Left Window" }) --- Util.map("n", "", function() --- require("smart-splits").move_cursor_down() --- end, { desc = "Focus to Lower Window" }) --- Util.map("n", "", function() --- require("smart-splits").move_cursor_up() --- end, { desc = "Focus to Upper Window" }) --- Util.map("n", "", function() --- require("smart-splits").move_cursor_right() --- end, { desc = "Focus to Right Window" }) --- swapping buffers between windows -Util.map("n", "h", function() - require("smart-splits").swap_buf_left() -end, { desc = "Swap Buffer Left" }) -Util.map("n", "j", function() - require("smart-splits").swap_buf_down() -end, { desc = "Swap Buffer Down" }) -Util.map("n", "k", function() - require("smart-splits").swap_buf_up() -end, { desc = "Swap Buffer Up" }) -Util.map("n", "l", function() - require("smart-splits").swap_buf_right() -end, { desc = "Swap Buffer Right" }) - --- tabs -Util.map("n", "l", "tablast", { desc = "Last Tab" }) -Util.map("n", "f", "tabfirst", { desc = "First Tab" }) -Util.map("n", "", "tabnew", { desc = "New Tab" }) -Util.map("n", "]", "tabnext", { desc = "Next Tab" }) -Util.map("n", "d", "tabclose", { desc = "Close Tab" }) -Util.map("n", "[", "tabprevious", { desc = "Previous Tab" }) - --- close -Util.map("n", "wq", "q", { desc = "[W]indow [Q]uit" }) -- quit - ------------------------------- --- Clipboard ------------------------------- - -Util.map("x", "p", [["_dP]]) - -Util.map({ "n", "v" }, "y", [["+y]]) -Util.map("n", "Y", [["+Y]]) - -Util.map({ "n", "v" }, "d", [["_d]]) - -Util.map("i", "", "") - -Util.map("n", "Q", "") - ------------------------------- --- Utilities ------------------------------- - -Util.map("n", "u", vim.cmd.UndotreeToggle) - --- better indenting -Util.map("v", "<", "", ">gv") - --- file permission -Util.map("n", "x", "!chmod +x %", { silent = true }) - -Util.map("n", "mr", "CellularAutomaton make_it_rain") - ------------------------------- --- Terminal ------------------------------- - --- lazygit -Util.map("n", "gg", function() - Util.float_term({ "lazygit" }, { cwd = Util.get_root(), esc_esc = false, ctrl_hjkl = false }) -end, { desc = "Lazygit (root dir)" }) -Util.map("n", "gG", function() - Util.float_term({ "lazygit" }, { esc_esc = false, ctrl_hjkl = false }) -end, { desc = "Lazygit (cwd)" }) - --- float term -local lazyterm = function() - Util.float_term(nil, { cwd = Util.get_root() }) -end -Util.map("n", "tt", lazyterm, { desc = "Terminal (root dir)" }) -Util.map("n", "tT", function() - Util.float_term() -end, { desc = "Terminal (cwd)" }) -Util.map("n", "`", lazyterm, { desc = "Terminal (root dir)" }) -Util.map("n", "", lazyterm, { desc = "Terminal (root dir)" }) -Util.map("n", "", lazyterm, { desc = "which_key_ignore" }) - -Util.map("t", "", "", { desc = "Enter Normal Mode" }) -Util.map("t", "", "close", { desc = "Hide Terminal" }) -Util.map("t", "", "close", { desc = "which_key_ignore" }) - ------------------------------- --- Netrw ------------------------------- - --- netrw --- Util.map("n", "e", function() --- vim.cmd("Ex") --- end) - --- remap q to quit buffer in netrw -vim.api.nvim_create_autocmd("FileType", { - pattern = "netrw", - command = "nnoremap q bd", -}) - --- disable ctrl-h and ctrl-l in netrw and change it to TmuxNavigateLeft and TmuxNavigateRight -vim.api.nvim_create_autocmd("FileType", { - pattern = "netrw", - command = "nnoremap TmuxNavigateLeft", -}) - -vim.api.nvim_create_autocmd("FileType", { - pattern = "netrw", - command = "nnoremap TmuxNavigateRight", -}) - --- change refresh netrw to r -vim.api.nvim_create_autocmd("FileType", { - pattern = "netrw", - command = "nnoremap r edit", -}) - ------------------------------- --- Others ------------------------------- - --- ufo -Util.map("n", "zR", function() - require("ufo").openAllFolds() -end) -Util.map("n", "zM", function() - require("ufo").closeAllFolds() -end) - --- lazy -Util.map("n", "l", "Lazy", { desc = "Lazy" }) - --- source file -Util.map("n", "s", function() - vim.cmd("so") -end, { desc = "Source File" }) diff --git a/lua/rayandrew/root.lua b/lua/rayandrew/root.lua deleted file mode 100644 index 45bffda..0000000 --- a/lua/rayandrew/root.lua +++ /dev/null @@ -1,205 +0,0 @@ -local lazy_util = require("lazy.util") - ----@class lazyvim.util.root ----@overload fun(): string -local M = setmetatable({}, { - __call = function(m) - return m.get() - end, -}) - ----@class LazyRoot ----@field paths string[] ----@field spec LazyRootSpec - ----@alias LazyRootFn fun(buf: number): (string|string[]) - ----@alias LazyRootSpec string|string[]|LazyRootFn - ----@type LazyRootSpec[] -M.spec = { "lsp", { ".git", "lua" }, "cwd" } - -M.detectors = {} - -function M.detectors.cwd() - return { vim.uv.cwd() } -end - -function M.detectors.lsp(buf) - local bufpath = M.bufpath(buf) - if not bufpath then - return {} - end - local roots = {} ---@type string[] - for _, client in pairs(LazyVim.lsp.get_clients({ bufnr = buf })) do - -- only check workspace folders, since we're not interested in clients - -- running in single file mode - local workspace = client.config.workspace_folders - for _, ws in pairs(workspace or {}) do - roots[#roots + 1] = vim.uri_to_fname(ws.uri) - end - end - return vim.tbl_filter(function(path) - path = lazy_util.norm(path) - return path and bufpath:find(path, 1, true) == 1 - end, roots) -end - ----@param patterns string[]|string -function M.detectors.pattern(buf, patterns) - patterns = type(patterns) == "string" and { patterns } or patterns - local path = M.bufpath(buf) or vim.uv.cwd() - local pattern = vim.fs.find(function(name) - for _, p in ipairs(patterns) do - if name == p then - return true - end - if p:sub(1, 1) == "*" and name:find(p:sub(2) .. "$") then - return true - end - end - return false - end, { path = path, upward = true })[1] - return pattern and { vim.fs.dirname(pattern) } or {} -end - -function M.bufpath(buf) - return M.realpath(vim.api.nvim_buf_get_name(assert(buf))) -end - -function M.cwd() - return M.realpath(vim.uv.cwd()) or "" -end - -function M.realpath(path) - if path == "" or path == nil then - return nil - end - path = vim.uv.fs_realpath(path) or path - return lazy_util.norm(path) -end - ----@param spec LazyRootSpec ----@return LazyRootFn -function M.resolve(spec) - if M.detectors[spec] then - return M.detectors[spec] - elseif type(spec) == "function" then - return spec - end - return function(buf) - return M.detectors.pattern(buf, spec) - end -end - ----@param opts? { buf?: number, spec?: LazyRootSpec[], all?: boolean } -function M.detect(opts) - opts = opts or {} - opts.spec = opts.spec or type(vim.g.root_spec) == "table" and vim.g.root_spec or M.spec - opts.buf = (opts.buf == nil or opts.buf == 0) and vim.api.nvim_get_current_buf() or opts.buf - - local ret = {} ---@type LazyRoot[] - for _, spec in ipairs(opts.spec) do - local paths = M.resolve(spec)(opts.buf) - paths = paths or {} - paths = type(paths) == "table" and paths or { paths } - local roots = {} ---@type string[] - for _, p in ipairs(paths) do - local pp = M.realpath(p) - if pp and not vim.tbl_contains(roots, pp) then - roots[#roots + 1] = pp - end - end - table.sort(roots, function(a, b) - return #a > #b - end) - if #roots > 0 then - ret[#ret + 1] = { spec = spec, paths = roots } - if opts.all == false then - break - end - end - end - return ret -end - -function M.info() - local spec = type(vim.g.root_spec) == "table" and vim.g.root_spec or M.spec - - local roots = M.detect({ all = true }) - local lines = {} ---@type string[] - local first = true - for _, root in ipairs(roots) do - for _, path in ipairs(root.paths) do - lines[#lines + 1] = ("- [%s] `%s` **(%s)**"):format( - first and "x" or " ", - path, - type(root.spec) == "table" and table.concat(root.spec, ", ") or root.spec - ) - first = false - end - end - lines[#lines + 1] = "```lua" - lines[#lines + 1] = "vim.g.root_spec = " .. vim.inspect(spec) - lines[#lines + 1] = "```" - LazyVim.info(lines, { title = "LazyVim Roots" }) - return roots[1] and roots[1].paths[1] or vim.uv.cwd() -end - ----@type table -M.cache = {} - -function M.setup() - vim.api.nvim_create_user_command("LazyRoot", function() - LazyVim.root.info() - end, { desc = "LazyVim roots for the current buffer" }) - - -- FIX: doesn't properly clear cache in neo-tree `set_root` (which should happen presumably on `DirChanged`), - -- probably because the event is triggered in the neo-tree buffer, therefore add `BufEnter` - -- Maybe this is too frequent on `BufEnter` and something else should be done instead?? - vim.api.nvim_create_autocmd({ "LspAttach", "BufWritePost", "DirChanged", "BufEnter" }, { - group = vim.api.nvim_create_augroup("lazyvim_root_cache", { clear = true }), - callback = function(event) - M.cache[event.buf] = nil - end, - }) -end - --- returns the root directory based on: --- * lsp workspace folders --- * lsp root_dir --- * root pattern of filename of the current buffer --- * root pattern of cwd ----@param opts? {normalize?:boolean} ----@return string -function M.get(opts) - local buf = vim.api.nvim_get_current_buf() - local ret = M.cache[buf] - if not ret then - local roots = M.detect({ all = false }) - ret = roots[1] and roots[1].paths[1] or vim.uv.cwd() - M.cache[buf] = ret - end - if opts and opts.normalize then - return ret - end - return M.is_win() and ret:gsub("/", "\\") or ret -end - -function M.is_win() - return vim.uv.os_uname().sysname:find("Windows") ~= nil -end - -function M.git() - local root = M.get() - local git_root = vim.fs.find(".git", { path = root, upward = true })[1] - local ret = git_root and vim.fn.fnamemodify(git_root, ":h") or root - return ret -end - ----@param opts? {hl_last?: string} -function M.pretty_path(opts) - return "" -end - -return M diff --git a/lua/rayandrew/set.lua b/lua/rayandrew/set.lua deleted file mode 100644 index 93d69b3..0000000 --- a/lua/rayandrew/set.lua +++ /dev/null @@ -1,94 +0,0 @@ -vim.g.mapleader = " " -vim.g.maplocalleader = "\\" - -vim.g.netrw_browse_split = 0 -vim.g.netrw_banner = 0 -vim.g.netrw_winsize = 25 - -local opt = vim.opt - -opt.guicursor = "" - -opt.autowrite = true -- Enable auto write -opt.backup = false -opt.clipboard = "unnamedplus" -- Sync with system clipboard -opt.completeopt = "menu,menuone,noselect" -opt.conceallevel = 3 -- Hide * markup for bold and italic -opt.confirm = true -- Confirm to save changes before exiting modified buffer -opt.cursorline = true -- Enable highlighting of the current line -opt.expandtab = true -- Use spaces instead of tabs -opt.formatoptions = "jcroqlnt" -- tcqj -opt.grepformat = "%f:%l:%c:%m" --- opt.grepformat = { "%f:%l:%c:%m", "%f:%l:%m,%f" } -opt.grepprg = "rg --vimgrep" -opt.hlsearch = false -opt.ignorecase = true -- Ignore case -opt.incsearch = true -opt.inccommand = "nosplit" -- preview incremental substitute -opt.laststatus = 2 -opt.list = true -- Show some invisible characters (tabs... -opt.mouse = "a" -- Enable mouse mode -opt.nu = true -opt.number = true -- Print line number -opt.pumblend = 10 -- Popup blend -opt.pumheight = 10 -- Maximum number of entries in a popup -opt.relativenumber = true -- Relative line numbers -opt.ruler = false -- Disable ruler -opt.scrolloff = 4 -- Lines of context -opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" } -opt.shiftround = true -- Round indent -opt.shiftwidth = 2 -- Size of an indent -opt.shortmess:append({ W = true, I = true, c = true }) -opt.showmode = false -- Dont show mode since we have a statusline -opt.sidescrolloff = 8 -- Columns of context -opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time -opt.smartcase = true -- Don't ignore case with capitals -opt.smartindent = true -- Insert indents automatically -opt.softtabstop = 2 -opt.spelllang = { "en" } -opt.splitbelow = true -- Put new windows below current -opt.splitright = true -- Put new windows right of current -opt.swapfile = false -opt.tabstop = 2 -- Number of spaces tabs count for -opt.termguicolors = true -- True color support -opt.timeoutlen = 300 -opt.undodir = os.getenv("HOME") .. "/.vim/undodir" -- Set an undo directory -opt.undofile = true -opt.undolevels = 10000 -opt.updatetime = 200 -- Save swap file and trigger CursorHold -opt.wildmode = "longest:full,full" -- Command-line completion mode -opt.winminwidth = 5 -- Minimum window width -opt.wrap = false -- Disable line wrap - --- For UFO --- vim.o.foldcolumn = "1" -vim.o.foldcolumn = "0" -vim.o.foldlevel = 99 -vim.o.foldlevelstart = 99 -vim.o.foldenable = true --- vim.o.fillchars = [[eob: ,fold: ,foldopen:๏‘ผ,foldsep: ,foldclose:๏‘ ]] - -if vim.fn.has("nvim-0.9.0") == 1 then - opt.splitkeep = "screen" - opt.shortmess:append({ C = true }) -end - --- Fix markdown indentation settings -vim.g.markdown_recommended_style = 0 - -opt.isfname:append("@-@") - -opt.colorcolumn = "80" - --- Error Format --- error format for location list -opt.errorformat:append("%f|%l col %c|%m") --- error format for quickfix -opt.errorformat:append("%f|%l|%m") --- error format for grep -rn -opt.errorformat:append("%f:%l:%m") --- error format for ls -opt.errorformat:append("%f:%l:%m") --- error format for ls -la -opt.errorformat:append("%f:%l:%m,%f") -opt.errorformat:append("%gggggg") diff --git a/lua/rayandrew/statusline.lua b/lua/rayandrew/statusline.lua deleted file mode 100644 index c369079..0000000 --- a/lua/rayandrew/statusline.lua +++ /dev/null @@ -1,132 +0,0 @@ --- credit goes to --- https://nuxsh.is-a.dev/blog/custom-nvim-statusline.html - -local M = {} - -local modes = { - ["n"] = "NORMAL", - ["no"] = "NORMAL", - ["v"] = "VISUAL", - ["V"] = "VISUAL LINE", - [""] = "VISUAL BLOCK", - ["s"] = "SELECT", - ["S"] = "SELECT LINE", - [""] = "SELECT BLOCK", - ["i"] = "INSERT", - ["ic"] = "INSERT", - ["R"] = "REPLACE", - ["Rv"] = "VISUAL REPLACE", - ["c"] = "COMMAND", - ["cv"] = "VIM EX", - ["ce"] = "EX", - ["r"] = "PROMPT", - ["rm"] = "MOAR", - ["r?"] = "CONFIRM", - ["!"] = "SHELL", - ["t"] = "TERMINAL", -} - -local function mode() - local current_mode = vim.api.nvim_get_mode().mode - return string.format(" %s ", modes[current_mode]):upper() -end - -local function filepath() - local fpath = vim.fn.fnamemodify(vim.fn.expand("%"), ":~:.:h") - if fpath == "" or fpath == "." then - return " " - end - - return string.format(" %%<%s/", fpath) -end - -local function update_mode_colors() - local current_mode = vim.api.nvim_get_mode().mode - local mode_color = "%#StatusLineAccent#" - if current_mode == "n" then - mode_color = "%#StatuslineAccent#" - elseif current_mode == "i" or current_mode == "ic" then - mode_color = "%#StatuslineInsertAccent#" - elseif current_mode == "v" or current_mode == "V" or current_mode == "" then - mode_color = "%#StatuslineVisualAccent#" - elseif current_mode == "R" then - mode_color = "%#StatuslineReplaceAccent#" - elseif current_mode == "c" then - mode_color = "%#StatuslineCmdLineAccent#" - elseif current_mode == "t" then - mode_color = "%#StatuslineTerminalAccent#" - end - return mode_color -end - -local function filename() - local fname = vim.fn.expand("%:t") - if fname == "" then - return "" - end - return fname .. " " -end - -function M.render_active() - local parts = { - "%#Statusline#", - update_mode_colors(), - mode(), - "%#Normal# ", - "%=%#StatusLineExtra#", - filepath(), - filename(), - } - - local statusline = table.concat(parts, "") - - return statusline -end - -function M.render_inactive() - local parts = { - "%#Statusline#", - "%#Normal# ", - "%=%#StatusLineExtra#", - } - local statusline = table.concat(parts, "") - return statusline -end - --- function M.render(opts) --- opts = opts or {} --- local active = opts.active or false --- local statusline = "" --- if active then --- statusline = M.render_active() --- else --- statusline = M.render_inactive() --- end --- vim.opt_local.statusline = statusline --- end - -function M.setup() - local augroup = require("rayandrew.util").augroup - local autocmd = vim.api.nvim_create_autocmd - - -- Statusline - autocmd({ "BufEnter", "BufWinEnter", "WinEnter" }, { - group = augroup("statusline-enter"), - pattern = "*", - callback = function() - vim.opt_local.statusline = "%!v:lua.require('rayandrew.statusline').render_active()" - end, - -- command = [[lua require("rayandrew.statusline").render({ active = true })]], - }) - - autocmd({ "BufLeave", "BufWinLeave", "WinLeave" }, { - group = augroup("statusline-leave"), - pattern = "*", - callback = function() - vim.opt_local.statusline = "%!v:lua.require('rayandrew.statusline').render_inactive()" - end, - -- command = [[lua require("rayandrew.statusline").render({ active = false })]], - }) -end - -return M diff --git a/lua/rayandrew/theme.lua b/lua/rayandrew/theme.lua deleted file mode 100644 index 0fae810..0000000 --- a/lua/rayandrew/theme.lua +++ /dev/null @@ -1,104 +0,0 @@ -local M = {} - --- M.colorscheme = "rose-pine" --- M.colorscheme = "meh" --- M.colorscheme = "rasmus" --- M.colorscheme = "everforest" -M.colorscheme = "gruber-darker" -M.background = "dark" --- M.colorscheme = "" - -function M.setup() - -- taken from https://github.com/LazyVim/LazyVim/blob/566049aa4a26a86219dd1ad1624f9a1bf18831b6/lua/lazyvim/config/init.lua#L117C3-L129C5 - require("lazy.core.util").try(function() - if M.colorscheme == "" then - return - end - - if type(M.colorscheme) == "function" then - M.colorscheme() - else - vim.cmd.colorscheme(M.colorscheme) - end - - if M.background == "" then - return - end - - vim.o.background = M.background - end, { - msg = "Could not load your colorscheme", - on_error = function(msg) - require("lazy.core.util").error(msg) - vim.cmd.colorscheme("habamax") - end, - }) -end - -M.icons = { - dap = { - Stopped = { "๓ฐ• ", "DiagnosticWarn", "DapStoppedLine" }, - Breakpoint = "๏†’ ", - BreakpointCondition = "๏™ ", - BreakpointRejected = { "๏ช ", "DiagnosticError" }, - LogPoint = ".>", - }, - diagnostics = { - Error = "๏— ", - Warn = "๏ฑ ", - Hint = "๏ƒซ ", - Info = "๏š ", - }, - git = { - added = "๏ƒพ ", - modified = "๏…‹ ", - removed = "๏…† ", - }, - kinds = { - Array = "๎ชŠ ", - Boolean = "๎ช ", - Class = "๎ญ› ", - Color = "๎ญœ ", - Constant = "๎ญ ", - Constructor = "๎ชŒ ", - Copilot = "๎œˆ ", - Enum = "๎ช• ", - EnumMember = "๎ญž ", - Event = "๎ช† ", - Field = "๎ญŸ ", - File = "๎ฉป ", - Folder = "๎—ฟ ", - Function = "๎ชŒ ", - Interface = "๎ญก ", - Key = "๎ช“ ", - Keyword = "๎ญข ", - Method = "๎ชŒ ", - Module = "๎ฌฉ ", - Namespace = "๎ช‹ ", - Null = "๎Š™ ", - Number = "๎ช ", - Object = "๎ช‹ ", - Operator = "๎ญค ", - Package = "๎ฌฉ ", - Property = "๎ญฅ ", - Reference = "๎ฌถ ", - Snippet = "๎ญฆ ", - String = "๎ฎ ", - Struct = "๎ช‘ ", - Text = "๎ช“ ", - TypeParameter = "๎ช’ ", - Unit = "๎ช– ", - Value = "๎ช“ ", - Variable = "๎ชˆ ", - }, -} - -function M.recolor(color) - color = color or M.colorscheme - vim.cmd.colorscheme(color) - - vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) - vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) -end - -return M diff --git a/lua/rayandrew/tools.lua b/lua/rayandrew/tools.lua deleted file mode 100644 index dd5a8f0..0000000 --- a/lua/rayandrew/tools.lua +++ /dev/null @@ -1,104 +0,0 @@ -local M = {} - -local lsps = { - lua = { "lua-language-server" }, - python = { "pyright" }, - rust = { "rust_analyzer" }, -} - --- https://github.com/chrisgrieser/.config/blob/7dc36c350976010b32ece078edd581687634811a/nvim/lua/plugins/linter-formatter.lua#L214-L234 -M.linters = { - lua = { "selene" }, - css = { "stylelint" }, - sh = { "shellcheck" }, - markdown = { "markdownlint", "vale" }, - yaml = { "yamllint" }, - python = { "pylint" }, - gitcommit = {}, - json = {}, - javascript = {}, - typescript = {}, - toml = {}, - applescript = {}, - bib = {}, -} - --- https://github.com/chrisgrieser/.config/blob/7dc36c350976010b32ece078edd581687634811a/nvim/lua/plugins/linter-formatter.lua#L214-L234 --- PENDING https://github.com/mfussenegger/nvim-lint/issues/355 -for ft, _ in pairs(M.linters) do - table.insert(M.linters[ft], "codespell") - table.insert(M.linters[ft], "editorconfig-checker") -end - --- https://github.com/chrisgrieser/.config/blob/7dc36c350976010b32ece078edd581687634811a/nvim/lua/plugins/linter-formatter.lua#L214-L234 -M.formatters = { - lua = { "stylua" }, - python = { "isort", "black" }, - javascript = { "biome" }, - typescript = { "biome" }, - json = { "biome" }, - jsonc = { "biome" }, - nix = { "alejandra" }, - yaml = { "prettier" }, - html = { "prettier" }, - rust = { "rustfmt" }, - markdown = { - "markdown-toc", - "markdownlint", - -- "injected", - }, - css = { "stylelint", "prettier" }, - sh = { "shellcheck", "shfmt" }, - bib = { "trim_whitespace", "bibtex-tidy" }, - ["_"] = { "trim_whitespace", "trim_newlines", "squeeze_blanks" }, - -- ["*"] = { "codespell" }, -} - -M.debuggers = {} - -M.dontInstall = { - -- installed externally due to its plugins: https://github.com/williamboman/mason.nvim/issues/695 - "stylelint", - -- not real formatters, but pseudo-formatters from conform.nvim - "trim_whitespace", - "trim_newlines", - "squeeze_blanks", - "injected", - "alejandra", - "nixpkgs_fmt", -} - ----given the linter- and formatter-list of nvim-lint and conform.nvim, extract a ----list of all tools that need to be auto-installed ----@param myLinters object[] ----@param myFormatters object[] ----@param myDebuggers string[] ----@param ignoreTools string[] ----@return string[] tools ----@nodiscard -function toolsToAutoinstall(myLinters, myFormatters, myDebuggers, ignoreTools) - -- get all linters, formatters, & debuggers and merge them into one list - local lspList = vim.tbl_flatten(vim.tbl_values(lsps)) - local linterList = vim.tbl_flatten(vim.tbl_values(myLinters)) - local formatterList = vim.tbl_flatten(vim.tbl_values(myFormatters)) - local tools = vim.list_extend(linterList, formatterList) - vim.list_extend(tools, lspList) - vim.list_extend(tools, myDebuggers) - - -- only unique tools - table.sort(tools) - tools = vim.fn.uniq(tools) - - -- remove exceptions not to install - tools = vim.tbl_filter(function(tool) - return not vim.tbl_contains(ignoreTools, tool) - end, tools) - return tools -end - -function M.getToolsToInstall() - local tools = toolsToAutoinstall(M.linters, M.formatters, M.debuggers, M.dontInstall) - return tools -end - -return M diff --git a/lua/rayandrew/util.lua b/lua/rayandrew/util.lua deleted file mode 100644 index 5d7e823..0000000 --- a/lua/rayandrew/util.lua +++ /dev/null @@ -1,265 +0,0 @@ -local root = require("rayandrew.root") - --- shamelessly copied from --- https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/util/init.lua - -local M = {} - -function M.augroup(name) - return vim.api.nvim_create_augroup("rayandrew_" .. name, { clear = true }) -end - ----@param on_attach fun(client, buffer) -function M.on_attach(on_attach) - vim.api.nvim_create_autocmd("LspAttach", { - callback = function(args) - local buffer = args.buf - local client = vim.lsp.get_client_by_id(args.data.client_id) - on_attach(client, buffer) - end, - }) -end - -function M.fg(name) - ---@type {foreground?:number}? - local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) or vim.api.nvim_get_hl_by_name(name, true) - local fg = hl and hl.fg or hl.foreground - return fg and { fg = string.format("#%06x", fg) } -end - -function M.map(mode, lhs, rhs, opts) - local has_handler, handler = pcall(require, "lazy.core.handler") - if has_handler then - local keys = handler.handlers.keys - ---@cast keys LazyKeysHandler - -- do not create the keymap if a lazy keys handler exists - if not keys.active[keys.parse({ lhs, mode = mode }).id] then - opts = opts or {} - opts.silent = opts.silent ~= false - vim.keymap.set(mode, lhs, rhs, opts) - end - return - end - - vim.keymap.set(mode, lhs, rhs, opts) -end - -M.root_patterns = { ".git", "lua" } - --- returns the root directory based on: --- * lsp workspace folders --- * lsp root_dir --- * root pattern of filename of the current buffer --- * root pattern of cwd ----@return string -function M.get_root() - ---@type string? - local path = vim.api.nvim_buf_get_name(0) - path = path ~= "" and vim.loop.fs_realpath(path) or nil - ---@type string[] - local roots = {} - if path then - for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do - local workspace = client.config.workspace_folders - local paths = workspace - and vim.tbl_map(function(ws) - return vim.uri_to_fname(ws.uri) - end, workspace) - or client.config.root_dir and { client.config.root_dir } - or {} - for _, p in ipairs(paths) do - local r = vim.loop.fs_realpath(p) - if path:find(r, 1, true) then - roots[#roots + 1] = r - end - end - end - end - table.sort(roots, function(a, b) - return #a > #b - end) - ---@type string? - local root = roots[1] - if not root then - path = path and vim.fs.dirname(path) or vim.loop.cwd() - ---@type string? - root = vim.fs.find(M.root_patterns, { path = path, upward = true })[1] - root = root and vim.fs.dirname(root) or vim.loop.cwd() - end - ---@cast root string - return root -end - --- function M.telescope(builtin, opts) --- local params = { builtin = builtin, opts = opts } --- return function() --- builtin = params.builtin --- opts = params.opts --- opts = vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {}) --- if builtin == "files" then --- if vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.git") then --- opts.show_untracked = true --- builtin = "git_files" --- else --- builtin = "find_files" --- end --- end --- if opts.cwd and opts.cwd ~= vim.loop.cwd() then --- opts.attach_mappings = function(_, map) --- map("i", "", function() --- local action_state = require("telescope.actions.state") --- local line = action_state.get_current_line() --- M.telescope( --- params.builtin, --- vim.tbl_deep_extend("force", {}, params.opts or {}, { cwd = false, default_text = line }) --- )() --- end) --- return true --- end --- end --- --- require("telescope.builtin")[builtin](opts) --- end --- end - --- this will return a function that calls telescope. --- cwd will default to lazyvim.util.get_root --- for `files`, git_files or find_files will be chosen depending on .git ----@param builtin string ----@param opts? lazyvim.util.telescope.opts -function M.telescope(builtin, opts) - local params = { builtin = builtin, opts = opts } - return function() - builtin = params.builtin - opts = params.opts - opts = vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {}) --[[@as lazyvim.util.telescope.opts]] - if builtin == "files" then - if - vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.git") - and not vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.ignore") - and not vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.rgignore") - then - if opts.show_untracked == nil then - opts.show_untracked = true - end - builtin = "git_files" - else - builtin = "find_files" - end - end - if opts.cwd and opts.cwd ~= vim.uv.cwd() then - local function open_cwd_dir() - local action_state = require("telescope.actions.state") - local line = action_state.get_current_line() - M.telescope( - params.builtin, - vim.tbl_deep_extend("force", {}, params.opts or {}, { cwd = false, default_text = line }) - )() - end - ---@diagnostic disable-next-line: inject-field - opts.attach_mappings = function(_, map) - -- opts.desc is overridden by telescope, until it's changed there is this fix - map("i", "", open_cwd_dir, { desc = "Open cwd Directory" }) - return true - end - end - - require("telescope.builtin")[builtin](opts) - end -end - ----@type table -local terminals = {} - -function M.float_term(cmd, opts) - opts = vim.tbl_deep_extend("force", { - ft = "lazyterm", - size = { width = 0.9, height = 0.9 }, - }, opts or {}, { persistent = true }) - ---@cast opts LazyCmdOptions|{interactive?:boolean, esc_esc?:false} - - local termkey = vim.inspect({ - cmd = cmd or "shell", - cwd = opts.cwd, - env = opts.env, - count = vim.v.count1, - }) - - if terminals[termkey] and terminals[termkey]:buf_valid() then - terminals[termkey]:toggle() - else - terminals[termkey] = require("lazy.util").float_term(cmd, opts) - local buf = terminals[termkey].buf - vim.b[buf].lazyterm_cmd = cmd - if opts.esc_esc == false then - vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) - end - if opts.ctrl_hjkl == false then - vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) - vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) - vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) - vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) - end - - vim.api.nvim_create_autocmd("BufEnter", { - buffer = buf, - callback = function() - vim.cmd.startinsert() - end, - }) - end - - return terminals[termkey] -end - -function M.has(plugin) - return require("lazy.core.config").spec.plugins[plugin] ~= nil -end - -function M.on_very_lazy(fn) - vim.api.nvim_create_autocmd("User", { - pattern = "VeryLazy", - callback = function() - fn() - end, - }) -end - -function M.lazy_file() - -- This autocmd will only trigger when a file was loaded from the cmdline. - -- It will render the file as quickly as possible. - vim.api.nvim_create_autocmd("BufReadPost", { - once = true, - callback = function(event) - -- Skip if we already entered vim - if vim.v.vim_did_enter == 1 then - return - end - - -- Try to guess the filetype (may change later on during Neovim startup) - local ft = vim.filetype.match({ buf = event.buf }) - if ft then - -- Add treesitter highlights and fallback to syntax - local lang = vim.treesitter.language.get_lang(ft) - if not (lang and pcall(vim.treesitter.start, event.buf, lang)) then - vim.bo[event.buf].syntax = ft - end - - -- Trigger early redraw - vim.cmd([[redraw]]) - end - end, - }) - - -- Add support for the LazyFile event - local Event = require("lazy.core.handler.event") - - Event.mappings.LazyFile = { id = "LazyFile", event = M.lazy_file_events } - Event.mappings["User LazyFile"] = Event.mappings.LazyFile -end - -function M.setup() - -- M.lazy_file() -end - -return M diff --git a/stylua.toml b/stylua.toml deleted file mode 100644 index 0f90030..0000000 --- a/stylua.toml +++ /dev/null @@ -1,3 +0,0 @@ -indent_type = "Spaces" -indent_width = 2 -column_width = 120