diff --git a/README.md b/README.md index 8ef72cb0..b8f97bf4 100644 --- a/README.md +++ b/README.md @@ -1,59 +1,60 @@ ## Plugins |Plugin|Description| |---|---| -|[akinsho/toggleterm.nvim](https://github.com/akinsho/toggleterm.nvim)|A neovim lua plugin to help easily manage multiple terminal windows| |[b0o/schemastore.nvim](https://github.com/b0o/schemastore.nvim)|🛍 JSON schemas for Neovim| -|[eandrju/cellular-automaton.nvim](https://github.com/eandrju/cellular-automaton.nvim)|A useless plugin that might help you cope with stubbornly broken tests or overall lack of sense in life. It lets you execute aesthetically pleasing, cellular automaton animations based on the content of neovim buffer.| -|[fladson/vim-kitty](https://github.com/fladson/vim-kitty)|Vim syntax highlighting for Kitty terminal config files| +|[chrisgrieser/cmp-nerdfont](https://github.com/chrisgrieser/cmp-nerdfont)|nvim-cmp source for nerdfont icons| +|[davidsierradz/cmp-conventionalcommits](https://github.com/davidsierradz/cmp-conventionalcommits)|(WIP) nvim-cmp source for autocompleting git commits with conventional commits types and lerna packages as scope| +|[epwalsh/obsidian.nvim](https://github.com/epwalsh/obsidian.nvim)|Neovim plugin for Obsidian, written in Lua| |[folke/neodev.nvim](https://github.com/folke/neodev.nvim)|💻 Neovim setup for init.lua and plugin development with full signature help, docs and completion for the nvim lua API.| -|[folke/zen-mode.nvim](https://github.com/folke/zen-mode.nvim)|🧘 Distraction-free coding for Neovim| +|[folke/noice.nvim](https://github.com/folke/noice.nvim)|💥 Highly experimental plugin that completely replaces the UI for messages, cmdline and the popupmenu.| +|[folke/trouble.nvim](https://github.com/folke/trouble.nvim)|🚦 A pretty diagnostics, references, telescope results, quickfix and location list to help you solve all the trouble your code is causing.| |[freddiehaddad/feline.nvim](https://github.com/freddiehaddad/feline.nvim)|A minimal, stylish and customizable statusline / winbar for Neovim written in Lua| -|[glacambre/firenvim](https://github.com/glacambre/firenvim)|Embed Neovim in Chrome, Firefox & others.| -|[godlygeek/tabular](https://github.com/godlygeek/tabular)|Vim script for text filtering and alignment| +|[github/copilot.vim](https://github.com/github/copilot.vim)|Neovim plugin for GitHub Copilot| |[HiPhish/nvim-ts-rainbow2](https://github.com/HiPhish/nvim-ts-rainbow2)|Rainbow delimiters for Neovim through Tree-sitter| |[hrsh7th/cmp-buffer](https://github.com/hrsh7th/cmp-buffer)|nvim-cmp source for buffer words| |[hrsh7th/cmp-cmdline](https://github.com/hrsh7th/cmp-cmdline)|nvim-cmp source for vim's cmdline| |[hrsh7th/cmp-nvim-lsp](https://github.com/hrsh7th/cmp-nvim-lsp)|nvim-cmp source for neovim builtin LSP client| +|[hrsh7th/cmp-nvim-lsp-document-symbol](https://github.com/hrsh7th/cmp-nvim-lsp-document-symbol)|nvim-cmp source for textDocument/documentSymbol via nvim-lsp.| +|[hrsh7th/cmp-nvim-lsp-signature-help](https://github.com/hrsh7th/cmp-nvim-lsp-signature-help)|cmp-nvim-lsp-signature-help| +|[hrsh7th/cmp-nvim-lua](https://github.com/hrsh7th/cmp-nvim-lua)|nvim-cmp source for nvim lua| |[hrsh7th/cmp-path](https://github.com/hrsh7th/cmp-path)|nvim-cmp source for path| |[hrsh7th/nvim-cmp](https://github.com/hrsh7th/nvim-cmp)|A completion plugin for neovim coded in Lua.| -|[iamcco/markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim)|markdown preview plugin for (neo)vim| -|[jakewvincent/mkdnflow.nvim](https://github.com/jakewvincent/mkdnflow.nvim)|Fluent navigation and management of markdown notebooks| -|[jay-babu/mason-null-ls.nvim](https://github.com/jay-babu/mason-null-ls.nvim)|| +|[ibhagwan/fzf-lua](https://github.com/ibhagwan/fzf-lua)|Improved fzf.vim written in lua| |[JoosepAlviste/nvim-ts-context-commentstring](https://github.com/JoosepAlviste/nvim-ts-context-commentstring)|Neovim treesitter plugin for setting the commentstring based on the cursor location in a file.| |[jose-elias-alvarez/null-ls.nvim](https://github.com/jose-elias-alvarez/null-ls.nvim)|Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.| -|[jose-elias-alvarez/typescript.nvim](https://github.com/jose-elias-alvarez/typescript.nvim)|A Lua plugin, written in TypeScript, to write TypeScript (Lua optional).| |[jparise/vim-graphql](https://github.com/jparise/vim-graphql)|A Vim plugin that provides GraphQL file detection, syntax highlighting, and indentation.| -|[junegunn/vim-easy-align](https://github.com/junegunn/vim-easy-align)|:sunflower: A Vim alignment plugin| |[kylechui/nvim-surround](https://github.com/kylechui/nvim-surround)|Add/change/delete surrounding delimiter pairs with ease. Written with :heart: in Lua.| |[L3MON4D3/LuaSnip](https://github.com/L3MON4D3/LuaSnip)|Snippet Engine for Neovim written in Lua.| -|[lewis6991/impatient.nvim](https://github.com/lewis6991/impatient.nvim)|Improve startup time for Neovim| +|[lewis6991/gitsigns.nvim](https://github.com/lewis6991/gitsigns.nvim)|Git integration for buffers| |[lukas-reineke/headlines.nvim](https://github.com/lukas-reineke/headlines.nvim)|This plugin adds horizontal highlights for text filetypes, like markdown, orgmode, and neorg.| |[lukas-reineke/indent-blankline.nvim](https://github.com/lukas-reineke/indent-blankline.nvim)|Indent guides for Neovim| +|[lvimuser/lsp-inlayhints.nvim](https://github.com/lvimuser/lsp-inlayhints.nvim)|| |[mbbill/undotree](https://github.com/mbbill/undotree)|The undo history visualizer for VIM| +|[MunifTanjim/nui.nvim](https://github.com/MunifTanjim/nui.nvim)|UI Component Library for Neovim.| |[neovim/nvim-lspconfig](https://github.com/neovim/nvim-lspconfig)|Quickstart configs for Nvim LSP| |[numToStr/Comment.nvim](https://github.com/numToStr/Comment.nvim)|:brain: :muscle: // Smart and powerful comment plugin for neovim. Supports treesitter, dot repeat, left-right/up-down motions, hooks, and more| |[NvChad/nvim-colorizer.lua](https://github.com/NvChad/nvim-colorizer.lua)|Maintained fork of the fastest Neovim colorizer| |[nvim-lua/plenary.nvim](https://github.com/nvim-lua/plenary.nvim)|plenary: full; complete; entire; absolute; unqualified. All the lua functions I don't want to write twice.| -|[nvim-telescope/telescope-fzf-native.nvim](https://github.com/nvim-telescope/telescope-fzf-native.nvim)|FZF sorter for telescope written in c| -|[nvim-telescope/telescope-node-modules.nvim](https://github.com/nvim-telescope/telescope-node-modules.nvim)|An extension that provides its users with node packages under node_modules directory| -|[nvim-telescope/telescope-ui-select.nvim](https://github.com/nvim-telescope/telescope-ui-select.nvim)|| -|[nvim-telescope/telescope.nvim](https://github.com/nvim-telescope/telescope.nvim)|Find, Filter, Preview, Pick. All lua, all the time.| +|[nvim-neo-tree/neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim)|Neovim plugin to manage the file system and other tree like structures.| |[nvim-tree/nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons)|lua `fork` of vim-web-devicons for neovim| |[nvim-treesitter/nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)|Nvim Treesitter configurations and abstraction layer| |[nvim-treesitter/nvim-treesitter-context](https://github.com/nvim-treesitter/nvim-treesitter-context)|Show code context| |[nvim-treesitter/nvim-treesitter-textobjects](https://github.com/nvim-treesitter/nvim-treesitter-textobjects)|| -|[rafamadriz/friendly-snippets](https://github.com/rafamadriz/friendly-snippets)|Set of preconfigured snippets for different languages. | +|[petertriho/cmp-git](https://github.com/petertriho/cmp-git)|Git source for nvim-cmp| |[ray-x/cmp-treesitter](https://github.com/ray-x/cmp-treesitter)|cmp source for treesitter| |[rcarriga/nvim-notify](https://github.com/rcarriga/nvim-notify)|A fancy, configurable, notification manager for NeoVim| +|[s1n7ax/nvim-window-picker](https://github.com/s1n7ax/nvim-window-picker)|This plugins prompts the user to pick a window and returns the window id of the picked window| |[saadparwaiz1/cmp_luasnip](https://github.com/saadparwaiz1/cmp_luasnip)|luasnip completion source for nvim-cmp| |[simrat39/symbols-outline.nvim](https://github.com/simrat39/symbols-outline.nvim)|A tree like view for symbols in Neovim using the Language Server Protocol. Supports all your favourite languages.| -|[snelling-a/better-folds.nvim](https://github.com/snelling-a/better-folds.nvim)|better-folds.nvim| +|[SmiteshP/nvim-navic](https://github.com/SmiteshP/nvim-navic)|Simple winbar/statusline plugin that shows your current code context| +|[snelling-a/base16.lua](https://github.com/snelling-a/base16.lua)|Neovim plugin for building a sync base16 colorscheme. Includes support for Treesitter and LSP highlight groups.| |[snelling-a/nvim-base16](https://github.com/snelling-a/nvim-base16)|Neovim plugin for building a sync base16 colorscheme. Includes support for Treesitter and LSP highlight groups.| -|[ThePrimeagen/refactoring.nvim](https://github.com/ThePrimeagen/refactoring.nvim)|The Refactoring library based off the Refactoring book by Martin Fowler| -|[tpope/vim-rhubarb](https://github.com/tpope/vim-rhubarb)|rhubarb.vim: GitHub extension for fugitive.vim| -|[wbthomason/packer.nvim](https://github.com/wbthomason/packer.nvim)|A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config| +|[tpope/vim-fugitive](https://github.com/tpope/vim-fugitive)|fugitive.vim: A Git wrapper so awesome, it should be illegal| |[williamboman/mason-lspconfig.nvim](https://github.com/williamboman/mason-lspconfig.nvim)|Extension to mason.nvim that makes it easier to use lspconfig with mason.nvim. Strongly recommended for Windows users.| +|[williamboman/mason.nvim](https://github.com/williamboman/mason.nvim)|Portable package manager for Neovim that runs everywhere Neovim runs. Easily install and manage LSP servers, DAP servers, linters, and formatters.| |[windwp/nvim-autopairs](https://github.com/windwp/nvim-autopairs)|autopairs for neovim written by lua| |[windwp/nvim-ts-autotag](https://github.com/windwp/nvim-ts-autotag)|Use treesitter to auto close and auto rename html tag| +|[yioneko/nvim-vtsls](https://github.com/yioneko/nvim-vtsls)|| |[zbirenbaum/copilot-cmp](https://github.com/zbirenbaum/copilot-cmp)|Lua plugin to turn github copilot into a cmp source| +|[zbirenbaum/copilot.lua](https://github.com/zbirenbaum/copilot.lua)|Fully featured & enhanced replacement for copilot.vim complete with API for interacting with Github Copilot| diff --git a/after/plugin/autopairs.lua b/after/plugin/autopairs.lua deleted file mode 100644 index 336bccfe..00000000 --- a/after/plugin/autopairs.lua +++ /dev/null @@ -1,12 +0,0 @@ -local fast_wrap = { - chars = { "{", "[", "(", '"', "'" }, - check_comma = true, - end_key = "$", - highlight = "Search", - highlight_grey = "Comment", - keys = "qwertyuiopzxcvbnmasdfghjkl", - map = "", - pattern = [=[[%'%"%>%]%)%}%,]]=], -} - -require("nvim-autopairs").setup({ fast_wrap = fast_wrap }) diff --git a/after/plugin/cmp.lua b/after/plugin/cmp.lua deleted file mode 100644 index 39e6ec58..00000000 --- a/after/plugin/cmp.lua +++ /dev/null @@ -1,124 +0,0 @@ -local cmp = require("cmp") -local cmp_autopairs = require("nvim-autopairs.completion.cmp") -local compare = require("cmp.config.compare") -local icons = require("ui.icons") -local luasnip = require("luasnip") - -local formatting = { - fields = { "kind", "abbr", "menu" }, - format = function(entry, vim_item) - vim_item.kind = icons.kind_icons[vim_item.kind] - vim_item.menu = icons.cmp[entry.source.name] - return vim_item - end, -} - -local has_words_before = function() - if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then - return false - end - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_text(0, line - 1, 0, line - 1, col, {})[1]:match("^%s*$") == nil -end - -local mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.close(), - [""] = cmp.mapping.confirm({ select = true }), - [""] = vim.schedule_wrap(function(fallback) - if cmp.visible() and has_words_before() then - cmp.select_next_item({ behavior = cmp.SelectBehavior.Select }) - else - fallback() - end - end), - [""] = vim.schedule_wrap(function(fallback) - if cmp.visible() and has_words_before() then - cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select }) - else - fallback() - end - end), -}) - -compare.lsp_scores = function(entry1, entry2) - local diff - if entry1.completion_item.score and entry2.completion_item.score then - diff = (entry2.completion_item.score * entry2.score) - (entry1.completion_item.score * entry1.score) - else - diff = entry2.score - entry1.score - end - return (diff < 0) -end - -local sorting = { - priority_weight = 2, - comparators = { - require("copilot_cmp.comparators").prioritize, - require("copilot_cmp.comparators").score, - compare.offset, - compare.exact, - compare.lsp_scores, - compare.kind, - compare.sort_text, - compare.recently_used, - compare.locality, - compare.length, - compare.order, - }, -} - -local sources = cmp.config.sources({ - { name = "copilot", group_index = 2 }, - { name = "nvim_lsp" }, - { name = "nvim_lua" }, - { name = "path" }, - { name = "treesitter" }, - { name = "buffer" }, - { name = "luasnip" }, -}) - -local window = { - completion = { - col_offset = -3, - side_padding = 0, - winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None", - }, - documentation = cmp.config.window.bordered(), -} - -cmp.setup({ - formatting = formatting, - mapping = mapping, - snippet = { expand = function(args) luasnip.lsp_expand(args.body) end }, - sorting = sorting, - sources = sources, - window = window, -}) - -luasnip.filetype_extend("javascript", { "html" }) -luasnip.filetype_extend("javascriptreact", { "html", "javascript" }) -luasnip.filetype_extend("typescript", { "html", "javascript" }) -luasnip.filetype_extend("typescriptreact", { "html", "javascript" }) - -require("luasnip.loaders.from_vscode").load() - -cmp.setup.filetype("gitcommit", { sources = cmp.config.sources({ { name = "cmp_git" } }, { { name = "buffer" } }) }) - -cmp.setup.cmdline({ "/", "?" }, { mapping = cmp.mapping.preset.cmdline(), sources = { { name = "buffer" } } }) - -cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ { name = "path" } }, { { name = "cmdline" } }), -}) - -cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) - -cmp.event:on("menu_opened", function() vim.b.copilot_suggestion_hidden = true end) - -cmp.event:on("menu_closed", function() vim.b.copilot_suggestion_hidden = false end) diff --git a/after/plugin/comment.lua b/after/plugin/comment.lua deleted file mode 100644 index 04151b6e..00000000 --- a/after/plugin/comment.lua +++ /dev/null @@ -1 +0,0 @@ -require("Comment").setup({ pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook() }) diff --git a/after/plugin/copilot.lua b/after/plugin/copilot.lua deleted file mode 100644 index a8e58abe..00000000 --- a/after/plugin/copilot.lua +++ /dev/null @@ -1,15 +0,0 @@ -local kind_icons = require("ui.icons").kind_icons -local logger = require("utils.logger") - -local get_node_path = function() - local node = vim.fn.exepath("node") - - if not node then - logger.warn({ msg = "Node not found in path", title = kind_icons.Copilot }) - return - end - - return node -end - -require("copilot").setup({ copilot_node_path = get_node_path }) diff --git a/after/plugin/easy-align.lua b/after/plugin/easy-align.lua deleted file mode 100644 index b72e4d75..00000000 --- a/after/plugin/easy-align.lua +++ /dev/null @@ -1,4 +0,0 @@ -local utils = require("utils") - -utils.nmap("ga", "(EasyAlign)") -utils.xmap("ga", "(EasyAlign)") diff --git a/after/plugin/firenvim.lua b/after/plugin/firenvim.lua deleted file mode 100644 index 660bff5c..00000000 --- a/after/plugin/firenvim.lua +++ /dev/null @@ -1,56 +0,0 @@ -local api = vim.api -local g = vim.g -local opt = vim.opt - -if g.started_by_firenvim then - opt.colorcolumn = "" - opt.cursorline = false - opt.guifont = "Iosevka Nerd Font Mono" - opt.laststatus = 1 - opt.number = false - opt.relativenumber = false - opt.showtabline = 0 - opt.spell = true -end - -local global_settings = { - all = { "" }, - alt = "all", -} - -local local_settings = { - [".*"] = { cmdline = "neovim", filename = "/tmp/{hostname}_{pathname%10}.{extension}" }, - ["https?://.*\\.atlassian\\.net/"] = { takeover = "never" }, - ["https?://.*\\.regexr\\.com/"] = { takeover = "never" }, - ["https?://www.messenger.com"] = { takeover = "never" }, - ["https?://docs\\.google\\.com"] = { takeover = "never" }, - ["https?://github\\.com/"] = { - priority = 1, - takeover = "always", - selector = "textarea:not(#read-only-cursor-text-area)", - }, - ["https://mail.proton.me"] = { priority = 1, takeover = "always", selector = 'div[id="rooster-editor"]' }, - ["https?://www\\.reddit\\.com/"] = { - priority = 1, - takeover = "always", - selector = 'textarea:not([placeholder*="Title"])', - }, -} - -g.firenvim_config = { - globalSettings = global_settings, - localSettings = local_settings, -} - -api.nvim_create_autocmd("BufEnter", { - callback = function() vim.bo.filetype = "markdown" end, - desc = "Use markdown formatting for GitHub and reddit", - group = api.nvim_create_augroup("Firenvim", {}), - pattern = { "*github.com_*", "*reddit.com_*" }, -}) - -api.nvim_create_user_command( - "FirenvimReload", - function() vim.fn["firenvim#install"](1) end, - { desc = "Reload Firenvim" } -) diff --git a/after/plugin/fugitive.lua b/after/plugin/fugitive.lua deleted file mode 100644 index 8c96d7e5..00000000 --- a/after/plugin/fugitive.lua +++ /dev/null @@ -1,38 +0,0 @@ -local telescope = require("telescope.builtin") -local utils = require("utils") - -local api = vim.api -local git = vim.cmd.Git - -utils.nmap("gs", git, { desc = "[G]it [s]tatus" }) - -local function set_fugitive_keymaps() - if vim.bo.ft ~= "fugitive" then - return - end - - local bufnr = api.nvim_get_current_buf() - local opts = { buffer = bufnr } - - utils.nmap("p", function() git("push") end, utils.tbl_extend_force(opts, { desc = "Git [p]ush" })) - utils.nmap( - "P", - function() git({ "pull", "--rebase" }) end, - utils.tbl_extend_force(opts, { desc = "Git [P]ull" }) - ) - utils.nmap( - "t", - function() git({ "push -u origin" }) end, - utils.tbl_extend_force(opts, { desc = "Push [t]o origin" }) - ) - utils.nmap("gb", telescope.git_branches, { desc = "View [g]it [b]ranches" }) - utils.nmap("gc", telescope.git_commits, { desc = "View [g]it [c]ommits" }) - utils.nmap("gst", telescope.git_stash, { desc = "View [g]it [st]ash" }) -end - -api.nvim_create_autocmd("BufWinEnter", { - callback = function() set_fugitive_keymaps() end, - desc = "Set fugitive keymaps", - group = api.nvim_create_augroup("Fugitive", {}), - pattern = "*", -}) diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua deleted file mode 100755 index e487eb3a..00000000 --- a/after/plugin/lsp.lua +++ /dev/null @@ -1,33 +0,0 @@ -local icons = require("ui.icons").progress -local lsp_config = require("lsp_config") -local lspconfig = require("lspconfig") - -require("neodev").setup({}) - -local capabilities = require("cmp_nvim_lsp").default_capabilities() - -require("lspconfig.ui.windows").default_options.border = "rounded" - -lsp_config.setup() - -local options = { - on_attach = lsp_config.on_attach, - capabilities = capabilities, - lsp_flags = { debounce_text_changes = 150 }, -} - -local servers = lsp_config.servers - -require("mason").setup({ - ui = { - border = "rounded", - icons = { package_installed = icons.done, package_pending = icons.pending, package_uninstalled = icons.trash }, - }, -}) - -require("mason-lspconfig").setup({ automatic_installation = true, ensure_installed = vim.tbl_keys(servers) }) - -for server, config in pairs(servers) do - local opts = vim.tbl_deep_extend("force", options, config or {}) - lspconfig[server].setup(opts) -end diff --git a/after/plugin/mkdnflow.lua b/after/plugin/mkdnflow.lua deleted file mode 100644 index cb2f167e..00000000 --- a/after/plugin/mkdnflow.lua +++ /dev/null @@ -1,20 +0,0 @@ -local icons = require("ui.icons").progress - -local mappings = { - MkdnFoldSection = false, - MkdnGoBack = { "n", "" }, - MkdnGoForward = { "n", "||" }, - MkdnMoveSource = { "n", "!!" }, - MkdnNextHeading = { "n", "]]" }, - MkdnNextLink = false, - MkdnPrevHeading = { "n", "[[" }, - MkdnPrevLink = false, - MkdnToggleToDo = { { "n", "v" }, "" }, - MkdnUnfoldSection = false, -} - -require("mkdnflow").setup({ - links = { conceal = true, name_is_source = true }, - mappings = mappings, - to_do = { symbols = { " ", icons.pending, "x" } }, -}) diff --git a/after/plugin/null-ls.lua b/after/plugin/null-ls.lua deleted file mode 100644 index 8e89b0b7..00000000 --- a/after/plugin/null-ls.lua +++ /dev/null @@ -1,82 +0,0 @@ -local disabled_filetypes = require("utils.no_format") -local null_ls = require("null-ls") -local on_attach = require("lsp_config").on_attach - -local builtins = null_ls.builtins -local builtins_code_actions = builtins.code_actions -local builtins_diagnostics = builtins.diagnostics -local builtins_formatting = builtins.formatting -local builtins_code_actions_typescript = require("typescript.extensions.null-ls.code-actions") - -local builtins_diagnostics_cspell = builtins_diagnostics.cspell.with({ - disabled_filetypes = disabled_filetypes, - diagnostics_postprocess = function(diagnostic) diagnostic.severity = vim.diagnostic.severity["HINT"] end, -}) - -local builtins_diagnostics_luacheck = builtins_diagnostics.luacheck.with({ - condition = function(utils) return utils.root_has_file({ ".luacheckrc" }) end, -}) - -local builtins_diagnostics_yamllint = builtins_diagnostics.yamllint.with({ - extra_args = function() - if vim.fn.filereadable(".yamllint") == 1 then - local config_file = vim.fn.getcwd() .. "/.yamllint" - return { "--config-file", config_file } - end - return {} - end, - condition = function(utils) return utils.root_has_file({ ".yamllint", ".yamllint.yaml", ".yamllint.yml" }) end, -}) - -local builtins_formatting_deno_fmt = builtins.formatting.deno_fmt.with({ - condition = function(utils) return utils.root_has_file({ "deno.json*" }) end, -}) - -local builtins_formatting_prettierd = builtins.formatting.prettierd.with({ - condition = function(utils) - return utils.root_has_file({ - ".prettierrc", - ".prettierrc.cjs", - ".prettierrc.js", - ".prettierrc.json", - ".prettierrc.json5", - ".prettierrc.toml", - ".prettierrc.yaml", - ".prettierrc.yml", - "prettier.config.cjs", - "prettier.config.js", - }) - end, -}) - -null_ls.setup({ - border = "rounded", - diagnostics_format = "[#{c}] #{m} (#{s})", - on_attach = on_attach, - sources = { - builtins_code_actions.cspell.with({ disabled_filetypes = disabled_filetypes }), - builtins_code_actions.shellcheck, - builtins_code_actions_typescript, - builtins_diagnostics.alex, - builtins_diagnostics.gitlint, - builtins_diagnostics.shellcheck.with({ extra_args = { "-x" } }), - builtins_diagnostics.todo_comments, - builtins_diagnostics.vint, - builtins_diagnostics.zsh, - builtins_diagnostics_cspell, - builtins_diagnostics_luacheck, - builtins_diagnostics_yamllint, - builtins_formatting.beautysh, - builtins_formatting.cbfmt, - builtins_formatting.jq, - builtins_formatting.shfmt, - builtins_formatting.stylua, - builtins_formatting.taplo, - builtins_formatting.yamlfmt, - builtins_formatting.yq, - builtins_formatting_deno_fmt, - builtins_formatting_prettierd, - }, -}) - -require("mason-null-ls").setup({ ensure_installed = nil, automatic_installation = true, automatic_setup = false }) diff --git a/after/plugin/nvim-tree.lua b/after/plugin/nvim-tree.lua deleted file mode 100644 index 858e83e3..00000000 --- a/after/plugin/nvim-tree.lua +++ /dev/null @@ -1,50 +0,0 @@ -local utils = require("utils") - -utils.nmap("n", vim.cmd.NvimTreeToggle, { desc = "NvimTreeToggle" }) -utils.nmap("m", vim.cmd.NvimTreeFindFileToggle, { desc = "NvimTreeFindFileToggle" }) - -local function on_attach(bufnr) - local api = require("nvim-tree.api") - - local function opts(desc) - return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } - end - - api.config.mappings.default_on_attach(bufnr) - - vim.keymap.set("n", "?", api.tree.toggle_help, opts("Help")) -end - -local renderer = { - add_trailing = true, - highlight_git = true, - highlight_opened_files = "all", - highlight_modified = "icon", - icons = { git_placement = "signcolumn", modified_placement = "signcolumn" }, - special_files = { - "Cargo.toml", - "Makefile", - "README.md", - "package.json", - "readme.md", - }, -} - -local view = { - -- mappings = { list = { { key = "?", action = "toggle_help" } } }, - number = true, - relativenumber = true, - side = "right", - signcolumn = "number", -} - -require("nvim-tree").setup({ - actions = { open_file = { quit_on_open = true } }, - diagnostics = { enable = true }, - filters = { custom = { "^\\.git$" } }, - git = { ignore = false }, - on_attach = on_attach, - renderer = renderer, - trash = { cmd = "trash" }, - view = view, -}) diff --git a/after/plugin/obsidian.lua b/after/plugin/obsidian.lua deleted file mode 100644 index 1022a9f3..00000000 --- a/after/plugin/obsidian.lua +++ /dev/null @@ -1,50 +0,0 @@ -local obsidian = require("obsidian") -local utils = require("utils") - -local api = vim.api -local cmd = vim.cmd -local vault_directory = os.getenv("NOTES") or os.getenv("HOME") .. "/notes" - -local function note_id_func(input) - local title = "Untitled" - if input ~= nil then - title = input:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower() - end - - return os.date("%Y%m%d%H%M") .. "-" .. title -end - -obsidian.setup({ - completion = { nvim_cmp = true }, - daily_notes = { folder = "daily-notes" }, - dir = vault_directory, - note_id_func = note_id_func, - use_advanced_uri = true, -}) - -local function set_obsidian_links() - if vim.fn.getcwd() ~= vault_directory then - return - end - - utils.nmap("dn", cmd.ObsidianToday, { desc = "Open today's [d]aily [n]ote" }) - utils.nmap("ob", cmd.ObsidianBacklinks, { desc = "[O]pen [b]acklinks" }) - utils.vmap("ol", cmd.ObsidianLinkNew, { desc = "[O]pen [l]ink in new buffer" }) - utils.nmap("on", cmd.ObsidianNew, { desc = "[O]pen [n]ew note" }) - utils.nmap("ot", cmd.ObsidianToday, { desc = "[O]pen [t]oday's daily note" }) - utils.nmap("oy", cmd.ObsidianYesterday, { desc = "[O]pen [y]esterday's daily note" }) - vim.keymap.set("n", "gf", function() - if require("obsidian").util.cursor_on_markdown_link() then - return "ObsidianFollowLink" - else - return "gf" - end - end, { desc = "[F]ollow link", noremap = false, expr = true }) -end - -api.nvim_create_autocmd("FileType", { - callback = function() set_obsidian_links() end, - desc = "Set Obsidian keymaps", - group = api.nvim_create_augroup("Obsidian", { clear = false }), - pattern = "markdown", -}) diff --git a/after/plugin/refactoring.lua b/after/plugin/refactoring.lua deleted file mode 100644 index dd64a17c..00000000 --- a/after/plugin/refactoring.lua +++ /dev/null @@ -1,23 +0,0 @@ -local utils = require("utils") -require("refactoring").setup({}) --- Remaps for the refactoring operations currently offered by the plugin -utils.vmap("re", [[ lua require('refactoring').refactor('Extract Function')]], { expr = false }) -utils.vmap( - "rf", - [[ lua require('refactoring').refactor('Extract Function To File')]], - { expr = false } -) -utils.vmap("rv", [[ lua require('refactoring').refactor('Extract Variable')]], { expr = false }) -utils.vmap("ri", [[ lua require('refactoring').refactor('Inline Variable')]], { expr = false }) - --- Extract block doesn't need visual mode -utils.nmap("rb", [[ lua require('refactoring').refactor('Extract Block')]], { expr = false }) -utils.nmap("rbf", [[ lua require('refactoring').refactor('Extract Block To File')]], { expr = false }) - --- Inline variable can also pick up the identifier currently under the cursor without visual mode -utils.nmap("ri", [[ lua require('refactoring').refactor('Inline Variable')]], { expr = false }) -utils.vmap( - "rr", - -- "lua require('telescope').extensions.refactoring.refactors()", - function() require("telescope").extensions.refactoring.refactors() end -) diff --git a/after/plugin/surround.lua b/after/plugin/surround.lua deleted file mode 100644 index f2499fdc..00000000 --- a/after/plugin/surround.lua +++ /dev/null @@ -1 +0,0 @@ -require("nvim-surround").setup({}) diff --git a/after/plugin/symbols-outline.lua b/after/plugin/symbols-outline.lua deleted file mode 100644 index f890d28d..00000000 --- a/after/plugin/symbols-outline.lua +++ /dev/null @@ -1 +0,0 @@ -require("symbols-outline").setup() diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua deleted file mode 100644 index 920e0288..00000000 --- a/after/plugin/telescope.lua +++ /dev/null @@ -1,113 +0,0 @@ -local icons = require("ui.icons").misc -local action_layout = require("telescope.actions.layout") -local actions = require("telescope.actions") -local builtin = require("telescope.builtin") -local previewers = require("telescope.previewers") -local telescope = require("telescope") -local themes = require("telescope.themes") -local utils = require("utils") - -local project_files = function() - local opts = {} - vim.fn.system("git rev-parse --is-inside-work-tree") - if vim.v.shell_error == 0 then - builtin.git_files(opts) - else - builtin.find_files(opts) - end -end - -utils.nmap("", project_files, { desc = "Open [p]roject files" }) -utils.nmap("", builtin.live_grep, { desc = "[R]un live grep" }) -utils.nmap("", builtin.builtin, { desc = "Open builtins" }) -utils.nmap("", builtin.keymaps, { desc = "Show keymaps" }) -utils.nmap("b", builtin.buffers, { desc = "Show [b]uffers" }) -utils.nmap("bf", builtin.current_buffer_fuzzy_find, { desc = "Current [B]uffer [F]uzzy find" }) -utils.nmap("ff", builtin.find_files, { desc = "[F]ind [f]iles" }) -utils.nmap("fh", builtin.help_tags, { desc = "[H]elp" }) -utils.nmap("qf", builtin.quickfix, { desc = "[Q]uick[f]ix" }) -utils.nmap('""', builtin.registers, { desc = "View registers" }) - -local base_mappings = { - [""] = actions.cycle_history_next, - [""] = actions.cycle_history_prev, - [""] = actions.close, - [""] = action_layout.toggle_preview, -} - -local n_mappings = { - ["q"] = actions.close, -} - -local mappings = { - i = base_mappings, - n = utils.tbl_extend_force(base_mappings, n_mappings), -} - -local hide_on_startup = { preview = { hide_on_startup = true } } -local mode_insert = { initial_mode = "insert" } -local mode_normal = { initial_mode = "normal" } - -local cursor_insert = themes.get_cursor(mode_insert) -local cursor_normal = themes.get_cursor(mode_normal) -local dropdown_insert = themes.get_dropdown(mode_insert) -local dropdown_normal = themes.get_dropdown(mode_normal) -local ivy_insert = themes.get_ivy(mode_insert) -local ivy_normal = themes.get_ivy(mode_normal) - -local defaults = { - file_previewer = previewers.cat.new, - grep_previewer = previewers.vimgrep.new, - layout_strategy = "flex", - mappings = mappings, - multi_icon = icons.multi, - prompt_prefix = icons.search, - qflist_previewer = previewers.qflist.new, - selection_caret = icons.selection, - sorting_strategy = "ascending", - vimgrep_arguments = { "rg", "--vimgrep", "--smart-case", "--trim", "--hidden", "--no-ignore" }, -} - -local extensions = { - fzf = { case_mode = "smart_case", fuzzy = true, override_file_sorter = true, override_generic_sorter = true }, - ["ui-select"] = { - cursor_insert, - specific_opts = { code_actions = dropdown_normal }, - }, -} - -local pickers = { - builtin = utils.tbl_extend_force(dropdown_insert, hide_on_startup), - find_files = { find_command = { "fd", "--type", "f", "--hidden", "--no-ignore" } }, - git_bcommits = mode_normal, - git_branches = mode_normal, - git_commits = mode_normal, - git_status = mode_normal, - keymaps = dropdown_insert, -- cSpell:enableCompoundWords - live_grep = utils.tbl_extend_force(ivy_insert, { glob_pattern = "!*node_modules" }), - lsp_definitions = cursor_normal, - lsp_document_symbols = ivy_normal, - lsp_implementations = ivy_normal, - lsp_references = dropdown_normal, - lsp_type_definitions = cursor_normal, - lsp_workspace_symbols = ivy_normal, - registers = dropdown_normal, -} - -telescope.setup({ - defaults = defaults, - extensions = extensions, - file_ignore_patterns = { ".git/$", "*/**/node_modules/*" }, - pickers = pickers, -}) - -vim.api.nvim_create_user_command( - "NodeModules", - function() vim.cmd.Telescope("node_modules", "list") end, - { desc = "Explore node_modules" } -) - -telescope.load_extension("fzf") -telescope.load_extension("node_modules") -telescope.load_extension("noice") -telescope.load_extension("ui-select") diff --git a/after/plugin/toggleterm.lua b/after/plugin/toggleterm.lua deleted file mode 100644 index 84225285..00000000 --- a/after/plugin/toggleterm.lua +++ /dev/null @@ -1,22 +0,0 @@ -local tmap = require("utils").tmap - -local api = vim.api - -require("toggleterm").setup({ open_mapping = "", shell = vim.o.shell }) - -local function set_terminal_keymaps() - local opts = { buffer = 0 } - tmap("", "", opts) - tmap("jk", "", opts) - tmap("", function() vim.cmd.wincmd("h") end, opts) - tmap("", function() vim.cmd.wincmd("j") end, opts) - tmap("", function() vim.cmd.wincmd("k") end, opts) - tmap("", function() vim.cmd.wincmd("l") end, opts) -end - -api.nvim_create_autocmd("TermOpen", { - callback = function() set_terminal_keymaps() end, - desc = "Set terminal keymaps", - group = api.nvim_create_augroup("ToggleTerm", {}), - pattern = "term://*toggleterm#*", -}) diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua deleted file mode 100644 index 41cd9d25..00000000 --- a/after/plugin/treesitter.lua +++ /dev/null @@ -1,73 +0,0 @@ -local ensure_installed = { - "awk", - "bash", - "comment", - "css", - "diff", - "git_config", - "git_rebase", - "gitattributes", - "gitcommit", - "gitignore", - "graphql", - "html", - "http", - "javascript", - "jq", - "json", - "json5", - "jsonc", - "lua", - "markdown", - "markdown_inline", - "passwd", - "query", - "regex", - "scss", - "sql", - "toml", - "tsx", - "typescript", - "vim", - "vimdoc", - "yaml", -} - -local rainbow = { enable = true, query = "rainbow-parens", strategy = require("ts-rainbow").strategy.global } - -local textobjects = { - select = { - enable = true, - lookahead = true, - lsp_interop = { - enable = true, - floating_preview_opts = { border = "rounded" }, - peek_definition_code = { ["df"] = "@function.outer", ["dF"] = "@class.outer" }, - }, - keymaps = { - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["aa"] = "@parameter.outer", - ["ia"] = "@parameter.inner", - ["ac"] = "@call.outer", - ["ic"] = "@call.inner", - ["ao"] = "@block.outer", - ["io"] = "@block.inner", - }, - }, -} - -require("nvim-treesitter.configs").setup({ - auto_install = true, - context_commentstring = { enable = true, enable_autocmd = false }, - ensure_installed = ensure_installed, - highlight = { enable = true, additional_vim_regex_highlighting = { "markdown" } }, - rainbow = rainbow, - sync_install = false, - textobjects = textobjects, -}) - -require("treesitter-context").setup({ mode = "topline" }) -require("ts_context_commentstring.internal").calculate_commentstring({ - location = require("ts_context_commentstring.utils").get_cursor_location(), -}) diff --git a/after/plugin/trouble.lua b/after/plugin/trouble.lua deleted file mode 100644 index e38856ea..00000000 --- a/after/plugin/trouble.lua +++ /dev/null @@ -1,19 +0,0 @@ -local utils = require("utils") - -local function bind(target, source, desc) - return utils.nmap( - target, - function() vim.cmd.TroubleToggle(source) end, - { expr = false, desc = desc } - -- utils.tbl_extend_force({ expr = false }, desc) - ) -end - -require("trouble").setup({ mode = "workspace_diagnostics", auto_close = true, use_diagnostic_signs = true }) - -bind("xx", nil, "Toggle trouble") -bind("xw", "workspace_diagnostics", "Toggle trouble for [w]orspace") -bind("xd", "document_diagnostics", "Toggle trouble for [d]ocument") -bind("xl", "loclist", "Toggle trouble [l]oclist") -bind("xq", "quickfix", "Toggle trouble [q]uickfix") -bind("gR", "lsp_references", "Toggle trouble for LSP [R]eference") diff --git a/after/plugin/typescript.lua b/after/plugin/typescript.lua deleted file mode 100644 index 8337d99a..00000000 --- a/after/plugin/typescript.lua +++ /dev/null @@ -1,39 +0,0 @@ -local capabilities = require("cmp_nvim_lsp").default_capabilities() -local config_util = require("lspconfig.util") -local on_attach = require("lsp_config").on_attach - -require("typescript").setup({ - root_dir = config_util.root_pattern("tsconfig.json", "package.json"), - server = { - on_attach = function(client, bufnr) - capabilities.textDocument.completion.completionItem.snippetSupport = true - capabilities.textDocument.completion.completionItem.preselectSupport = true - capabilities.textDocument.completion.completionItem.insertReplaceSupport = true - capabilities.textDocument.completion.completionItem.labelDetailsSupport = true - capabilities.textDocument.completion.completionItem.deprecatedSupport = true - capabilities.textDocument.completion.completionItem.commitCharactersSupport = true - capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } } - capabilities.textDocument.completion.completionItem.resolveSupport = - { properties = { "documentation", "detail", "additionalTextEdits" } } - capabilities.textDocument.codeAction = { - dynamicRegistration = false, - codeActionLiteralSupport = { - codeActionKind = { - valueSet = { - "", - "quickfix", - "refactor", - "refactor.extract", - "refactor.inline", - "refactor.rewrite", - "source", - "source.organizeImports", - }, - }, - }, - } - capabilities.textDocument.foldingRange = { dynamicRegistration = false, lineFoldingOnly = true } - on_attach(client, bufnr) - end, - }, -}) diff --git a/after/plugin/undotree.lua b/after/plugin/undotree.lua deleted file mode 100644 index e74895a8..00000000 --- a/after/plugin/undotree.lua +++ /dev/null @@ -1,5 +0,0 @@ -local utils = require("utils") - -utils.nmap("u", vim.cmd.UndotreeToggle, { desc = "Toggle undotree" }) - -vim.g.undotree_SetFocusWhenToggle = 1 diff --git a/after/plugin/zenmode.lua b/after/plugin/zenmode.lua deleted file mode 100644 index 0b5f2ea1..00000000 --- a/after/plugin/zenmode.lua +++ /dev/null @@ -1,9 +0,0 @@ -local utils = require("utils") -local zen_mode = require("zen-mode") - -zen_mode.setup({ window = { width = 100, options = { number = true, relativenumber = true } } }) - -utils.nmap("zz", function() - zen_mode.toggle() - vim.wo.wrap = false -end, { desc = "Toggle [Z]en Mode" }) diff --git a/cspell.json b/cspell.json index e5b45632..7ced2030 100644 --- a/cspell.json +++ b/cspell.json @@ -1,12 +1,12 @@ { - "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json", - "allowCompoundWords": true, "dictionaries": [ "softwareTerms", "fonts" ], + "import": [ + "@cspell/dict-fonts/cspell-ext.json" + ], "enableGlobDot": true, - "enabled": true, "ignorePaths": [ "./.git", "./plugin" @@ -14,6 +14,8 @@ "ignoreWords": [ "acklinks", "aily", + "amed", + "cretch", "earch", "eclaration", "ecutable", @@ -28,6 +30,7 @@ "iagnostic", "iles", "mplementation", + "ndotree", "ntcl", "nzzzv", "oclist", @@ -36,6 +39,7 @@ "odules", "oggle", "ollow", + "omment", "ommits", "orkspace", "ormat", @@ -49,16 +53,19 @@ "uickfix", "uzzy" ], - "import": [ - "@cspell/dict-fonts/cspell-ext.json" - ], + "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json", + "enabled": true, "version": "0.2", "words": [ "AARRGGBB", + "Kunz", "Smitesh", "afile", "akinsho", "alviste", + "anuvyklack", + "anuvyklack", + "anuvyklack", "arkav", "augroup", "autocmd", @@ -86,15 +93,21 @@ "cmds", "cnoreabbrev", "codeium", + "cretch", + "cretch", + "cretch", + "cretch", "cssls", "ction", "curren", + "davidsierradz", "dcmake", "deno", "denols", "diagnosti", "doautoall", "eandrju", + "ehthumbs", "emerg", "emsg", "endfunction", @@ -104,6 +117,7 @@ "exafunction", "exepath", "expandtab", + "exporer", "favourite", "findbuf", "firenvim", @@ -131,6 +145,11 @@ "hlsearch", "hrsh", "iamcco", + "ibhagwan", + "ibhagwan", + "ibhagwan", + "ibhagwan", + "ibhagwan", "ignorecase", "incsearch", "invisibles", @@ -170,6 +189,7 @@ "mrjones", "munif", "myvimrc", + "nargs", "navic", "ncipollo", "neodev", @@ -178,6 +198,7 @@ "netrw", "nmap", "nnoremap", + "noautocmd", "nobuflisted", "nocombine", "noeol", @@ -235,10 +256,12 @@ "theprimeagen", "timeoutlen", "tmap", + "tohtml", "tpope", "tsuri", "ttimeoutlen", "undodir", + "unstaged", "vimls", "vimrc", "vint", @@ -247,6 +270,8 @@ "virtnum", "vmap", "vsplit", + "vtsls", + "vtsls", "wbthomason", "williamboman", "winbar", @@ -259,6 +284,8 @@ "xmap", "yamlfmt", "yamlls", + "yioneko", "zbirenbaum" - ] + ], + "allowCompoundWords": true } diff --git a/generate_readme.sh b/generate_readme.sh index fab3f950..81d091e9 100755 --- a/generate_readme.sh +++ b/generate_readme.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -packer="packer.lua" output="./README.md" packages_list='packages.temp' start_text="|---|---|" @@ -8,7 +7,7 @@ end_text="" packages="$( rg '.*("([a-zA-Z0-9-_]+/[.a-zA-Z0-9-_]+)").*' \ - --glob="$packer" \ + --glob='lua/plugins/*.lua' \ --replace='$2' \ --no-line-number \ --no-filename | sort -uf diff --git a/init.lua b/init.lua index 1a3f3ca6..4cb3436a 100644 --- a/init.lua +++ b/init.lua @@ -1,13 +1,3 @@ vim.loader.enable() -local impatient_ok, impatient = pcall(require, "impatient") -if impatient_ok then - impatient.enable_profile() -end - -if vim.g.vscode then - require("vscode") -else - require("user") - require("ui") -end +require("config") diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000..e2788b65 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,59 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "e1fe53117aab24c378d5e6deaad786789c360123" }, + "LuaSnip": { "branch": "master", "commit": "a46ab6f8bce6bbddd8ce3e287e1a517c1f5e348e" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "5af1bb7d722ef8a96658f01d6eb219c4cf746b32" }, + "cmp-conventionalcommits": { "branch": "master", "commit": "a4dfacf0601130b7f8afa7c948d735c27802fb7f" }, + "cmp-git": { "branch": "main", "commit": "a798a25b21e7204597f56029af2e8a17d65e2518" }, + "cmp-nerdfont": { "branch": "main", "commit": "853a946eda00016f60c0602a20d8595c6eb074a6" }, + "cmp-npm": { "branch": "main", "commit": "e5753b6103ce4cf887233142fa9f31b2d13b42f2" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" }, + "cmp-nvim-lsp-document-symbol": { "branch": "main", "commit": "f0f53f704c08ea501f9d222b23491b0d354644b0" }, + "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp-treesitter": { "branch": "master", "commit": "389eadd48c27aa6dc0e6b992644704f026802a2e" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "copilot-cmp": { "branch": "master", "commit": "ad4c097bf76c544fce95a2cb6b02f245cb18a6bb" }, + "copilot.lua": { "branch": "master", "commit": "21d8ef6ce4ac931ebfa3fc3c0afb65bb05db9fc3" }, + "copilot.vim": { "branch": "release", "commit": "1358e8e45ecedc53daf971924a0541ddf6224faf" }, + "feline.nvim": { "branch": "main", "commit": "7d4aa041cc796a736729d2a29046d26af89943cc" }, + "fzf-lua": { "branch": "main", "commit": "79c7c3480cc363b3d4ecdfcb8b56623d9decd570" }, + "gitsigns.nvim": { "branch": "main", "commit": "e5edefd9976039f5352e0c900f35206770b33a2d" }, + "headlines.nvim": { "branch": "master", "commit": "ddef41b2664f0ce25fe76520d708e2dc9dfebd70" }, + "indent-blankline.nvim": { "branch": "master", "commit": "018bd04d80c9a73d399c1061fa0c3b14a7614399" }, + "lazy.nvim": { "branch": "main", "commit": "ceb413678dfcf3d5455208959185e3db1f7892c7" }, + "lsp-inlayhints.nvim": { "branch": "main", "commit": "62c7b8dd8ac9933b071912fe3c789ef2cb704672" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "cec0e6dd534ade486b5eeb59ebcfa8d51c3e8c5e" }, + "mason-null-ls.nvim": { "branch": "main", "commit": "54d702020bf94e4eefd357f0b738317af30217eb" }, + "mason.nvim": { "branch": "main", "commit": "057ac5ca159c83e302a55bd839a96ff1ea2396db" }, + "neo-tree.nvim": { "branch": "v2.x", "commit": "8d485aab32da9b8841d4af977f992b82b14af469" }, + "neodev.nvim": { "branch": "main", "commit": "ab4c68129b5fefe5c6bb6d7e92283d3f8bdf8566" }, + "noice.nvim": { "branch": "main", "commit": "6a7649413ef61123c333f422ee95840c04ece161" }, + "nui.nvim": { "branch": "main", "commit": "698e75814cd7c56b0dd8af4936bcef2d13807f3c" }, + "null-ls.nvim": { "branch": "main", "commit": "33b853a3933eed3137cd055aac4e539e69832ad0" }, + "nvim-autopairs": { "branch": "master", "commit": "7747bbae60074acf0b9e3a4c13950be7a2dff444" }, + "nvim-cmp": { "branch": "main", "commit": "0f47dcaf7e39d64cd067e090e6f2eda6326e7366" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" }, + "nvim-lspconfig": { "branch": "master", "commit": "3bd4ca412982afa6f88bb7ef890660cee51c3e58" }, + "nvim-navic": { "branch": "master", "commit": "83dc174da915f9dbc9b51169e9b62a2e0d42b527" }, + "nvim-notify": { "branch": "master", "commit": "159c6cf1be25a933f35e97499314c9faab55c98f" }, + "nvim-surround": { "branch": "main", "commit": "e6047128e57c1aff1566fb9f627521d2887fc77a" }, + "nvim-treesitter": { "branch": "master", "commit": "54741de02c18fae1b33d2b0da36f5ef946712073" }, + "nvim-treesitter-context": { "branch": "master", "commit": "0226dd639712141235d5c9eefde47365d15d0535" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "5632f926833493bf44de3d0c214169a062b068df" }, + "nvim-ts-autotag": { "branch": "main", "commit": "40615e96075c743ef47aaf9de966dc348bec6459" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "0bf8fbc2ca8f8cdb6efbd0a9e32740d7a991e4c3" }, + "nvim-ts-rainbow2": { "branch": "master", "commit": "1ffe68cdd594633dfee0762feebfef81ed6f1fbb" }, + "nvim-vtsls": { "branch": "main", "commit": "f694f65898e7daf34858f6c5041c1cd1433b4dd7" }, + "nvim-web-devicons": { "branch": "master", "commit": "b34362b20a4942b3245f958e73ebe1b09b020ad1" }, + "obsidian.nvim": { "branch": "main", "commit": "0418505ff7d1e06460450a02b9209d03f4c2a50d" }, + "plenary.nvim": { "branch": "master", "commit": "9ac3e9541bbabd9d73663d757e4fe48a675bb054" }, + "schemastore.nvim": { "branch": "main", "commit": "b8e6c7d966857e8ff14d9b6a23eec9214d99db32" }, + "scretch.nvim": { "branch": "main", "commit": "93b05dcb0ddd1eb5a7d94058a4f6177c7dea9e7c" }, + "symbols-outline.nvim": { "branch": "master", "commit": "512791925d57a61c545bc303356e8a8f7869763c" }, + "trouble.nvim": { "branch": "main", "commit": "d56bfc0c501ced4002a57cb60433362fb2ce9c4d" }, + "undotree": { "branch": "master", "commit": "485f01efde4e22cb1ce547b9e8c9238f36566f21" }, + "vim-fugitive": { "branch": "master", "commit": "5f0d280b517cacb16f59316659966c7ca5e2bea2" }, + "vim-graphql": { "branch": "master", "commit": "996749a7d69a3709768fa8c4d259f79b5fd9bdb1" } +} \ No newline at end of file diff --git a/lua/user/autocommands.lua b/lua/config/autocmd.lua similarity index 94% rename from lua/user/autocommands.lua rename to lua/config/autocmd.lua index 89ddcd97..09bd0cac 100644 --- a/lua/user/autocommands.lua +++ b/lua/config/autocmd.lua @@ -1,4 +1,4 @@ -local utils = require("utils") +local util = require("config.util") local api = vim.api local augroup = api.nvim_create_augroup @@ -22,7 +22,7 @@ autocmd({ "BufLeave", "FocusLost" }, { autocmd({ "FileType" }, { callback = function() local filetype = bo.filetype - if filetype == "toggleterm" or utils.should_have_formatting(filetype) then + if filetype == "toggleterm" or util.should_have_formatting(filetype) then return end api.nvim_buf_set_keymap(0, "n", "q", "", { callback = function() api.nvim_buf_delete(0, { force = true }) end }) @@ -90,7 +90,7 @@ autocmd("BufLeave", { opt_local.cursorline = false opt_local.relativenumber = false - if utils.should_have_formatting(bo.filetype) then + if util.should_have_formatting(bo.filetype) then opt_local.number = true else opt_local.number = false @@ -103,7 +103,7 @@ autocmd("BufLeave", { autocmd("BufEnter", { callback = function() - if utils.should_have_formatting(bo.filetype) then + if util.should_have_formatting(bo.filetype) then opt_local.cursorline = true opt_local.number = true opt_local.relativenumber = true diff --git a/lua/user/commands.lua b/lua/config/command.lua similarity index 100% rename from lua/user/commands.lua rename to lua/config/command.lua diff --git a/lua/config/init.lua b/lua/config/init.lua new file mode 100644 index 00000000..95bd4353 --- /dev/null +++ b/lua/config/init.lua @@ -0,0 +1,11 @@ +require("config.keymap") + +require("config.lazy") + +require("config.autocmd") +require("config.command") +require("config.opt") +require("config.session") +require("config.ui") + +require("config.util.netrw") diff --git a/lua/config/keymap.lua b/lua/config/keymap.lua new file mode 100644 index 00000000..8401c131 --- /dev/null +++ b/lua/config/keymap.lua @@ -0,0 +1,100 @@ +local logger = require("config.util.logger") +local util = require("config.util") + +local cmd = vim.cmd +local fn = vim.fn +local map = vim.keymap.set + +vim.g.mapleader = "," + +local function escape() util.feedkeys("", "i", true) end + +util.map({ "c", "v", "x" }, "jk", escape, { desc = "Escape to normal mode" }) +util.map({ "n", "v" }, ":", ";", { desc = "Command is remapped to `;`" }) +map({ "n", "v" }, ";", ":", { desc = "Command is remapped to `;`" }) + +local movement_warning = "NO! USE " +util.nmap("", function() logger.warn({ msg = movement_warning .. "J!" }) end, { desc = "DON'T USE [DOWN]" }) +util.nmap("", function() logger.warn({ msg = movement_warning .. "H!" }) end, { desc = "DON'T USE [LEFT]" }) +util.nmap("", function() logger.warn({ msg = movement_warning .. "L!" }) end, { desc = "DON'T USE [RIGHT]" }) +util.nmap("", function() logger.warn({ msg = movement_warning .. "K!" }) end, { desc = "DON'T USE [Up]" }) + +util.map("", "", function() cmd.wincmd("h") end, { desc = "Move to Left Window" }) +util.map("", "", function() cmd.wincmd("j") end, { desc = "Move to Bottom Window" }) +util.map("", "", function() cmd.wincmd("k") end, { desc = "Move to Upper Window" }) +util.map("", "", function() cmd.wincmd("l") end, { desc = "Move to Right Window" }) + +util.nmap( + "", + function() cmd.resize({ args = { "-5" }, mods = { vertical = true } }) end, + { desc = "Decrease current window width" } +) +util.nmap( + "", + function() cmd.resize({ args = { "+5" }, mods = { vertical = true } }) end, + { desc = "Increase current window width" } +) +util.nmap("", function() cmd.resize({ args = { "-5" } }) end, { desc = "Decrease current window height" }) +util.nmap("", function() cmd.resize({ args = { "+5" } }) end, { desc = "Increase current window height" }) + +map( + "n", + "s", + [[:%s/\<\>//I]], + { desc = "[S]earch and replace word under the cursor" } +) +util.nmap("", function() + util.feedkeys("") + util.scroll_center() +end, { desc = "Scroll [u]p and center" }) +util.nmap("", "", { desc = "I'm sure there is a use for this, but for now it's just annoying" }) +util.nmap("", function() cmd.bprevious() end, { desc = "Go to the previous buffer" }) +util.nmap("", function() cmd.bnext() end, { desc = "Go to the next buffer" }) +util.nmap(",", "``", { desc = "Press `,,` to jump back to the last cursor position." }) +util.nmap("/", function() + cmd.nohlsearch() + logger.info({ msg = "Highlighting cleared" }) +end, { desc = "Clear search highlighting" }) +util.nmap("fml", function() cmd.CellularAutomaton("make_it_rain") end, { desc = "make it rain" }) +util.nmap("rl", function() util.reload_modules() end, { desc = "[R]eload [m]odules" }) +util.nmap("x", function() + fn.setfperm(fn.expand("%:p"), "rwxr-xr-x") + logger.info({ msg = string.format("%s made executable", fn.expand("%")), title = "CHMOD!" }) +end, { desc = "Make file e[x]ecutable" }) +util.nmap("H", "^", { desc = "Move to the start of line" }) +util.nmap("J", "mzJ`z", { desc = "[J]oin next line to current line" }) +util.nmap("L", "$", { desc = "Move to the end of line" }) +util.nmap("N", function() + util.feedkeys("N") + util.scroll_center() + util.feedkeys("zv") +end, { desc = "Go to previous search result and center" }) +util.nmap("Q", "", { desc = "I'm sure there is a use for this, but for now it's just annoying" }) +util.nmap("U", function() cmd.redo() end, { desc = "Better redo" }) +util.nmap("Y", "y$", { desc = "[Y]ank to the end of the line" }) +util.nmap("n", function() + util.feedkeys("n") + util.scroll_center() + util.feedkeys("zv") +end, { desc = "Go to [n]ext search result and center" }) + +map({ "n", "v" }, "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, desc = "Move to next visual line" }) +map({ "n", "v" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, desc = "Move to previous visual line" }) + +util.imap("jk", function() + escape() + if vim.bo.buftype == "" then + cmd.update() + end +end, { desc = "Write and go to normal mode" }) +util.imap("jj", function() escape() end, { desc = "Go to normal mode" }) + +util.vmap("J", ":m '>+1gv=gv", { desc = "Move lines down" }) +util.vmap("K", ":m '<-2gv=gv", { desc = "Move lines up" }) + +util.nmap("g", function() + local conf = logger.confirm({ msg = "Are you sure you want to quit?", type = "Warning" }) + if conf == 1 then + cmd.quit() + end +end, { desc = "[Q]uit all windows" }) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 00000000..b5066c19 --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,32 @@ +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", + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ + change_detection = { notify = false }, + dev = { path = os.getenv("HOME") .. "/dev/github.com/snelling-a" }, + performance = { + rtp = { + disabled_plugins = { + "gzip", + "matchit", + "rplugin", + "spellfile", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, + spec = { import = "plugins" }, +}) diff --git a/lua/lsp_config/diagnostics.lua b/lua/config/lsp/diagnostic.lua similarity index 77% rename from lua/lsp_config/diagnostics.lua rename to lua/config/lsp/diagnostic.lua index 544bf846..ee305867 100644 --- a/lua/lsp_config/diagnostics.lua +++ b/lua/config/lsp/diagnostic.lua @@ -1,14 +1,7 @@ -local signs = require("ui.icons").diagnostics +local signs = require("config.ui.icons").diagnostics local vim_diagnostic = vim.diagnostic local api = vim.api -for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) -end - -local LspDiagnostiCurrenLineGroup = api.nvim_create_augroup("LspDiagnostiCurrenLine", { clear = true }) - local function best_diagnostic(diagnostics) if vim.tbl_isempty(diagnostics) then return @@ -83,12 +76,27 @@ vim_diagnostic.handlers.current_line_virt = { end, } -return function(bufnr) - api.nvim_clear_autocmds({ - buffer = bufnr, - group = LspDiagnostiCurrenLineGroup, +local Diagnostic = {} + +function Diagnostic.on_attach(bufnr) + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) + end + + vim.diagnostic.config({ + float = { source = "always", border = "rounded" }, + severity_sort = true, + signs = true, + underline = true, + update_in_insert = false, + virtual_text = false, }) + local LspDiagnostiCurrenLineGroup = api.nvim_create_augroup("LspDiagnostiCurrenLine", { clear = true }) + + api.nvim_clear_autocmds({ buffer = bufnr, group = LspDiagnostiCurrenLineGroup }) + api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { group = LspDiagnostiCurrenLineGroup, buffer = bufnr, @@ -101,3 +109,5 @@ return function(bufnr) callback = function() vim_diagnostic.handlers.current_line_virt.hide(nil, nil) end, }) end + +return Diagnostic diff --git a/lua/lsp_config/document_highlight.lua b/lua/config/lsp/document_highlight.lua similarity index 55% rename from lua/lsp_config/document_highlight.lua rename to lua/config/lsp/document_highlight.lua index 245041c5..47688277 100644 --- a/lua/lsp_config/document_highlight.lua +++ b/lua/config/lsp/document_highlight.lua @@ -1,24 +1,26 @@ local api = vim.api -local lsp = vim.lsp +local lsp = vim.lsp.buf -return function(client, bufnr) - if not client.supports_method("textDocument/documentHighlight") then - return - end +local DocumentHighlight = {} +function DocumentHighlight.on_attach(bufnr) local LspDocumentHighlightGroup = api.nvim_create_augroup("LspDocumentHightlight", { clear = false }) + vim.api.nvim_clear_autocmds({ buffer = bufnr, group = LspDocumentHighlightGroup }) + api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { group = LspDocumentHighlightGroup, buffer = bufnr, - callback = lsp.buf.document_highlight, + callback = lsp.document_highlight, desc = "Highlight all occurrences of the word under the cursor", }) api.nvim_create_autocmd("CursorMoved", { group = LspDocumentHighlightGroup, buffer = bufnr, - callback = lsp.buf.clear_references, - desc = "Clear all references on cursor move", + callback = lsp.clear_references, + desc = "Clear highlighted references on cursor move", }) end + +return DocumentHighlight diff --git a/lua/config/lsp/formatting.lua b/lua/config/lsp/formatting.lua new file mode 100644 index 00000000..e20201ef --- /dev/null +++ b/lua/config/lsp/formatting.lua @@ -0,0 +1,53 @@ +local logger = require("config.util.logger") + +local Formatting = {} + +local lsp_formatting = "LspFormatting" +local autoformat = true + +function Formatting.toggle() + autoformat = not autoformat + + if autoformat then + logger.info({ msg = "Enabled format on save", title = lsp_formatting }) + else + logger.warn({ msg = "Disabled format on save", title = lsp_formatting }) + end +end + +function Formatting.format() + local buf = vim.api.nvim_get_current_buf() + local have_nls = package.loaded["null-ls"] + and (#require("null-ls.sources").get_available(vim.bo.filetype, "NULL_LS_FORMATTING") > 0) + + vim.lsp.buf.format({ + bufnr = buf, + filter = function(client) + if have_nls then + return client.name == "null-ls" + end + return client.name ~= "null-ls" + end, + }) +end + +function Formatting.on_attach(buf) + vim.api.nvim_create_autocmd("BufWritePre", { + group = vim.api.nvim_create_augroup(lsp_formatting .. "." .. buf, {}), + buffer = buf, + callback = function() + if autoformat then + Formatting.format() + end + end, + desc = "Format on save", + }) + + vim.api.nvim_create_user_command( + "AutoformatToggle", + function() Formatting.toggle() end, + { desc = "Toggle format on save", nargs = 0 } + ) +end + +return Formatting diff --git a/lua/config/lsp/handlers.lua b/lua/config/lsp/handlers.lua new file mode 100644 index 00000000..30558f7e --- /dev/null +++ b/lua/config/lsp/handlers.lua @@ -0,0 +1,20 @@ +local fzf_lua = require("fzf-lua") +local handlers = vim.lsp.handlers +local lsp = vim.lsp + +local Handlers = {} + +function Handlers.on_attach() + handlers["textDocument/documentSymbol"] = fzf_lua.lsp_document_symbols + -- handlers["textDocument/hover"] = lsp.with(handlers.hover, { border = "rounded" }) + handlers["textDocument/publishDiagnostics"] = + lsp.with(handlers["textDocument/publishDiagnostics"], { signs = true, virtual_text = false }) + handlers["textDocument/references"] = fzf_lua.lsp_references + -- handlers["textDocument/signatureHelp"] = lsp.with(handlers.signature_help, { border = "rounded" }) + handlers["textdocument/definition"] = fzf_lua.lsp_definitions + handlers["textdocument/implementation"] = fzf_lua.lsp_implementations + handlers["textDocument/documentSymbol"] = fzf_lua.lsp_document_symbols + handlers["workspace/symbol"] = fzf_lua.lsp_workspace_symbols +end + +return Handlers diff --git a/lua/config/lsp/init.lua b/lua/config/lsp/init.lua new file mode 100644 index 00000000..506c6650 --- /dev/null +++ b/lua/config/lsp/init.lua @@ -0,0 +1,31 @@ +local navic = require("nvim-navic") + +local LspConfig = {} + +function LspConfig.on_attach(client, bufnr) + if client.name == "tsserver" then + client.server_capabilities.documentFormattingProvider = false + end + + if client.server_capabilities.documentSymbolProvider then + navic.attach(client, bufnr) + end + + if client.server_capabilities.documentFormattingProvider == true then + require("config.lsp.formatting").on_attach(bufnr) + end + + if client.supports_method("textDocument/documentHighlight") then + require("config.lsp.document_highlight").on_attach(bufnr) + end + + if client.server_capabilities.inlayHintProvider then + require("lsp-inlayhints").on_attach(client, bufnr) + end + + require("config.lsp.handlers").on_attach() + require("config.lsp.diagnostic").on_attach(bufnr) + require("config.lsp.keymap").on_attach(bufnr) +end + +return LspConfig diff --git a/lua/lsp_config/mappings.lua b/lua/config/lsp/keymap.lua old mode 100644 new mode 100755 similarity index 60% rename from lua/lsp_config/mappings.lua rename to lua/config/lsp/keymap.lua index 0b1e2cb3..e7521112 --- a/lua/lsp_config/mappings.lua +++ b/lua/config/lsp/keymap.lua @@ -1,33 +1,37 @@ -local logger = require("utils.logger") -local utils = require("utils") -local format = require("lsp_config.formatting").lsp_formatting +local formatting = require("config.lsp.formatting") +local logger = require("config.util.logger") +local util = require("config.util") local diagnostic = vim.diagnostic local lsp = vim.lsp.buf -return function(bufnr) - utils.nmap("d", diagnostic.open_float, { desc = "Open [d]iagnostic float" }) - utils.nmap("[d", function() +local M = {} + +function M.on_attach(bufnr) + util.nmap("d", diagnostic.open_float, { desc = "Open [d]iagnostic float" }) + util.nmap("[d", function() diagnostic.goto_prev({ float = false }) - utils.scroll_center() + util.scroll_center() end, { desc = "Goto previous [d]iagnostic issue" }) - utils.nmap("]d", function() + util.nmap("]d", function() diagnostic.goto_next({ float = false }) - utils.scroll_center() + util.scroll_center() end, { desc = "Goto next [d]iagnostic issue" }) - utils.nmap("q", diagnostic.setloclist) + util.nmap("q", diagnostic.setloclist) local function bind(target, source, desc) local opts = { buffer = bufnr, desc = desc } - return utils.nmap(target, source, opts) + return util.nmap(target, source, opts) end bind("", lsp.signature_help, "Show signature help") bind("D", lsp.type_definition, "Show type [d]efinition") bind("ca", lsp.code_action, "[C]ode [a]ction") - bind("f", function() format() end, "[F]ormat the current buffer") + bind("f", function() formatting.format() end, "[F]ormat the current buffer") + bind("tf", function() formatting.toggle() end, "[F]ormat the current buffer") bind("rn", lsp.rename, "[R]ename variable") + bind("sw", function() vim.cmd("noautocmd write") end, "save without formatting") bind("wa", lsp.add_workspace_folder, "[A]dd [w]orkspace folder") bind( "wl", @@ -39,11 +43,13 @@ return function(bufnr) bind("gD", lsp.declaration, { desc = "Show [d]eclaration" }) bind("gd", function() lsp.definition() - utils.scroll_center() + util.scroll_center() end, "Show [d]efinition") bind("gi", lsp.implementation, "Show [i]mplementation") bind("gr", function() lsp.references() - utils.scroll_center() + util.scroll_center() end, "[G]et [r]eferences") end + +return M diff --git a/lua/config/lsp/server/awk_ls.lua b/lua/config/lsp/server/awk_ls.lua new file mode 100644 index 00000000..4b54d5df --- /dev/null +++ b/lua/config/lsp/server/awk_ls.lua @@ -0,0 +1,5 @@ +local M = {} + +function M.setup(opts) require("lspconfig").awk_ls.setup(opts) end + +return M diff --git a/lua/config/lsp/server/bashls.lua b/lua/config/lsp/server/bashls.lua new file mode 100644 index 00000000..63d4f1d6 --- /dev/null +++ b/lua/config/lsp/server/bashls.lua @@ -0,0 +1,5 @@ +local M = {} + +function M.setup(opts) require("lspconfig").bashls.setup(opts) end + +return M diff --git a/lua/config/lsp/server/emmet_ls.lua b/lua/config/lsp/server/emmet_ls.lua new file mode 100644 index 00000000..1ee47e44 --- /dev/null +++ b/lua/config/lsp/server/emmet_ls.lua @@ -0,0 +1,5 @@ +local M = {} + +function M.setup(opts) require("lspconfig").emmet_ls.setup(opts) end + +return M diff --git a/lua/config/lsp/server/eslint.lua b/lua/config/lsp/server/eslint.lua new file mode 100644 index 00000000..8de5ad54 --- /dev/null +++ b/lua/config/lsp/server/eslint.lua @@ -0,0 +1,5 @@ +local M = {} + +function M.setup(opts) require("lspconfig").eslint.setup(opts) end + +return M diff --git a/lua/config/lsp/server/lua_ls.lua b/lua/config/lsp/server/lua_ls.lua new file mode 100644 index 00000000..4cfa4e73 --- /dev/null +++ b/lua/config/lsp/server/lua_ls.lua @@ -0,0 +1,28 @@ +local lspconfig = require("lspconfig") + +local config_files = + { ".luarc.json", ".luarc.jsonc", ".luacheckrc", ".stylua.toml", "stylua.toml", "selene.toml", "selene.yml" } + +local settings = { + Lua = { + completion = { displayContext = true, keywordSnippet = "Both" }, + diagnostics = { enable = true, disable = { "spell-check" }, globals = { "vim", "_*" } }, + format = { enable = false }, + hint = { enabled = true }, + runtime = { version = "LuaJIT", path = vim.split(package.path, ";") }, + telemetry = { enable = false }, + workspace = { checkThirdParty = false, library = vim.api.nvim_get_runtime_file("", true) }, + }, +} + +local M = {} + +function M.setup(opts) + opts.root_dir = lspconfig.util.root_pattern(unpack(config_files)) + + opts.settings = settings + + lspconfig.lua_ls.setup(opts) +end + +return M diff --git a/lua/config/lsp/server/sqlls.lua b/lua/config/lsp/server/sqlls.lua new file mode 100644 index 00000000..8188edd4 --- /dev/null +++ b/lua/config/lsp/server/sqlls.lua @@ -0,0 +1,5 @@ +local M = {} + +function M.setup(opts) require("lspconfig").sqlls.setup(opts) end + +return M diff --git a/lua/config/lsp/server/tsserver.lua b/lua/config/lsp/server/tsserver.lua new file mode 100644 index 00000000..4bb99757 --- /dev/null +++ b/lua/config/lsp/server/tsserver.lua @@ -0,0 +1,47 @@ +local lspconfig = require("lspconfig") +local util = require("config.lsp.util") + +local Tsserver = {} + +local config_files = { "package.json", "tsconfig.json", "jsconfig.json" } + +local javascript_settings = { + inlayHints = { + includeInlayParameterNameHints = "all", + includeInlayParameterNameHintsWhenArgumentMatchesName = false, + includeInlayFunctionParameterTypeHints = true, + includeInlayVariableTypeHints = true, + includeInlayPropertyDeclarationTypeHints = true, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayEnumMemberValueHints = true, + }, +} + +local typescript_settings = { + inlayHints = { + includeInlayParameterNameHints = "literal", + includeInlayParameterNameHintsWhenArgumentMatchesName = false, + includeInlayFunctionParameterTypeHints = false, + includeInlayVariableTypeHints = false, + includeInlayPropertyDeclarationTypeHints = false, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayEnumMemberValueHints = true, + }, +} + +local settings = { + javascript = javascript_settings, + typescript = typescript_settings, +} + +function Tsserver.setup(opts) + opts.root_dir = util.get_root_pattern(config_files) + + lspconfig.vtsls.setup(opts) + + opts.settings = settings + + lspconfig.tsserver.setup(opts) +end + +return Tsserver diff --git a/lua/config/lsp/util.lua b/lua/config/lsp/util.lua new file mode 100644 index 00000000..cd5d1fb9 --- /dev/null +++ b/lua/config/lsp/util.lua @@ -0,0 +1,34 @@ +local util = require("config.util") + +local M = {} + +---wrapper for lspconfig.util.root_pattern +---@param config_files string[] +---@return _ function (startpath: any) -> string|unknown|nil +function M.get_root_pattern(config_files) return require("lspconfig").util.root_pattern(unpack(config_files)) end + +---wrapper for tbl_extend.completion.completionItem.snippetSupport +---@param opts table +---@return table +function M.enable_broadcasting(opts) + --Enable (broadcasting) snippet capability for completion + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities.textDocument.completion.completionItem.snippetSupport = true + + opts.capabilities = util.tbl_extend_force(opts.capabilities or {}, capabilities) + + return opts +end + +---wrapper for lspconfig.util.root_pattern for graphql language servers +---@return _ function (startpath: any) -> string|unknown|nil +function M.get_graphql_root_pattern() + return require("lspconfig").util.root_pattern({ + ".graphqlrc*", + ".graphql.config.*", + "graphql.config.*", + "relay.config.*", + }) +end + +return M diff --git a/lua/user/set.lua b/lua/config/opt.lua similarity index 100% rename from lua/user/set.lua rename to lua/config/opt.lua diff --git a/lua/user/sessions.lua b/lua/config/session.lua similarity index 77% rename from lua/user/sessions.lua rename to lua/config/session.lua index a3bcbec7..277170dd 100644 --- a/lua/user/sessions.lua +++ b/lua/config/session.lua @@ -1,12 +1,13 @@ local session_string = "sessions" local session_file_name = "Session.vim" -local logger = require("utils.logger") -local utils = require("utils") +local logger = require("config.util.logger") +local util = require("config.util") local api = vim.api local fn = vim.fn local cmd = vim.cmd local SessionGroup = api.nvim_create_augroup(session_string, { clear = true }) +local is_file_readable = fn.filereadable(session_file_name) == 1 and 1 api.nvim_create_autocmd("VimEnter", { group = SessionGroup, @@ -14,7 +15,7 @@ api.nvim_create_autocmd("VimEnter", { callback = function() local path = fn.expand("%") - if fn.argc() > 0 or string.match(path, "man://*") or not utils.is_vim() then + if fn.argc() > 0 or string.match(path, "man://*") or not util.is_vim() then return end @@ -34,7 +35,7 @@ api.nvim_create_autocmd("VimEnter", { api.nvim_create_autocmd("VimLeavePre", { group = SessionGroup, callback = function() - if fn.filereadable(session_file_name) == 0 or fn.argc() > 0 or not utils.is_vim() then + if not is_file_readable or fn.argc() > 0 or not util.is_vim() then return end diff --git a/lua/ui/icons.lua b/lua/config/ui/icons.lua similarity index 54% rename from lua/ui/icons.lua rename to lua/config/ui/icons.lua index b93209c6..72973273 100644 --- a/lua/ui/icons.lua +++ b/lua/config/ui/icons.lua @@ -1,12 +1,14 @@ -local Icons = {} - local copilot = " " -local down = "" +local down = "" local error = " " +local file = " " +local folder = " " local modified = " " -local right = "" +local moved = "" local vert = "┃" +local Icons = {} + Icons.cmp = { Codeium = " ", Copilot = copilot, @@ -19,9 +21,21 @@ Icons.cmp = { treesitter = " ", } -Icons.diagnostics = { Error = error, Hint = " ", Info = " ", Warn = " " } +Icons.diagnostics = { Error = error, Hint = " ", Info = " ", Warn = " " } -Icons.git = { added = " ", branch = "󰘬", modified = modified, removed = " " } +Icons.git = { + added = " ", + branch = "󰘬", + git = " ", + git_commit = " ", + git_compare = " ", + ignored = " ", + merge = " ", + modified = modified, + removed = " ", + renamed = moved, + staged = "󰱒 ", +} Icons.gitsigns = { add = { text = vert }, @@ -32,38 +46,46 @@ Icons.gitsigns = { untracked = { text = "┆" }, } -Icons.file = { modified = modified, newfile = " ", readonly = " ", unnamed = " " } +Icons.file = { + folder_empty = "󰷍 ", + folder_open = " ", + modified = modified, + newfile = file, + readonly = " ", + unnamed = " ", +} Icons.fillchars = { diff = "░", eob = " ", fold = "󰇼", foldclose = "", foldopen = down, foldsep = "│", vert = vert } Icons.kind_icons = { - Class = "ﴯ", - Color = "", - Constant = "", - Constructor = "", Copilot = copilot, - Enum = "", - EnumMember = "", - Event = "", - Field = "", - File = "", - Folder = "", - Function = "", - Interface = "", - Keyword = "", - Method = "", - Module = "", - Operator = "", - Property = "ﰠ", - Reference = "", - Snippet = "", - Struct = "", - Text = "", - TypeParameter = "", - Unit = "", - Value = "", - Variable = "", + File = file, + Class = " ", + Color = " ", + Constant = " ", + Constructor = " ", + Enum = " ", + EnumMember = " ", + Event = " ", + Field = " ", + Folder = folder, + Function = "󰊕 ", + Interface = " ", + Keyword = "󰌋 ", + Method = " ", + Module = " ", + Operator = " ", + Property = " ", + Reference = " ", + Snippet = " ", + Struct = " ", + Text = " ", + TypeParameter = " ", + Unit = " ", + Value = "󰎠 ", + Null = "󰟢 ", + Variable = "󰀫 ", } Icons.languages = { @@ -104,26 +126,30 @@ Icons.location = { bottom = " ", col = "󰚉 ", line = "󰚈 ", top = " " Icons.misc = { chevron_down = " ", chevron_up = " ", - l = "ℓ", code = " ", down = down, + exit = "󰩈 ", + files = " ", gears = " ", + health = " ", help = "", indent = "▏", - moved = "", + l = "ℓ", + lazy = "󰒲 ", + moved = moved, multi = " ", percent = "󰏰 ", - right = right, + restore = "󰁯 ", + right = "", search = " ", + search_text = "󰱽 ", selection = " ", + tools = " ", wrap = "↵", } -Icons.progress = { - done = " ", - error = error, - pending = "󰔟", - trash = "ﮁ ", -} +Icons.progress = { done = " ", error = error, pending = "󰔟", trash = "ﮁ " } + +Icons.obsidian = { health = "󱨌 ", new = " ", search = "󱙔 ", today = "󱨰 ", yesterday = "󱓩 " } return Icons diff --git a/lua/ui/init.lua b/lua/config/ui/init.lua similarity index 80% rename from lua/ui/init.lua rename to lua/config/ui/init.lua index 6ba0b9b8..f5fbf9d7 100644 --- a/lua/ui/init.lua +++ b/lua/config/ui/init.lua @@ -1,13 +1,11 @@ -require("ui.shortmess") -require("ui.statuscolumn") -require("ui.winbar") +require("config.ui.shortmess") +require("config.ui.statuscolumn") +require("config.ui.winbar") -local icons = require("ui.icons") +local icons = require("config.ui.icons") local opt = vim.opt -vim.cmd.colorscheme("base16-default-dark") - opt.colorcolumn = "100" opt.cursorline = true opt.fillchars = icons.fillchars diff --git a/lua/ui/shortmess.lua b/lua/config/ui/shortmess.lua similarity index 100% rename from lua/ui/shortmess.lua rename to lua/config/ui/shortmess.lua diff --git a/after/plugin/feline.lua b/lua/config/ui/statusbar.lua similarity index 88% rename from after/plugin/feline.lua rename to lua/config/ui/statusbar.lua index 3a038dc2..400d97b1 100644 --- a/after/plugin/feline.lua +++ b/lua/config/ui/statusbar.lua @@ -1,58 +1,55 @@ -if not require("utils").is_vim() then - return nil -end - -local icons = require("ui.icons") +local icons = require("config.ui.icons") +local Statusbar = {} local global_theme = vim.g.theme -local theme = { - fg = global_theme.base04, +Statusbar.theme = { bg = global_theme.base01, black = global_theme.base00, - skyblue = global_theme.base0D, cyan = global_theme.base0C, + fg = global_theme.base04, green = global_theme.base0B, - oceanblue = global_theme.base0D, magenta = global_theme.base0E, + oceanblue = global_theme.base0D, orange = global_theme.base09, red = global_theme.base08, + skyblue = global_theme.base0D, violet = global_theme.base0E, white = global_theme.base05, yellow = global_theme.base0A, } -local vi_mode_colors = { - NORMAL = "skyblue", - OP = "yellow", - INSERT = "green", - VISUAL = "magenta", - LINES = "magenta", +Statusbar.vi_mode_colors = { BLOCK = "magenta", - REPLACE = "orange", - ["V-REPLACE"] = "orange", + COMMAND = "red", ENTER = "cyan", + INSERT = "green", + LINES = "magenta", MORE = "cyan", + NONE = "fg", + NORMAL = "skyblue", + OP = "yellow", + REPLACE = "orange", SELECT = "yellow", - COMMAND = "red", SHELL = "red", TERM = "red", - NONE = "fg", + VISUAL = "magenta", + ["V-REPLACE"] = "orange", } local function get_vi_mode() return require("feline.providers.vi_mode").get_mode_color() end local vim_mode = { - provider = function() return vim.api.nvim_get_mode().mode:upper() end, hl = function() return { fg = "bg", bg = get_vi_mode(), style = "bold", name = "NeovimModeHLColor" } end, left_sep = "block", + provider = function() return vim.api.nvim_get_mode().mode:upper() end, right_sep = "block", } local diagnostic_errors = { hl = { fg = "red" }, provider = "diagnostic_errors" } -local diagnostic_warnings = { hl = { fg = "magenta" }, provider = "diagnostic_warnings" } local diagnostic_hints = { hl = { fg = "cyan" }, provider = "diagnostic_hints" } local diagnostic_info = { hl = { fg = "skyblue" }, provider = "diagnostic_info" } +local diagnostic_warnings = { hl = { fg = "magenta" }, provider = "diagnostic_warnings" } local lsp = { provider = function() @@ -98,10 +95,10 @@ local macro_recording = { local search_count = { provider = { name = "search_count" } } -local git_branch = { hl = { fg = "magenta", style = "bold" }, provider = "git_branch" } local git_add = { hl = { fg = "green" }, provider = "git_diff_added" } -local git_delete = { hl = { fg = "red" }, provider = "git_diff_removed" } +local git_branch = { hl = { fg = "magenta", style = "bold" }, provider = "git_branch" } local git_change = { provider = "git_diff_changed" } +local git_delete = { hl = { fg = "red" }, provider = "git_diff_removed" } local function get_position() return math.floor(vim.api.nvim_win_get_cursor(0)[1] / vim.api.nvim_buf_line_count(0) * 100) @@ -109,17 +106,19 @@ end local progress = { provider = function() + local pos local position = get_position() if position <= 5 then - position = icons.location.top .. "TOP" + pos = icons.location.top .. "TOP" elseif position >= 95 then - position = icons.location.bottom .. "BOT" + pos = icons.location.bottom .. "BOT" else - position = position .. icons.misc.percent + pos = position .. icons.misc.percent end + local line, col = vim.fn.line("."), vim.fn.virtcol(".") - return string.format("%s%d%s%d %s", icons.location.line, line, icons.location.col, col, position) + return string.format("%s%d%s%d %s", icons.location.line, line, icons.location.col, col, pos) end, hl = function() local position = get_position() @@ -157,6 +156,6 @@ local middle = { macro_recording } local right = { search_count, gap, git_branch, git_add, git_delete, git_change, progress } -- TODO: add something for inactive buffers -local components = { active = { left, middle, right }, inactive = { {}, {}, {} } } +Statusbar.components = { active = { left, middle, right }, inactive = { {}, {}, {} } } -require("feline").setup({ components = components, theme = theme, vi_mode_colors = vi_mode_colors }) +return Statusbar diff --git a/lua/ui/statuscolumn.lua b/lua/config/ui/statuscolumn.lua similarity index 96% rename from lua/ui/statuscolumn.lua rename to lua/config/ui/statuscolumn.lua index 279ad518..fd84776a 100755 --- a/lua/ui/statuscolumn.lua +++ b/lua/config/ui/statuscolumn.lua @@ -1,4 +1,4 @@ -local icons = require("ui.icons").misc +local icons = require("config.ui.icons").misc local M = {} _G.Status = M diff --git a/lua/ui/winbar.lua b/lua/config/ui/winbar.lua similarity index 50% rename from lua/ui/winbar.lua rename to lua/config/ui/winbar.lua index 1a308fc3..166c73f8 100644 --- a/lua/ui/winbar.lua +++ b/lua/config/ui/winbar.lua @@ -1,22 +1,16 @@ -if not require("utils").is_vim() then - return nil -end +local icons = require("config.ui.icons") +local navic = require("nvim-navic") -local navic_ok, navic = pcall(require, "nvim-navic") -local feline_ok, feline = pcall(require, "feline") - -local icons = require("ui.icons") - -if not navic_ok or not feline_ok then - return nil -end - -navic.setup({ lsp = { auto_attach = true, preference = { "tsserver", "graphql" } }, highlight = true }) +navic.setup({ + highlight = true, + lsp = { auto_attach = true, preference = { "tsserver", "graphql", "vtsls" } }, +}) local navic_component = { provider = function() return navic.get_location() end, enabled = function() return navic.is_available() end, } + local file_info = { provider = { left_sep = "block", @@ -34,9 +28,12 @@ local file_info_inactive = { }, } -feline.winbar.setup({ - components = { - active = { { file_info, { provider = " " }, navic_component }, {}, {} }, - inactive = { { file_info_inactive }, {} }, - }, -}) +local active = { { file_info, { provider = " " }, navic_component }, {}, {} } + +local inactive = { { file_info_inactive }, {} } + +local Winbar = {} + +Winbar.components = { active = active, inactive = inactive } + +return Winbar diff --git a/lua/utils/init.lua b/lua/config/util/init.lua similarity index 74% rename from lua/utils/init.lua rename to lua/config/util/init.lua index cb43a92a..0c6227b6 100644 --- a/lua/utils/init.lua +++ b/lua/config/util/init.lua @@ -1,5 +1,5 @@ -local logger = require("utils.logger") -local no_format = require("utils.no_format") +local logger = require("config.util.logger") +local no_format = require("config.util.no_format") local api = vim.api local fn = vim.fn @@ -21,11 +21,6 @@ local function feedkeys(keys, mode, escape_ks) return api.nvim_feedkeys(keys, mode or "n", escape_ks or false) end ----wrapper around vim.tbl_extend that always overwrites existing keys ----@param ... table two or more map-like tables ----@return table merged -local tbl_extend_force = function(...) return vim.tbl_extend("force", ...) end - ---@class MapOptions ---@field silent? boolean ---@field noremap? boolean @@ -33,7 +28,12 @@ local tbl_extend_force = function(...) return vim.tbl_extend("force", ...) end ---@field callback? function ---@field replace_keycodes? boolean -local Utils = {} +local Util = {} + +---wrapper around vim.tbl_extend that always overwrites existing keys +---@param ... table two or more map-like tables +---@return table merged +function Util.tbl_extend_force(...) return vim.tbl_extend("force", ...) end ---comment ---@param custom_options MapOptions @@ -41,7 +41,7 @@ local Utils = {} local function get_map_options(custom_options) local options = { silent = true, noremap = true } if custom_options then - options = tbl_extend_force(options, custom_options or {}) + options = Util.tbl_extend_force(options, custom_options or {}) end return options end @@ -57,13 +57,13 @@ end ---@param target string ---@param source string|function ---@param opts? MapOptions -function Utils.map(mode, target, source, opts) vim.keymap.set(mode, target, source, opts and get_map_options(opts)) end +function Util.map(mode, target, source, opts) vim.keymap.set(mode, target, source, opts and get_map_options(opts)) end for _, mode in ipairs(key_map_modes) do - Utils[mode .. "map"] = function(...) Utils.map(mode, ...) end + Util[mode .. "map"] = function(...) Util.map(mode, ...) end end -function Utils.reload_modules() +function Util.reload_modules() local config_path = fn.stdpath("config") local lua_files = fn.glob(config_path .. "/**/*.lua", false, true) @@ -78,13 +78,13 @@ function Utils.reload_modules() logger.info({ msg = "Reloaded all config modules\nReloaded lua modules", title = "Happy hacking!" }) end -Utils.scroll_center = function() feedkeys("zz") end +function Util.scroll_center() feedkeys("zz") end -Utils.feedkeys = feedkeys +Util.feedkeys = feedkeys ---check if the current editor is terminal vim ---@return boolean -function Utils.is_vim() +function Util.is_vim() if g.started_by_firenvim or g.vscode then return false else @@ -92,11 +92,9 @@ function Utils.is_vim() end end -Utils.tbl_extend_force = tbl_extend_force - ---returns `true` if current buffer should be formatted or not ---@param filetype string result of `vim.bo.filetype` ---@return _ boolean if `filetype` should have formatting -function Utils.should_have_formatting(filetype) return not vim.tbl_contains(no_format, filetype) end +function Util.should_have_formatting(filetype) return not vim.tbl_contains(no_format, filetype) end -return Utils +return Util diff --git a/lua/utils/logger.lua b/lua/config/util/logger.lua similarity index 58% rename from lua/utils/logger.lua rename to lua/config/util/logger.lua index 252c8c66..bd359381 100644 --- a/lua/utils/logger.lua +++ b/lua/config/util/logger.lua @@ -12,18 +12,27 @@ local levels = { ---@field msg string? ---@field title string? ---@param logger_args LoggerArgs -Logger.info = function(logger_args) -- - logger(logger_args.msg or "", levels.info, { Title = logger_args.title or "Hey!" }) +function Logger.info(logger_args) -- + vim.defer_fn( + function() logger(logger_args.msg or "", levels.info, { Title = logger_args.title or "Hey!" }) end, + 500 + ) end ---@param logger_args LoggerArgs -Logger.warn = function(logger_args) - logger(logger_args.msg or "", levels.warn, { Title = logger_args.title or "Listen!" }) +function Logger.warn(logger_args) + vim.defer_fn( + function() logger(logger_args.msg or "", levels.warn, { Title = logger_args.title or "Listen!" }) end, + 500 + ) end ---@param logger_args LoggerArgs -Logger.error = function(logger_args) - logger(logger_args.msg or "", levels.error, { Title = logger_args.title or "Error!" }) +function Logger.error(logger_args) + vim.defer_fn( + function() logger(logger_args.msg or "", levels.error, { Title = logger_args.title or "Error!" }) end, + 500 + ) end ---@class ConfirmArgs @@ -33,7 +42,7 @@ end ---@field type string? ---@param confirm_args ConfirmArgs ---@return number confirmation -Logger.confirm = function(confirm_args) +function Logger.confirm(confirm_args) local confirmation = vim.fn.confirm( confirm_args.msg or "Confirm", confirm_args.choices or "&Yes\n&No\n&Cancel", diff --git a/lua/utils/no_format.lua b/lua/config/util/no_format.lua similarity index 95% rename from lua/utils/no_format.lua rename to lua/config/util/no_format.lua index ecf7f1ea..02b9ff01 100644 --- a/lua/utils/no_format.lua +++ b/lua/config/util/no_format.lua @@ -13,6 +13,7 @@ return { "notify", "NvimTree", "ObsidianBacklinks", + "Outline", "packer", "qf", "query", diff --git a/lua/lsp_config/formatting.lua b/lua/lsp_config/formatting.lua deleted file mode 100644 index fbf1f46d..00000000 --- a/lua/lsp_config/formatting.lua +++ /dev/null @@ -1,28 +0,0 @@ -local Formatting = {} - -local lsp_formatting = function(bufnr) - vim.lsp.buf.format({ - filter = function(client) return client.name == "null-ls" end, - bufnr = bufnr, - }) -end - -Formatting.lsp_formatting = lsp_formatting - -local LspFormattingGroup = vim.api.nvim_create_augroup("LspFormatting", {}) - -Formatting.format_on_save = function(client, bufnr) - if not client.supports_method("textDocument/formatting") then - return - end - - vim.api.nvim_clear_autocmds({ group = LspFormattingGroup, buffer = bufnr }) - vim.api.nvim_create_autocmd("BufWritePre", { - group = LspFormattingGroup, - buffer = bufnr, - callback = function() lsp_formatting(bufnr) end, - desc = "LSP format on save", - }) -end - -return Formatting diff --git a/lua/lsp_config/handlers.lua b/lua/lsp_config/handlers.lua deleted file mode 100644 index 45d61b93..00000000 --- a/lua/lsp_config/handlers.lua +++ /dev/null @@ -1,18 +0,0 @@ -local is_okay, telescope = pcall(require, "telescope.builtin") -local handlers = vim.lsp.handlers -local lsp = vim.lsp - -if is_okay then - return function() - handlers["textDocument/documentSymbol"] = telescope.lsp_document_symbols - handlers["textDocument/hover"] = lsp.with(handlers.hover, { border = "rounded" }) - handlers["textDocument/publishDiagnostics"] = - lsp.with(handlers["textDocument/publishDiagnostics"], { signs = true, virtual_text = false }) - handlers["textDocument/references"] = telescope.lsp_references - handlers["textDocument/signatureHelp"] = lsp.with(handlers.signature_help, { border = "rounded" }) - handlers["textdocument/definition"] = telescope.lsp_definitions - handlers["textdocument/implementation"] = telescope.lsp_implementations - handlers["textDocument/documentSymbol"] = telescope.lsp_document_symbols - handlers["workspace/symbol"] = telescope.lsp_workspace_symbols - end -end diff --git a/lua/lsp_config/init.lua b/lua/lsp_config/init.lua deleted file mode 100644 index ad5cdc3d..00000000 --- a/lua/lsp_config/init.lua +++ /dev/null @@ -1,41 +0,0 @@ -local navic = require("nvim-navic") - -local lsp_config = {} - -lsp_config.servers = require("lsp_config.servers") - -local diagnostics = require("lsp_config.diagnostics") -local document_highlighting = require("lsp_config.document_highlight") -local format_on_save = require("lsp_config.formatting").format_on_save -local handlers = require("lsp_config.handlers") -local mappings = require("lsp_config.mappings") - -lsp_config.setup = function() - vim.diagnostic.config({ - current_line_virt = true, - float = { source = "always", border = "rounded" }, - severity_sort = true, - signs = true, - underline = true, - update_in_insert = false, - virtual_text = false, - }) -end - -lsp_config.on_attach = function(client, bufnr) - if client.name == "tsserver" then - client.server_capabilities.documentFormattingProvider = false - end - - if client.server_capabilities.documentSymbolProvider then - navic.attach(client, bufnr) - end - - mappings(bufnr) - handlers() - format_on_save(client, bufnr) - document_highlighting(client, bufnr) - diagnostics(bufnr) -end - -return lsp_config diff --git a/lua/lsp_config/servers.lua b/lua/lsp_config/servers.lua deleted file mode 100644 index 457aa646..00000000 --- a/lua/lsp_config/servers.lua +++ /dev/null @@ -1,76 +0,0 @@ -local lsp_ok, config_util = pcall(require, "lspconfig.util") -local api = vim.api - -if not lsp_ok then - return -end - -local Servers = {} - -Servers.awk_ls = {} - -Servers.bashls = {} - ---Enable (broadcasting) snippet capability for completion -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities.textDocument.completion.completionItem.snippetSupport = true -Servers.cssls = { capabilities = capabilities } - -Servers.denols = { root_dir = config_util.root_pattern("deno.json", "deno.jsonc") } - -Servers.emmet_ls = {} - -Servers.eslint = { - root_dir = config_util.root_pattern( - ".eslintrc", - ".eslintrc.cjs", - ".eslintrc.js", - ".eslintrc.json", - ".eslintrc.yaml", - ".eslintrc.yml" - ), -} - -Servers.graphql = { root_dir = config_util.root_pattern(".graphqlrc*", ".graphql.config.*", "graphql.config.*") } - -Servers.jsonls = - { settings = { json = { schemas = require("schemastore").json.schemas(), validate = { enable = true } } } } - -Servers.lua_ls = { - root_dir = config_util.root_pattern(".luarc.json", ".luacheckrc", ".stylua.toml", "stylua.toml", "selene.toml"), - settings = { - Lua = { - completion = { displayContext = true, keywordSnippet = "Both" }, - diagnostics = { enable = true, disable = { "spell-check" }, globals = { "vim", "_*" } }, - format = { enable = false }, - hint = { enabled = true }, - runtime = { version = "LuaJIT", path = vim.split(package.path, ";") }, - telemetry = { enable = false }, - workspace = { checkThirdParty = false, library = api.nvim_get_runtime_file("", true) }, - }, - }, -} - -Servers.sqlls = {} - -Servers.taplo = { - root_dir = config_util.root_pattern(".taplo.toml"), - settings = { evenBetterToml = { schema = { repositoryEnabled = true } } }, -} - -Servers.vimls = { vimls = { indexes = { "runtime", "nvim", "autoload", "plugin" } } } - -Servers.yamlls = { - root_dir = config_util.root_pattern(".yamlfmt", ".yamllint"), - settings = { - yaml = { - validate = true, - hover = true, - completion = true, - schemaStore = { enable = true, url = "https://www.schemastore.org/api/json/catalog.json" }, - schemas = require("schemastore").json.schemas(), - }, - }, -} - -return Servers diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua new file mode 100644 index 00000000..46fcfd63 --- /dev/null +++ b/lua/plugins/autopairs.lua @@ -0,0 +1,5 @@ +local M = { "windwp/nvim-autopairs" } + +M.config = true + +return M diff --git a/lua/plugins/base16.lua b/lua/plugins/base16.lua new file mode 100644 index 00000000..3eda6728 --- /dev/null +++ b/lua/plugins/base16.lua @@ -0,0 +1,14 @@ +-- local M = "snelling-a/base16.lua" +local M = { "snelling-a/nvim-base16" } + +M.cond = not vim.g.vscode + +M.dev = true + +M.lazy = false + +M.priority = 1000 + +function M.config() vim.cmd.colorscheme("base16-default-dark") end + +return M diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 00000000..195fa194 --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,102 @@ +local icons = require("config.ui.icons") + +local formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + vim_item.kind = icons.kind_icons[vim_item.kind] + vim_item.menu = icons.cmp[entry.source.name] + return vim_item + end, +} + +local function luasnip_extend() + local luasnip = require("luasnip") + + luasnip.filetype_extend("javascript", { "html" }) + luasnip.filetype_extend("javascriptreact", { "html", "javascript" }) + luasnip.filetype_extend("typescript", { "html", "javascript" }) + luasnip.filetype_extend("typescriptreact", { "html", "javascript" }) +end + +local M = { "hrsh7th/nvim-cmp" } + +M.cond = not vim.g.vscode + +M.dependencies = { + "chrisgrieser/cmp-nerdfont", + "davidsierradz/cmp-conventionalcommits", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-nvim-lsp-document-symbol", + "hrsh7th/cmp-nvim-lsp-signature-help", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-path", + "L3MON4D3/LuaSnip", + "neovim/nvim-lspconfig", + "petertriho/cmp-git", + "ray-x/cmp-treesitter", + "saadparwaiz1/cmp_luasnip", + "zbirenbaum/copilot-cmp", + { "David-Kunz/cmp-npm", dependencies = { "nvim-lua/plenary.nvim" } }, +} + +M.event = "InsertEnter" + +function M.config() + local cmp = require("cmp") + local mapping = cmp.mapping + local config = cmp.config + + cmp.setup({ + experimental = { ghost_text = { hl_group = "LspCodeLens" } }, + formatting = formatting, + mapping = mapping.preset.insert({ + [""] = mapping.scroll_docs(-4), + [""] = mapping.scroll_docs(4), + [""] = mapping.complete(), + [""] = mapping.abort(), + [""] = mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), + }), + snippet = { expand = function(args) require("luasnip").lsp_expand(args.body) end }, + sources = config.sources( + { { name = "copilot" }, { name = "nvim_lsp" }, { name = "nvim_lsp_signature_help" } }, + { { name = "luasnip" }, { name = "treesitter", max_item_count = 5 }, { name = "nvim_lua" } }, + { { name = "buffer" }, { name = "nerdfont" } }, + { { name = "obsidian" }, { name = "obsidian_new" }, { name = "npm", keyword_length = 4 } } + ), + sorting = { + priority_weight = 2, + comparators = { + require("copilot_cmp.comparators").prioritize, + config.compare.offset, + config.compare.exact, + config.compare.score, + config.compare.recently_used, + config.compare.locality, + config.compare.kind, + config.compare.sort_text, + config.compare.length, + config.compare.order, + }, + }, + }) + + luasnip_extend() + + cmp.setup.filetype("gitcommit", { + sources = config.sources({ { name = "cmp" }, { name = "conventionalcommits" } }, { { name = "buffer" } }), + }) + + cmp.setup.cmdline({ "/", "?" }, { + mapping = mapping.preset.cmdline(), + sources = cmp.config.sources({ { name = "nvim_lsp_document_symbol" } }, { { name = "buffer" } }), + }) + + cmp.setup.cmdline(":", { + mapping = mapping.preset.cmdline(), + sources = config.sources({ { name = "path" } }, { { name = "cmdline" } }), + }) +end + +return M diff --git a/after/plugin/colorizer.lua b/lua/plugins/colorizer.lua similarity index 81% rename from after/plugin/colorizer.lua rename to lua/plugins/colorizer.lua index a0987775..72f5c695 100644 --- a/after/plugin/colorizer.lua +++ b/lua/plugins/colorizer.lua @@ -1,26 +1,30 @@ -local no_format = require("utils.no_format") +local no_format = require("config.util.no_format") local function no_color() return vim.tbl_map(function(filetype) return "!" .. filetype end, no_format) end -require("colorizer").setup({ +local M = { "NvChad/nvim-colorizer.lua" } + +M.opts = { + buftypes = no_color(), filetypes = { "*", cmp_docs = { always_update = true } }, user_default_options = { - RGB = true, - RRGGBB = true, - names = true, - RRGGBBAA = true, AARRGGBB = true, - rgb_fn = false, - hsl_fn = false, + always_update = false, css = false, css_fn = false, + hsl_fn = false, mode = "foreground", - tailwind = false, + names = true, + RGB = true, + rgb_fn = false, + RRGGBB = true, + RRGGBBAA = true, sass = { enable = false, parsers = { "css" } }, + tailwind = false, virtualtext = "■", - always_update = false, }, - buftypes = no_color(), -}) +} + +return M diff --git a/lua/plugins/comment.lua b/lua/plugins/comment.lua new file mode 100644 index 00000000..0daaf89b --- /dev/null +++ b/lua/plugins/comment.lua @@ -0,0 +1,15 @@ +local M = { "numToStr/Comment.nvim" } + +M.dependencies = "nvim-treesitter/nvim-treesitter" + +M.keys = { + { "gc", mode = { "n", "v" }, desc = "To[g]gle [c]omment" }, + { "gb", mode = { "n", "v" }, desc = "To[g]gle [b]lock comment" }, +} + +function M.opts() + local commentstring_avail, commentstring = pcall(require, "ts_context_commentstring.integrations.comment_nvim") + return commentstring_avail and commentstring and { pre_hook = commentstring.create_pre_hook() } or {} +end + +return M diff --git a/lua/plugins/copilot.lua b/lua/plugins/copilot.lua new file mode 100644 index 00000000..d4d4a7f4 --- /dev/null +++ b/lua/plugins/copilot.lua @@ -0,0 +1,46 @@ +local kind_icons = require("config.ui.icons").kind_icons +local logger = require("config.util.logger") + +local function get_node_path() + local node = vim.fn.exepath("node") + + if not node then + logger.warn({ msg = "Node not found in path", title = kind_icons.Copilot .. " Copilot" }) + return + end + + return node +end + +local M = { "github/copilot.vim" } + +M.build = ":Copilot auth" + +M.cond = not vim.g.vscode + +M.dependencies = { + { + "zbirenbaum/copilot-cmp", + opts = {}, + config = function(_, opts) + local copilot_cmp = require("copilot_cmp") + copilot_cmp.setup(opts) + + vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + + if client.name == "copilot" then + copilot_cmp._on_insert_enter() + end + end, + }) + end, + }, + { + "zbirenbaum/copilot.lua", + opts = { copilot_node_path = get_node_path, panel = { enabled = false }, suggestion = { enabled = true } }, + }, +} + +return M diff --git a/lua/plugins/feline.lua b/lua/plugins/feline.lua new file mode 100644 index 00000000..a3cd31bf --- /dev/null +++ b/lua/plugins/feline.lua @@ -0,0 +1,23 @@ +local M = { "freddiehaddad/feline.nvim" } + +M.cond = require("config.util").is_vim() + +M.dependencies = { "SmiteshP/nvim-navic" } + +function M.config() + local statusbar = require("config.ui.statusbar") + local winbar = require("config.ui.winbar") + local feline = require("feline") + + ---@diagnostic disable-next-line: need-check-nil + feline.setup({ + components = statusbar.components, + theme = statusbar.theme, + vi_mode_colors = statusbar.vi_mode_colors, + }) + + ---@diagnostic disable-next-line: need-check-nil + feline.winbar.setup({ components = winbar.components }) +end + +return M diff --git a/lua/plugins/fugitive.lua b/lua/plugins/fugitive.lua new file mode 100644 index 00000000..34db4d55 --- /dev/null +++ b/lua/plugins/fugitive.lua @@ -0,0 +1,47 @@ +local util = require("config.util") + +local api = vim.api +local git = vim.cmd.Git + +local function set_fugitive_keymaps() + if vim.bo.ft ~= "fugitive" then + return + end + + local fzf = require("fzf-lua") + + local bufnr = api.nvim_get_current_buf() + local opts = { buffer = bufnr } + + util.nmap("p", function() git("push") end, util.tbl_extend_force(opts, { desc = "Git [p]ush" })) + util.nmap( + "P", + function() git({ "pull", "--rebase" }) end, + util.tbl_extend_force(opts, { desc = "Git [P]ull" }) + ) + util.nmap( + "t", + function() git({ "push -u origin" }) end, + util.tbl_extend_force(opts, { desc = "Push [t]o origin" }) + ) + util.nmap("gb", fzf.git_branches, { desc = "View [g]it [b]ranches" }) + util.nmap("gc", fzf.git_commits, { desc = "View [g]it [c]ommits" }) + util.nmap("gst", fzf.git_stash, { desc = "View [g]it [st]ash" }) +end + +local M = { "tpope/vim-fugitive" } + +M.cmd = { "G", "Git" } + +M.keys = { { "gs", vim.cmd.Git, desc = "[G]it [s]tatus" } } + +function M.config() + api.nvim_create_autocmd("BufWinEnter", { + callback = function() set_fugitive_keymaps() end, + desc = "Set fugitive keymaps", + group = api.nvim_create_augroup("Fugitive", {}), + pattern = "*", + }) +end + +return M diff --git a/lua/plugins/fzf.lua b/lua/plugins/fzf.lua new file mode 100644 index 00000000..a27670f4 --- /dev/null +++ b/lua/plugins/fzf.lua @@ -0,0 +1,80 @@ +local icons = require("config.ui.icons") + +local preview_pager = "delta --width=$FZF_PREVIEW_COLUMNS" + +---@param icon string +---@return string +local function get_prompt(icon) return string.format("%s %s ", icon, icons.misc.right) end + +local M = { "ibhagwan/fzf-lua" } +-- local M = {} +M.dir = "~/dev/github.com/ibhagwan/fzf-lua" + +M.dependencies = { "nvim-tree/nvim-web-devicons" } + +M.keys = { + { "", function() require("fzf-lua").files() end, desc = "Open [p]roject files" }, + { "", function() require("fzf-lua").live_grep() end, desc = "[R]un live grep" }, + { "", function() require("fzf-lua").builtin() end, desc = "Open builtins" }, + { "", function() require("fzf-lua").keymaps() end, desc = "Show keymaps" }, + { "b", function() require("fzf-lua").buffers() end, desc = "Show [b]uffers" }, + { "fh", function() require("fzf-lua").help_tags() end, desc = "[H]elp" }, + { + "gr", + function() require("fzf-lua").lsp_references({ ignore_current_line = true }) end, + desc = "[G]et [R]eference", + }, + { "q", function() require("fzf-lua").quickfix() end }, + { "qf", function() require("fzf-lua").quickfix() end }, + { '""', function() require("fzf-lua").registers() end, desc = "View registers" }, +} + +---@return table +local function get_diagnostics_signs() + local signs = {} + for key, value in pairs(icons.diagnostics) do + table.insert(signs, { [key] = { text = value, texthl = "Diagnostic" .. key } }) + end + return unpack(signs) +end + +get_diagnostics_signs() +M.opts = { + diagnostics = { + prompt = ":Diagnostics❯ ", + signs = get_diagnostics_signs(), + }, + files = { + fd_opts = "--color=never --type f --hidden --no-ignore --follow --exclude .git --exclude node_modules", + prompt = get_prompt(icons.misc.files), + }, + git = { + branches = { prompt = get_prompt(icons.git.branch) }, + commit = { preview_pager = preview_pager, prompt = get_prompt(icons.misc.git_commit) }, + files = { prompt = get_prompt(icons.misc.git) }, + icons = { + ["A"] = { icon = icons.git.added, color = "green" }, + ["D"] = { icon = icons.git.removed, color = "red" }, + ["M"] = { icon = icons.git.modified, color = "magenta" }, + }, + status = { preview_pager = preview_pager, prompt = get_prompt(icons.misc.git_compare) }, + }, + grep = { prompt = get_prompt(icons.misc.search) }, + previewers = { + bat = { args = "--style=numbers,changes --color always", config = nil, theme = "base16" }, + git_diff = { pager = preview_pager }, + }, + winopts = { preview = { default = "bat" } }, +} + +function M.config(_, opts) + local fzf_lua = require("fzf-lua") + + fzf_lua.deregister_ui_select({}, true) + + vim.api.nvim_create_autocmd("VimResized", { pattern = "*", callback = function() require("fzf-lua").redraw() end }) + + fzf_lua.setup(opts) +end + +return M diff --git a/after/plugin/gitsigns.lua b/lua/plugins/gitsigns.lua similarity index 92% rename from after/plugin/gitsigns.lua rename to lua/plugins/gitsigns.lua index 3ed1430f..f7878810 100644 --- a/after/plugin/gitsigns.lua +++ b/lua/plugins/gitsigns.lua @@ -1,5 +1,5 @@ -local signs = require("ui.icons").gitsigns -local utils = require("utils") +local signs = require("config.ui.icons").gitsigns +local utils = require("config.util") local function current_line_blame_formatter_nc(_, blame_info, _) if blame_info.committer == "Not Committed Yet" then @@ -62,11 +62,17 @@ local function on_attach(bufnr) utils.map({ "o", "x" }, "ah", function() gs.select_hunk() end, { desc = "Select [a]round [h]unk" }) end -require("gitsigns").setup({ +local M = { "lewis6991/gitsigns.nvim" } + +M.opts = { current_line_blame = true, current_line_blame_formatter_nc = current_line_blame_formatter_nc, numhl = true, on_attach = on_attach, preview_config = { border = "rounded" }, signs = signs, -}) +} + +M.config = true + +return M diff --git a/lua/plugins/headlines.lua b/lua/plugins/headlines.lua new file mode 100644 index 00000000..f0e05694 --- /dev/null +++ b/lua/plugins/headlines.lua @@ -0,0 +1,17 @@ +local M = { "lukas-reineke/headlines.nvim" } + +M.dependencies = { "nvim-treesitter/nvim-treesitter" } + +M.opts = { + markdown = { + codeblock_highlight = "CodeBlock", + dash_highlight = "Dash", + dash_string = "x", + fat_headlines = false, + headline_highlights = { "Headline" }, + quote_highlight = "Quote", + quote_string = "┃", + }, +} + +return M diff --git a/after/plugin/indent-blankline.lua b/lua/plugins/indent-blankline.lua similarity index 69% rename from after/plugin/indent-blankline.lua rename to lua/plugins/indent-blankline.lua index 7ba25a66..ca71166e 100644 --- a/after/plugin/indent-blankline.lua +++ b/lua/plugins/indent-blankline.lua @@ -1,6 +1,8 @@ -local icon = require("ui.icons").misc.indent +local icon = require("config.ui.icons").misc.indent -require("indent_blankline").setup({ +local M = { "lukas-reineke/indent-blankline.nvim" } + +M.opts = { char = icon, context_highlight_list = { "IndentBlanklineIndent1", @@ -15,4 +17,8 @@ require("indent_blankline").setup({ space_char_blankline = " ", use_treesitter = true, use_treesitter_scope = true, -}) +} + +M.event = "BufReadPre" + +return M diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua new file mode 100644 index 00000000..3ddb75fb --- /dev/null +++ b/lua/plugins/lspconfig.lua @@ -0,0 +1,46 @@ +local icons = require("config.ui.icons") + +local M = { "neovim/nvim-lspconfig" } + +M.dependencies = { + "b0o/schemastore.nvim", + "folke/neodev.nvim", + "hrsh7th/cmp-nvim-lsp", + "ibhagwan/fzf-lua", + "jparise/vim-graphql", + "lvimuser/lsp-inlayhints.nvim", + "SmiteshP/nvim-navic", + "yioneko/nvim-vtsls", + { + "williamboman/mason.nvim", + opts = { + ui = { + border = "rounded", + icons = { + package_installed = icons.done, + package_pending = icons.pending, + package_uninstalled = icons.trash, + }, + }, + }, + }, + { "williamboman/mason-lspconfig.nvim", opts = { automatic_installation = true } }, +} + +function M.config() + local opts = { + capabilities = require("cmp_nvim_lsp").default_capabilities(), + flags = { debounce_text_changes = 150 }, + on_attach = require("config.lsp").on_attach, + } + + for index, value in vim.fs.dir("$XDG_CONFIG_HOME/neovim/lua/config/lsp/server") do + if value ~= "file" then + return + end + + require("config.lsp.server." .. index:gsub(".lua", "")).setup(opts) + end +end + +return M diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua new file mode 100644 index 00000000..202b5205 --- /dev/null +++ b/lua/plugins/neo-tree.lua @@ -0,0 +1,92 @@ +local icons = require("config.ui.icons") + +local M = { "nvim-neo-tree/neo-tree.nvim" } + +M.dependencies = { + "MunifTanjim/nui.nvim", + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + { + "s1n7ax/nvim-window-picker", + opts = { + autoselect_one = true, + filter_rules = { + bo = { buftype = { "terminal", "quickfix" }, filetype = { "neo-tree", "neo-tree-popup", "notify" } }, + }, + include_current = false, + other_win_hl_color = "#e35e4f", + }, + }, +} + +M.keys = { + { ".", function() vim.cmd.Neotree("toggle") end, desc = "Toggle NeoTree" }, + { "bf", function() vim.cmd.Neotree("buffers") end, desc = "Toggle open buffers" }, + { "gss", function() vim.cmd.Neotree({ args = { "float", "git_status" } }) end }, + { "|", function() vim.cmd.Neotree("reveal") end, desc = "Reveal current file in Neotree" }, +} + +M.opts = { + filesystem = { + filtered_items = { + never_show = { + ".git", + ".hg", + ".DS_Store", + ".Trashes", + "__MACOSX", + "ehthumbs.db", + "Thumbs.db", + }, + hide_dotfiles = false, + hide_gitignored = false, + visible = true, + }, + }, + window = { + position = "right", + width = 30, + fuzzy_finder_mappings = { [""] = "move_cursor_down", [""] = "move_cursor_up" }, + mappings = { + [""] = "open_with_window_picker", + ["l"] = "focus_preview", + ["S"] = "split_with_window_picker", + ["s"] = "vsplit_with_window_picker", + ["t"] = "open_tabnew", + ["w"] = "open_with_window_picker", + ["C"] = "close_all_subnodes", + ["z"] = "close_all_nodes", + ["Z"] = "expand_all_nodes", + ["a"] = { "add", config = { show_path = "relative" } }, + ["A"] = { "add_directory", config = { show_path = "relative" } }, + }, + }, + open_files_do_not_replace_types = { "terminal", "trouble", "qf", "neo-tree" }, + default_component_configs = { + icon = { + folder_closed = icons.kind_icons.Folder, + folder_open = icons.file.folder_open, + folder_empty = icons.file.folder_empty, + }, + -- modified = { + -- symbol = false, + -- }, + git_status = { + symbols = { + added = icons.git.added, + conflict = icons.git.merge, + deleted = icons.git.removed, + ignored = icons.git.ignored, + -- modified = icons.git.modified, + renamed = icons.git.renamed, + staged = icons.git.staged, + unstaged = icons.git.modified, + untracked = icons.misc.help, + }, + }, + }, +} + +M.config = true + +return M diff --git a/after/plugin/noice.lua b/lua/plugins/noice.lua similarity index 52% rename from after/plugin/noice.lua rename to lua/plugins/noice.lua index fa2ada27..0d9a96de 100644 --- a/after/plugin/noice.lua +++ b/lua/plugins/noice.lua @@ -1,9 +1,4 @@ -if not require("utils").is_vim() then - return nil -end - -local icons = require("ui.icons") -local noice = require("noice") +local icons = require("config.ui.icons") local function pad_right(icon) return icon .. " " end local function get_search(icon) return icons.misc.search .. icon end @@ -11,17 +6,17 @@ local function get_search(icon) return icons.misc.search .. icon end local cmdline = { -- view = "cmdline", format = { - cmdline = { pattern = "^:", icon = pad_right(icons.languages.vim), lang = "vim" }, - search_down = { kind = "search", pattern = "^/", icon = get_search(icons.misc.chevron_down), lang = "regex" }, - search_up = { kind = "search", pattern = "^%?", icon = get_search(icons.misc.chevron_up), lang = "regex" }, - filter = { pattern = "^:%s*!", icon = pad_right(icons.languages.bash), lang = "bash" }, + cmdline = { icon = pad_right(icons.languages.vim), lang = "vim", pattern = "^:" }, + filter = { icon = pad_right(icons.languages.bash), lang = "bash", pattern = "^:%s*!" }, + input = { lang = "vim" }, lua = { - pattern = { "^:%s*lua%s+", "^:%s*lua%s*=%s*", "^:%s*=%s*" }, icon = pad_right(icons.languages.lua), lang = "lua", + pattern = { "^:%s*lua%s+", "^:%s*lua%s*=%s*", "^:%s*=%s*" }, }, - help = { pattern = "^:%s*he?l?p?%s+", icon = pad_right(icons.misc.help) }, - input = { lang = "vim" }, + help = { icon = pad_right(icons.misc.help), pattern = "^:%s*he?l?p?%s+" }, + search_down = { icon = get_search(icons.misc.chevron_down), kind = "search", lang = "regex", pattern = "^/" }, + search_up = { icon = get_search(icons.misc.chevron_up), kind = "search", lang = "regex", pattern = "^%?" }, }, } @@ -31,41 +26,47 @@ local lsp_progress_format = { { "[{data.progress.title}] ", hl_group = "NoiceLspProgressTitle" }, } -local lsp = { - progress = { format = lsp_progress_format }, - hover = { enabled = false }, - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = false, - ["vim.lsp.util.stylize_markdown"] = false, - ["cmp.entry.get_documentation"] = false, - }, - message = { enabled = false }, - signature = { enabled = false }, - -- message = { view = "mini" }, -} - local routes = { - { view = "split", filter = { event = "msg_show", min_height = 20 } }, + { view = "split", filter = { event = "msg_show", min_height = 10 } }, { filter = { any = { { event = "msg_show", kind = "emsg", find = "E382" }, -- Cannot write, 'buftype' option is set { event = "msg_show", kind = "lua_error", find = "E5108" }, -- CellularAutomation error if folds in file - { event = "notify", kind = "warn", find = "Already attached" }, -- navic can only attach to 1 server + { event = "notify", kind = "warn", find = "Already attached" }, -- navic preferences don't work with 3 servers }, }, opts = { skip = true }, }, } -noice.setup({ +local M = { "folke/noice.nvim" } + +M.dependencies = { "MunifTanjim/nui.nvim", "rcarriga/nvim-notify" } + +M.opts = { cmdline = cmdline, - messages = { view = "mini", view_error = "mini", view_warn = "mini", view_search = false }, - redirect = { view = "mini" }, - popupmenu = { enabled = true, backend = "cmp", kind_icons = icons.kind_icons }, commands = {}, + lsp = { + override = { + ["cmp.entry.get_documentation"] = true, + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + }, + progress = { format = lsp_progress_format }, + }, + messages = { view = "mini", view_error = "mini", view_warn = "mini", view_search = false }, notify = { view = "mini" }, - lsp = lsp, - presets = { long_message_to_split = true }, + popupmenu = { enabled = true, backend = "cmp", kind_icons = icons.kind_icons }, + presets = { + bottom_search = true, + command_palette = true, + inc_rename = false, + long_message_to_split = true, + lsp_doc_border = true, + }, + redirect = { view = "mini" }, routes = routes, -}) +} + +return M diff --git a/lua/plugins/null-ls.lua b/lua/plugins/null-ls.lua new file mode 100644 index 00000000..0831b6aa --- /dev/null +++ b/lua/plugins/null-ls.lua @@ -0,0 +1,86 @@ +local M = { "jose-elias-alvarez/null-ls.nvim" } + +M.dependencies = { "jay-babu/mason-null-ls.nvim", "williamboman/mason.nvim" } + +function M.config() + local disabled_filetypes = require("config.util.no_format") + local null_ls = require("null-ls") + + local builtins = null_ls.builtins + local builtins_code_actions = builtins.code_actions + local builtins_diagnostics = builtins.diagnostics + local builtins_formatting = builtins.formatting + + local builtins_diagnostics_cspell = builtins_diagnostics.cspell.with({ + disabled_filetypes = disabled_filetypes, + diagnostics_postprocess = function(diagnostic) diagnostic.severity = vim.diagnostic.severity["HINT"] end, + }) + + local builtins_diagnostics_luacheck = builtins_diagnostics.luacheck.with({ + condition = function(utils) return utils.root_has_file({ ".luacheckrc" }) end, + }) + + local builtins_diagnostics_yamllint = builtins_diagnostics.yamllint.with({ + extra_args = function() + if vim.fn.filereadable(".yamllint") == 1 then + local config_file = vim.fn.getcwd() .. "/.yamllint" + return { "--config-file", config_file } + end + return {} + end, + condition = function(utils) return utils.root_has_file({ ".yamllint", ".yamllint.yaml", ".yamllint.yml" }) end, + }) + + local builtins_formatting_deno_fmt = builtins.formatting.deno_fmt.with({ + condition = function(utils) return utils.root_has_file({ "deno.json*" }) end, + }) + + local builtins_formatting_prettierd = builtins.formatting.prettierd.with({ + condition = function(utils) + return utils.root_has_file({ + ".prettierrc", + ".prettierrc.cjs", + ".prettierrc.js", + ".prettierrc.json", + ".prettierrc.json5", + ".prettierrc.toml", + ".prettierrc.yaml", + ".prettierrc.yml", + "prettier.config.cjs", + "prettier.config.js", + }) + end, + }) + + null_ls.setup({ + border = "rounded", + diagnostics_format = "[#{c}] #{m} (#{s})", + on_attach = require("config.lsp").on_attach, + sources = { + builtins_code_actions.cspell.with({ disabled_filetypes = disabled_filetypes }), + builtins_code_actions.shellcheck, + builtins_diagnostics.alex, + builtins_diagnostics.gitlint, + builtins_diagnostics.shellcheck.with({ extra_args = { "-x" } }), + builtins_diagnostics.todo_comments, + builtins_diagnostics.vint, + builtins_diagnostics.zsh, + builtins_diagnostics_cspell, + builtins_diagnostics_luacheck, + builtins_diagnostics_yamllint, + builtins_formatting.cbfmt, + builtins_formatting.jq, + builtins_formatting.shfmt, + builtins_formatting.stylua, + builtins_formatting.taplo, + builtins_formatting.yamlfmt, + builtins_formatting.yq, + builtins_formatting_deno_fmt, + builtins_formatting_prettierd, + }, + }) + + require("mason-null-ls").setup({ ensure_installed = nil, automatic_installation = true, automatic_setup = false }) +end + +return M diff --git a/lua/plugins/obsidian.lua b/lua/plugins/obsidian.lua new file mode 100644 index 00000000..461c49ac --- /dev/null +++ b/lua/plugins/obsidian.lua @@ -0,0 +1,59 @@ +local cmd = vim.cmd +local vault_directory = os.getenv("NOTES") or os.getenv("HOME") .. "/notes" + +local function note_id_func(input) + local title = "Untitled" + if input ~= nil then + title = input:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower() + end + + return os.date("%Y%m%d%H%M") .. "-" .. title +end + +local M = { "epwalsh/obsidian.nvim" } + +M.is_vault_dir = vim.fn.getcwd() == vault_directory + +M.dependencies = { + "nvim-lua/plenary.nvim", + "hrsh7th/nvim-cmp", + "ibhagwan/fzf-lua", + "nvim-treesitter/nvim-treesitter", +} + +M.event = { "BufReadPre " .. vault_directory .. "/*" } + +M.ft = "markdown" + +M.keys = { + { "dn", cmd.ObsidianToday, desc = "Open today's [d]aily [n]ote" }, + { "ob", cmd.ObsidianBacklinks, desc = "[O]pen [b]acklinks" }, + { "ol", cmd.ObsidianLinkNew, desc = "[O]pen [l]ink in new buffer" }, + { "on", cmd.ObsidianNew, desc = "[O]pen [n]ew note" }, + { "ot", cmd.ObsidianToday, desc = "[O]pen [t]oday's daily note" }, + { "oy", cmd.ObsidianYesterday, desc = "[O]pen [y]esterday's daily note" }, + { + "gf", + function() + if require("obsidian").util.cursor_on_markdown_link() then + return vim.cmd.ObsidianFollowLink() + else + return "gf" + end + end, + desc = "[F]ollow link", + }, +} + +M.lazy = not M.is_vault_dir + +M.opts = { + completion = { nvim_cmp = true }, + daily_notes = { folder = "daily-notes" }, + dir = vault_directory, + note_id_func = note_id_func, + open_app_foreground = true, + use_advanced_uri = true, +} + +return M diff --git a/lua/plugins/surround.lua b/lua/plugins/surround.lua new file mode 100644 index 00000000..5cd5719c --- /dev/null +++ b/lua/plugins/surround.lua @@ -0,0 +1,9 @@ +local M = { "kylechui/nvim-surround" } + +M.config = true + +M.event = "BufRead" + +M.version = "*" + +return M diff --git a/lua/plugins/symbols-outline.lua b/lua/plugins/symbols-outline.lua new file mode 100644 index 00000000..e4c4d76b --- /dev/null +++ b/lua/plugins/symbols-outline.lua @@ -0,0 +1,23 @@ +local icons = require("config.ui.icons") + +local M = { "simrat39/symbols-outline.nvim" } + +M.cmd = "SymbolsOutline" + +local function get_symbols() + local symbols = {} + + for k, v in pairs(icons.kind_icons) do + symbols[k] = { icon = v } + end + + return symbols +end + +M.opts = { + fold_markers = { icons.misc.right, icons.misc.down }, + position = "left", + symbols = get_symbols(), +} + +return M diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 00000000..8b957630 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,106 @@ +local util = require("config.util") + +local ensure_installed = { + "awk", + "bash", + "comment", + "css", + "diff", + "git_config", + "git_rebase", + "gitattributes", + "gitcommit", + "gitignore", + "graphql", + "html", + "http", + "javascript", + "jq", + "json", + "json5", + "jsonc", + "lua", + "markdown", + "markdown_inline", + "passwd", + "query", + "regex", + "scss", + "sql", + "toml", + "tsx", + "typescript", + "vim", + "vimdoc", + "yaml", +} + +local textobjects = { + select = { + enable = true, + lookahead = true, + lsp_interop = { + enable = true, + floating_preview_opts = { border = "rounded" }, + peek_definition_code = { ["df"] = "@function.outer", ["dF"] = "@class.outer" }, + }, + keymaps = { + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["aa"] = "@parameter.outer", + ["ia"] = "@parameter.inner", + ["ac"] = "@call.outer", + ["ic"] = "@call.inner", + ["ao"] = "@block.outer", + ["io"] = "@block.inner", + }, + }, +} + +local M = { "nvim-treesitter/nvim-treesitter" } + +M.build = ":TSUpdate" + +M.dependencies = { + "HiPhish/nvim-ts-rainbow2", + "JoosepAlviste/nvim-ts-context-commentstring", + "nvim-treesitter/nvim-treesitter-textobjects", + "windwp/nvim-ts-autotag", + { "nvim-treesitter/nvim-treesitter-context", opts = { mode = "topline" }, config = true }, +} + +M.event = { "BufReadPost", "BufNewFile" } + +M.opts = { + auto_install = true, + autotag = { enable = true }, + context_commentstring = { enable = true, enable_autocmd = true }, + ensure_installed = ensure_installed, + highlight = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = false, + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, + indent = { enable = true }, + textobjects = textobjects, +} + +M.version = false + +function M.config(_, opts) + require("nvim-treesitter.configs").setup(util.tbl_extend_force(opts, { + rainbow = { + enable = true, + extended_mode = true, + query = "rainbow-parens", + strategy = require("ts-rainbow").strategy.global, + }, + })) +end + +return M diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua new file mode 100644 index 00000000..133eb245 --- /dev/null +++ b/lua/plugins/trouble.lua @@ -0,0 +1,22 @@ +local M = { "folke/trouble.nvim" } + +M.keys = { + { "xx", function() vim.cmd.TroubleToggle(nil) end, desc = "Toggle trouble" }, + { + "xw", + function() vim.cmd.TroubleToggle("workspace_diagnostics") end, + desc = "Toggle trouble for [w]orspace", + }, + { + "xd", + function() vim.cmd.TroubleToggle("document_diagnostics") end, + desc = "Toggle trouble for [d]ocument", + }, + { "xl", function() vim.cmd.TroubleToggle("loclist") end, desc = "Toggle trouble [l]oclist" }, + { "xq", function() vim.cmd.TroubleToggle("quickfix") end, desc = "Toggle trouble [q]uickfix" }, + { "gR", function() vim.cmd.TroubleToggle("lsp_references") end, desc = "Toggle trouble for LSP [R]eference" }, +} + +M.opts = { auto_close = true, mode = "workspace_diagnostics", use_diagnostic_signs = true } + +return M diff --git a/lua/plugins/undotree.lua b/lua/plugins/undotree.lua new file mode 100644 index 00000000..d51c498c --- /dev/null +++ b/lua/plugins/undotree.lua @@ -0,0 +1,9 @@ +local M = { "mbbill/undotree" } + +M.cmd = "UndotreeToggle" + +M.keys = { { "u", vim.cmd.UndotreeToggle, desc = "Toggle [u]ndotree" } } + +function M.config() vim.api.nvim_set_var("undotree_SetFocusWhenToggle", 1) end + +return M diff --git a/lua/user/init.lua b/lua/user/init.lua deleted file mode 100644 index b779c9fe..00000000 --- a/lua/user/init.lua +++ /dev/null @@ -1,39 +0,0 @@ -require("user.autocommands") -require("user.packer") -require("user.remap") -require("user.sessions") -require("user.set") -require("user.commands") - -local default_plugins = { - "2html_plugin", - "getscript", - "getscriptPlugin", - "gzip", - "logipat", - "netrw", - "netrwPlugin", - "netrwSettings", - "netrwFileHandlers", - "matchit", - "tar", - "tarPlugin", - "rrhelper", - "spellfile_plugin", - "vimball", - "vimballPlugin", - "zip", - "zipPlugin", - "tutor", - "rplugin", - "syntax", - "synmenu", - "optwin", - "compiler", - "bugreport", - "ftplugin", -} - -for _, plugin in pairs(default_plugins) do - vim.g["loaded_" .. plugin] = 1 -end diff --git a/lua/user/packer.lua b/lua/user/packer.lua deleted file mode 100644 index f6a0202a..00000000 --- a/lua/user/packer.lua +++ /dev/null @@ -1,165 +0,0 @@ -local icons = require("ui.icons") - -local api = vim.api -local cmd = vim.cmd -local fn = vim.fn - -local ensure_packer = function() - local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" - if fn.empty(fn.glob(install_path)) > 0 then - fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }) - cmd([[packadd packer.nvim]]) - return true - end - return false -end - -local packer_bootstrap = ensure_packer() - -local status_ok, packer = pcall(require, "packer") -if not status_ok then - return -end - -api.nvim_create_autocmd("BufWritePost", { - pattern = "packer.lua", - command = "source | PackerCompile", - group = api.nvim_create_augroup("PackerGroup", {}), -}) - -packer.init({ - display = { - done_sym = icons.progress.done, - error_sym = icons.progress.error, - header_sym = "—", - moved_sym = icons.misc.moved, - removed_sym = icons.progress.trash, - working_sym = icons.progress.pending, - }, - luarocks = { python_cmd = "python3" }, -}) - -local dev_dir = os.getenv("HOME") .. "/dev/github.com/" - -return packer.startup(function(use) - use({ "wbthomason/packer.nvim" }) - - use({ "lewis6991/impatient.nvim" }) - - -- [[ UI]] - use({ - "eandrju/cellular-automaton.nvim", - "folke/zen-mode.nvim", - "lukas-reineke/indent-blankline.nvim", - dev_dir .. "snelling-a/nvim-base16", - -- "snelling-a/nvim-base16", - { - -- dev_dir .. "snelling-a/better-folds.nvim", - "snelling-a/better-folds.nvim", - config = function() require("better-folds").setup() end, - }, - "NvChad/nvim-colorizer.lua", - { "nvim-tree/nvim-tree.lua", requires = { "nvim-tree/nvim-web-devicons" } }, - { "folke/noice.nvim", requires = { "MunifTanjim/nui.nvim", "rcarriga/nvim-notify" } }, - "freddiehaddad/feline.nvim", - }) - - -- [[[ TELESCOPE ]]] - use({ - "nvim-telescope/telescope.nvim", - requires = { - "nvim-lua/plenary.nvim", - "nvim-telescope/telescope-node-modules.nvim", - "nvim-telescope/telescope-ui-select.nvim", - { "nvim-telescope/telescope-fzf-native.nvim", run = "make" }, - }, - }) - - --[[ TREESITTER ]] - use({ - "nvim-treesitter/nvim-treesitter", - run = ":TSUpdate", - requires = { - "JoosepAlviste/nvim-ts-context-commentstring", - "windwp/nvim-ts-autotag", - "HiPhish/nvim-ts-rainbow2", - "nvim-treesitter/nvim-treesitter-context", - "nvim-treesitter/nvim-treesitter-textobjects", - }, - }) - - -- [[ LSP ]] - use({ - { - "neovim/nvim-lspconfig", - requires = { "SmiteshP/nvim-navic", "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim" }, - }, - "b0o/schemastore.nvim", - "fladson/vim-kitty", - "folke/neodev.nvim", - "jay-babu/mason-null-ls.nvim", - "jose-elias-alvarez/null-ls.nvim", - "jose-elias-alvarez/typescript.nvim", - "jparise/vim-graphql", - "simrat39/symbols-outline.nvim", - { "preservim/vim-markdown", ft = "markdown", dependencies = { "godlygeek/tabular" } }, - { "folke/trouble.nvim", requires = "nvim-tree/nvim-web-devicons" }, - }) - - -- [[ TOOLS ]] - use({ - "akinsho/toggleterm.nvim", - "mbbill/undotree", - { - "ThePrimeagen/refactoring.nvim", - requires = { { "nvim-lua/plenary.nvim" }, { "nvim-treesitter/nvim-treesitter" } }, - }, - }) - - use({ - "junegunn/vim-easy-align", - { "kylechui/nvim-surround", tag = "*" }, - "numToStr/Comment.nvim", - "windwp/nvim-autopairs", - }) - - -- [[ GIT ]] - use({ "kdheepak/lazygit.nvim", "lewis6991/gitsigns.nvim", "tpope/vim-fugitive", "tpope/vim-rhubarb" }) - - -- [[ COMPLETION ]] - use({ - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-cmdline", - "hrsh7th/nvim-cmp", - "ray-x/cmp-treesitter", - { - "L3MON4D3/LuaSnip", - requires = { - "rafamadriz/friendly-snippets", - "saadparwaiz1/cmp_luasnip", - }, - }, - { "petertriho/cmp-git", requires = "nvim-lua/plenary.nvim" }, - }) - - -- [[ COPILOT ]] - use({ "github/copilot.vim", "zbirenbaum/copilot.lua", { "zbirenbaum/copilot-cmp", after = { "copilot.lua" } } }) - - use({ "glacambre/firenvim", run = "FirenvimReload" }) - - use({ "epwalsh/obsidian.nvim", requires = "nvim-lua/plenary.nvim" }) - use({ "jakewvincent/mkdnflow.nvim", rocks = "luautf8" }) - use({ - "lukas-reineke/headlines.nvim", - after = "nvim-treesitter", - config = function() require("headlines").setup() end, - }) - - use({ "iamcco/markdown-preview.nvim", run = function() vim.fn["mkdp#util#install"]() end }) - - if packer_bootstrap then - require("packer").sync() - end -end) diff --git a/lua/user/remap.lua b/lua/user/remap.lua deleted file mode 100644 index 4b1f3337..00000000 --- a/lua/user/remap.lua +++ /dev/null @@ -1,100 +0,0 @@ -local logger = require("utils.logger") -local utils = require("utils") - -local cmd = vim.cmd -local fn = vim.fn -local map = vim.keymap.set - -vim.g.mapleader = "," - -local function escape() utils.feedkeys("", "i", true) end - -utils.map({ "c", "v", "x" }, "jk", escape, { desc = "Escape to normal mode" }) -utils.map({ "n", "v" }, ":", ";", { desc = "Command is remapped to `;`" }) -map({ "n", "v" }, ";", ":", { desc = "Command is remapped to `;`" }) - -local movement_warning = "NO! USE " -utils.nmap("", function() logger.warn({ msg = movement_warning .. "J!" }) end, { desc = "DON'T USE [DOWN]" }) -utils.nmap("", function() logger.warn({ msg = movement_warning .. "H!" }) end, { desc = "DON'T USE [LEFT]" }) -utils.nmap("", function() logger.warn({ msg = movement_warning .. "L!" }) end, { desc = "DON'T USE [RIGHT]" }) -utils.nmap("", function() logger.warn({ msg = movement_warning .. "K!" }) end, { desc = "DON'T USE [Up]" }) - -utils.map("", "", function() cmd.wincmd("h") end, { desc = "Move to Left Window" }) -utils.map("", "", function() cmd.wincmd("j") end, { desc = "Move to Bottom Window" }) -utils.map("", "", function() cmd.wincmd("k") end, { desc = "Move to Upper Window" }) -utils.map("", "", function() cmd.wincmd("l") end, { desc = "Move to Right Window" }) - -utils.nmap( - "", - function() cmd.resize({ args = { "-5" }, mods = { vertical = true } }) end, - { desc = "Decrease current window width" } -) -utils.nmap( - "", - function() cmd.resize({ args = { "+5" }, mods = { vertical = true } }) end, - { desc = "Increase current window width" } -) -utils.nmap("", function() cmd.resize({ args = { "-5" } }) end, { desc = "Decrease current window height" }) -utils.nmap("", function() cmd.resize({ args = { "+5" } }) end, { desc = "Increase current window height" }) - -map( - "n", - "s", - [[:%s/\<\>//I]], - { desc = "[S]earch and replace word under the cursor" } -) -utils.nmap("", function() - utils.feedkeys("") - utils.scroll_center() -end, { desc = "Scroll [u]p and center" }) -utils.nmap("", "", { desc = "I'm sure there is a use for this, but for now it's just annoying" }) -utils.nmap("", function() cmd.bprevious() end, { desc = "Go to the previous buffer" }) -utils.nmap("", function() cmd.bnext() end, { desc = "Go to the next buffer" }) -utils.nmap(",", "``", { desc = "Press `,,` to jump back to the last cursor position." }) -utils.nmap("/", function() - cmd.nohlsearch() - logger.info({ msg = "Highlighting cleared" }) -end, { desc = "Clear search highlighting" }) -utils.nmap("fml", function() cmd.CellularAutomaton("make_it_rain") end, { desc = "make it rain" }) -utils.nmap("rl", function() utils.reload_modules() end, { desc = "[R]eload [m]odules" }) -utils.nmap("x", function() - fn.setfperm(fn.expand("%:p"), "rwxr-xr-x") - logger.info({ msg = string.format("%s made executable", fn.expand("%")), title = "CHMOD!" }) -end, { desc = "Make file e[x]ecutable" }) -utils.nmap("H", "^", { desc = "Move to the start of line" }) -utils.nmap("J", "mzJ`z", { desc = "[J]oin next line to current line" }) -utils.nmap("L", "$", { desc = "Move to the end of line" }) -utils.nmap("N", function() - utils.feedkeys("N") - utils.scroll_center() - utils.feedkeys("zv") -end, { desc = "Go to previous search result and center" }) -utils.nmap("Q", "", { desc = "I'm sure there is a use for this, but for now it's just annoying" }) -utils.nmap("U", function() cmd.redo() end, { desc = "Better redo" }) -utils.nmap("Y", "y$", { desc = "[Y]ank to the end of the line" }) -utils.nmap("n", function() - utils.feedkeys("n") - utils.scroll_center() - utils.feedkeys("zv") -end, { desc = "Go to [n]ext search result and center" }) - -map({ "n", "v" }, "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, desc = "Move to next visual line" }) -map({ "n", "v" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, desc = "Move to previous visual line" }) - -utils.imap("jk", function() - escape() - if vim.bo.buftype == "" then - cmd.update() - end -end, { desc = "Wright and go to normal mode" }) -utils.imap("jj", function() escape() end, { desc = "Go to normal mode" }) - -utils.vmap("J", ":m '>+1gv=gv", { desc = "Move lines down" }) -utils.vmap("K", ":m '<-2gv=gv", { desc = "Move lines up" }) - -utils.nmap("g", function() - local conf = logger.confirm({ msg = "Are you sure you want to quit?", type = "Warning" }) - if conf == 1 then - cmd.quit() - end -end, { desc = "[Q]uit all windows" })