diff --git a/config/nvim/lua/fschauen/plugins/colorizer.lua b/config/nvim/lua/fschauen/plugins/colorizer.lua index ca5786d..928b327 100644 --- a/config/nvim/lua/fschauen/plugins/colorizer.lua +++ b/config/nvim/lua/fschauen/plugins/colorizer.lua @@ -1,20 +1,18 @@ -local M = { 'norcalli/nvim-colorizer.lua' } +return { + "norcalli/nvim-colorizer.lua", -M.cond = function(--[[plugin]]_) - return vim.o.termguicolors -end + cond = function(_) + return vim.o.termguicolors + end, -M.event = { - 'BufReadPost', - 'BufNewFile' + event = { "BufNewFile", "BufReadPost" }, + + opts = { + css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB + mode = "foreground", + }, + + config = function(_, opts) + require("colorizer").setup(nil, opts) + end, } - -M.config = function(--[[plugin]]_, --[[opts]]_) - require('colorizer').setup(--[[filetypes]]nil, { - css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB - mode = 'foreground', - }) -end - -return M - diff --git a/config/nvim/lua/fschauen/plugins/colorscheme.lua b/config/nvim/lua/fschauen/plugins/colorscheme.lua index 3812911..66a04f2 100644 --- a/config/nvim/lua/fschauen/plugins/colorscheme.lua +++ b/config/nvim/lua/fschauen/plugins/colorscheme.lua @@ -1,55 +1,47 @@ local colorscheme = function(tbl) - return vim.tbl_deep_extend('keep', tbl, { lazy = false, priority = 1000 }) + return vim.tbl_deep_extend("keep", tbl, { lazy = false, priority = 1000 }) end return { - colorscheme { 'fschauen/gruvbox.nvim', dev = true }, - colorscheme { 'fschauen/solarized.nvim', dev = true }, - - colorscheme { 'catppuccin/nvim', - name = 'catppuccin', + colorscheme { "fschauen/gruvbox.nvim", dev = true }, + colorscheme { "fschauen/solarized.nvim", dev = true }, + colorscheme { + "catppuccin/nvim", + name = "catppuccin", opts = { - flavor = 'mocha', + flavor = "mocha", show_end_of_buffer = true, dim_inactive = { enabled = true }, integrations = { notify = true }, - custom_highlights = function(colors) - local extra_dark = false - return extra_dark - and { - Normal = { bg = colors.crust }, - CursorLine = { bg = colors.mantle }, - } - or {} - end, }, }, - - colorscheme { 'rebelot/kanagawa.nvim', + colorscheme { + "rebelot/kanagawa.nvim", opts = { dimInactive = true, - theme = 'dragon', + theme = "dragon", overrides = function(colors) local palette = colors.palette return { + -- stylua: ignore start Normal = { bg = palette.sumiInk2 }, CursorLine = { bg = palette.sumiInk3 }, LineNr = { bg = palette.sumiInk2 }, CursorLineNr = { bg = palette.sumiInk2 }, SignColumn = { bg = palette.sumiInk2 }, + -- stylua: ignore end } end, }, }, - - colorscheme { 'folke/tokyonight.nvim', + colorscheme { + "folke/tokyonight.nvim", opts = { - style = 'night', + style = "night", dim_inactive = true, on_colors = function(colors) - colors.bg_highlight = '#1d212f' + colors.bg_highlight = "#1d212f" end, }, }, } - diff --git a/config/nvim/lua/fschauen/plugins/comment.lua b/config/nvim/lua/fschauen/plugins/comment.lua index ef55fe4..6bfcdd4 100644 --- a/config/nvim/lua/fschauen/plugins/comment.lua +++ b/config/nvim/lua/fschauen/plugins/comment.lua @@ -1,12 +1,13 @@ -local M = { 'tpope/vim-commentary' } +return { + "tpope/vim-commentary", -M.cmd = 'Commentary' + cmd = "Commentary", -M.keys = { - { 'gc', 'Commentary', mode = { 'n', 'x', 'o' }, desc = 'Comment in/out' }, - { 'gcc', 'CommentaryLine', desc = 'Comment in/out line' }, - { 'gcu', 'CommentaryCommentary', desc = 'Undo comment in/out' }, + keys = { + -- stylua: ignore start + { "gc", "Commentary", mode = {"n", "x", "o"}, desc = "Comment in/out" }, + { "gcc", "CommentaryLine", desc = "Comment in/out line" }, + { "gcu", "CommentaryCommentary", desc = "Undo comment in/out" }, + -- stylua: ignore end + }, } - -return M - diff --git a/config/nvim/lua/fschauen/plugins/completion.lua b/config/nvim/lua/fschauen/plugins/completion.lua index e2b12c2..08ee3e6 100644 --- a/config/nvim/lua/fschauen/plugins/completion.lua +++ b/config/nvim/lua/fschauen/plugins/completion.lua @@ -1,54 +1,45 @@ -local M = { 'hrsh7th/nvim-cmp' } - -M.dependencies = { - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-nvim-lua', - 'hrsh7th/cmp-path', - 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-cmdline', - 'onsails/lspkind-nvim', - - 'L3MON4D3/LuaSnip', - 'saadparwaiz1/cmp_luasnip', -} - -M.event = { - 'CmdlineEnter', - 'InsertEnter', -} +local icons = require("fschauen.util.icons") local make_keymap = function(cmp) local select = { behavior = cmp.SelectBehavior.Select } - local either = function(yes, no) + local if_visible = function(yes, no) return function(fallback) - if cmp.visible() then yes(fallback) else no(fallback) end + if cmp.visible() then + yes(fallback) + else + no(fallback) + end end end -- Mappings that should work in both command line and Insert mode. local common = { - [''] = either(cmp.mapping.select_next_item(select), cmp.mapping.complete()), - [''] = either(cmp.mapping.select_prev_item(select), cmp.mapping.complete()), + -- stylua: ignore start + [""] = if_visible(cmp.mapping.select_next_item(select), cmp.mapping.complete()), + [""] = if_visible(cmp.mapping.select_prev_item(select), cmp.mapping.complete()), - [''] = cmp.mapping.select_next_item(select), - [''] = cmp.mapping.select_prev_item(select), + [""] = cmp.mapping.select_next_item(select), + [""] = cmp.mapping.select_prev_item(select), - [''] = cmp.mapping.scroll_docs( 3), - [''] = cmp.mapping.scroll_docs( 3), - [''] = cmp.mapping.scroll_docs(-3), - [''] = cmp.mapping.scroll_docs(-3), + [""] = cmp.mapping.scroll_docs( 3), + [""] = cmp.mapping.scroll_docs( 3), + [""] = cmp.mapping.scroll_docs(-3), + [""] = cmp.mapping.scroll_docs(-3), - [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm { select = true }, + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm { select = true }, + -- stylua: ignore end } -- I want to start completion on the command line, but not in Insert. local keymap = { - [''] = { - i = either(cmp.mapping.confirm { select = true }, function(fallback) fallback() end), - c = either(cmp.mapping.confirm { select = true }, cmp.mapping.complete()), - } + [""] = { + i = if_visible(cmp.mapping.confirm { select = true }, function(fallback) + fallback() + end), + c = if_visible(cmp.mapping.confirm { select = true }, cmp.mapping.complete()), + }, } -- Turn { lhs = rhs } into { lhs = { i = rhs, c = rhs } }. @@ -59,75 +50,83 @@ local make_keymap = function(cmp) return cmp.mapping.preset.insert(keymap) end -M.config = function(--[[plugin]]_, --[[opts]]_) - local cmp = require 'cmp' - local keymap = make_keymap(cmp) +return { + "hrsh7th/nvim-cmp", - cmp.setup { - mapping = keymap, + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-path", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-cmdline", + "onsails/lspkind-nvim", - enabled = function() - local c = require 'cmp.config.context' - return not c.in_treesitter_capture('comment') and - not c.in_syntax_group('Comment') - end, + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + }, - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) + event = { "CmdlineEnter", "InsertEnter" }, + + config = function() + local cmp = require("cmp") + local keymap = make_keymap(cmp) + + cmp.setup { + mapping = keymap, + + enabled = function() + local ctx = require("cmp.config.context") + return not ctx.in_treesitter_capture("comment") and not ctx.in_syntax_group("Comment") end, - }, - formatting = { - format = require('lspkind').cmp_format { - mode = 'symbol_text', - - menu = { - buffer = 'buf', - nvim_lsp = 'LSP', - nvim_lua = 'lua', - path = '', - }, - - symbol_map = require('fschauen.util.icons').kind, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, }, - }, - sources = cmp.config.sources({ - { name = 'nvim_lua' }, - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - }, { - { name = 'path' }, - { name = 'buffer', keyword_length = 5 }, - }), + formatting = { + format = require("lspkind").cmp_format { + mode = "symbol_text", + symbol_map = icons.kind, + menu = { + buffer = "buf", + nvim_lsp = "LSP", + nvim_lua = "lua", + path = "", + }, + }, + }, - window = { + sources = cmp.config.sources({ + { name = "nvim_lua" }, + { name = "nvim_lsp" }, + { name = "luasnip" }, + }, { + { name = "path" }, + { name = "buffer", keyword_length = 5 }, + }), + + window = { completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), - }, + }, - experimental = { - ghost_text = true, - }, - } + experimental = { ghost_text = true }, + } - cmp.setup.cmdline(':', { - mapping = keymap, - - completion = { - autocomplete = false, - }, - - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }), - }) - - cmp.setup.filetype('TelescopePrompt', { enabled = false }) -end - -return M + cmp.setup.cmdline(":", { + mapping = keymap, + completion = { autocomplete = false }, + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), + }) + cmp.setup.filetype("TelescopePrompt", { + enabled = false, + }) + end, +} diff --git a/config/nvim/lua/fschauen/plugins/dial.lua b/config/nvim/lua/fschauen/plugins/dial.lua index dee0f00..b7cac02 100644 --- a/config/nvim/lua/fschauen/plugins/dial.lua +++ b/config/nvim/lua/fschauen/plugins/dial.lua @@ -1,13 +1,11 @@ -local M = { 'monaqa/dial.nvim' } - ---Create a right hand side for `dial` key maps. ---@param cmd string: name of a function from `dial.map`. ---@param suffix? string: keys to add after `dial`s mapping. ---@return function local dial_cmd = function(cmd, suffix) - suffix = suffix or '' + suffix = suffix or "" return function() - return require('dial.map')[cmd]() .. suffix + return require("dial.map")[cmd]() .. suffix end end @@ -15,41 +13,58 @@ end ---@param elements string[]: the elements to cycle. ---@return table: @see `dial.types.Augend` local cyclic_augend = function(elements) - return require('dial.augend').constant.new { + return require("dial.augend").constant.new { elements = elements, word = true, - cyclic = true + cyclic = true, } end -M.keys = { - { '', dial_cmd('inc_normal'), expr = true, desc = ' Increment' }, - { '', dial_cmd('dec_normal'), expr = true, desc = ' Decrement' }, - - { '', dial_cmd('inc_visual', 'gv'), expr = true, desc = ' Increment', mode = 'v' }, - { '', dial_cmd('dec_visual', 'gv'), expr = true, desc = ' Decrement', mode = 'v' }, - - { 'g', dial_cmd('inc_gvisual', 'gv'), expr = true, desc = ' Increment', mode = 'v' }, - { 'g', dial_cmd('dec_gvisual', 'gv'), expr = true, desc = ' Decrement', mode = 'v' }, +local weekdays = { + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + "Sunday", } -M.config = function( --[[plugin]] _, --[[opts]] _) - local augend = require('dial.augend') - require('dial.config').augends:register_group { - default = { - augend.integer.alias.decimal_int, - augend.integer.alias.hex, - augend.integer.alias.binary, - augend.constant.alias.bool, - augend.semver.alias.semver, - augend.date.alias['%Y-%m-%d'], - augend.date.alias['%d/%m/%Y'], - augend.date.alias['%d.%m.%Y'], - cyclic_augend { 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' }, - cyclic_augend { 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' }, - cyclic_augend { 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su' }, - } - } -end +local weekdays_short = vim.tbl_map(function(s) + return s:sub(1, 3) +end, weekdays) -return M +return { + "monaqa/dial.nvim", + + keys = { + -- stylua: ignore start + { "", dial_cmd("inc_normal"), expr = true, desc = " Increment" }, + { "", dial_cmd("dec_normal"), expr = true, desc = " Decrement" }, + + { "", dial_cmd("inc_visual", "gv"), expr = true, desc = " Increment", mode = "v" }, + { "", dial_cmd("dec_visual", "gv"), expr = true, desc = " Decrement", mode = "v" }, + + { "g", dial_cmd("inc_gvisual", "gv"), expr = true, desc = " Increment", mode = "v" }, + { "g", dial_cmd("dec_gvisual", "gv"), expr = true, desc = " Decrement", mode = "v" }, + -- stylua: ignore end + }, + + config = function() + local augend = require("dial.augend") + require("dial.config").augends:register_group { + default = { + augend.integer.alias.decimal_int, + augend.integer.alias.hex, + augend.integer.alias.binary, + augend.constant.alias.bool, + augend.semver.alias.semver, + augend.date.alias["%Y-%m-%d"], + augend.date.alias["%d/%m/%Y"], + augend.date.alias["%d.%m.%Y"], + cyclic_augend(weekdays), + cyclic_augend(weekdays_short), + }, + } + end, +} diff --git a/config/nvim/lua/fschauen/plugins/dressing.lua b/config/nvim/lua/fschauen/plugins/dressing.lua index 398f457..18af1dd 100644 --- a/config/nvim/lua/fschauen/plugins/dressing.lua +++ b/config/nvim/lua/fschauen/plugins/dressing.lua @@ -1,21 +1,21 @@ -local M = { 'stevearc/dressing.nvim' } +return { + "stevearc/dressing.nvim", -M.lazy = false + -- `vim.ui.select()` and `vim.ui.input()` can be used from the start. + lazy = false, -M.opts = { - input = { - insert_only = false, -- changes to Normal mode - mappings = { - n = { - [''] = 'Close', - }, - i = { - [''] = 'HistoryPrev', - [''] = 'HistoryNext', + opts = { + input = { + insert_only = false, -- changes to Normal mode + mappings = { + n = { + [""] = "Close", + }, + i = { + [""] = "HistoryPrev", + [""] = "HistoryNext", + }, }, }, }, } - -return M - diff --git a/config/nvim/lua/fschauen/plugins/fidget.lua b/config/nvim/lua/fschauen/plugins/fidget.lua index 621e06b..ee9a2d3 100644 --- a/config/nvim/lua/fschauen/plugins/fidget.lua +++ b/config/nvim/lua/fschauen/plugins/fidget.lua @@ -1,33 +1,34 @@ -local M = { 'j-hui/fidget.nvim' } +local icons = require("fschauen.util.icons") -M.branch = 'legacy' +return { + "j-hui/fidget.nvim", -M.event = 'LspAttach' + branch = "legacy", -M.opts = { - text = { - done = require('fschauen.util.icons').ui.Checkmark, - spinner = { - '▱▱▱▱▱▱▱', - '▰▱▱▱▱▱▱', - '▰▰▱▱▱▱▱', - '▰▰▰▱▱▱▱', - '▰▰▰▰▱▱▱', - '▰▰▰▰▰▱▱', - '▰▰▰▰▰▰▱', - '▰▰▰▰▰▰▰', - '▱▰▰▰▰▰▰', - '▱▱▰▰▰▰▰', - '▱▱▱▰▰▰▰', - '▱▱▱▱▰▰▰', - '▱▱▱▱▱▰▰', - '▱▱▱▱▱▱▰', + event = "LspAttach", + + opts = { + text = { + done = icons.ui.Checkmark, + spinner = { + "▱▱▱▱▱▱▱", + "▰▱▱▱▱▱▱", + "▰▰▱▱▱▱▱", + "▰▰▰▱▱▱▱", + "▰▰▰▰▱▱▱", + "▰▰▰▰▰▱▱", + "▰▰▰▰▰▰▱", + "▰▰▰▰▰▰▰", + "▱▰▰▰▰▰▰", + "▱▱▰▰▰▰▰", + "▱▱▱▰▰▰▰", + "▱▱▱▱▰▰▰", + "▱▱▱▱▱▰▰", + "▱▱▱▱▱▱▰", + }, }, + timer = { spinner_rate = 75 }, + window = { blend = 50 }, + fmt = { max_messages = 10 }, }, - timer = { spinner_rate = 75 }, - window = { blend = 50 }, - fmt = { max_messages = 10 } } - -return M - diff --git a/config/nvim/lua/fschauen/plugins/formatter.lua b/config/nvim/lua/fschauen/plugins/formatter.lua index dc13971..8bb252f 100644 --- a/config/nvim/lua/fschauen/plugins/formatter.lua +++ b/config/nvim/lua/fschauen/plugins/formatter.lua @@ -1,33 +1,37 @@ -local M = { 'mhartington/formatter.nvim' } +return { + "mhartington/formatter.nvim", -M.cmd = { - 'Format', - 'FormatLock', - 'FormatWrite', - 'FormatWriteLock', + cmd = { + "Format", + "FormatLock", + "FormatWrite", + "FormatWriteLock", + }, + + keys = { + -- stylua: ignore start + { "F", "Format", desc = "󰉼 Format file" }, + { "F", "'<,'>Format", mode = "v", desc = "󰉼 Format file" }, + -- stylua: ignore end + }, + + opts = function(_, opts) + local ft = require("formatter.filetypes") + return vim.tbl_deep_extend("force", opts or {}, { + filetype = { + -- stylua: ignore start + c = {ft.c.clangformat}, + cmake = {ft.cmake.cmakeformat}, + cpp = {ft.cpp.clangformat}, + cs = {ft.cs.clangformat}, + json = {ft.cs.prettier}, + lua = {ft.lua.stylua}, + markdown = {ft.markdown.prettier}, + python = {}, -- TODO: pick one + sh = {ft.sh.shfmt}, + zsh = {ft.zsh.beautysh}, + -- stylua: ignore end + }, + }) + end, } - -M.keys = { - { 'F', 'Format', desc = '󰉼 Format file' }, - { 'F', "'<,'>Format", mode = 'v', desc = '󰉼 Format file' }, -} - -M.opts = function( --[[plugin]] _, opts) - local ft = require('formatter.filetypes') - return vim.tbl_deep_extend('force', opts or {}, { - filetype = { - c = { ft.c.clangformat }, - cmake = { ft.cmake.cmakeformat }, - cpp = { ft.cpp.clangformat }, - cs = { ft.cs.clangformat }, - json = { ft.cs.prettier }, - lua = { ft.lua.stylua }, - markdown = { ft.markdown.prettier }, - python = {}, -- TODO: pick one - sh = { ft.sh.shfmt }, - zsh = { ft.zsh.beautysh }, - } - }) -end - -return M diff --git a/config/nvim/lua/fschauen/plugins/fugitive.lua b/config/nvim/lua/fschauen/plugins/fugitive.lua index 5cfb59b..fca2609 100644 --- a/config/nvim/lua/fschauen/plugins/fugitive.lua +++ b/config/nvim/lua/fschauen/plugins/fugitive.lua @@ -1,11 +1,12 @@ -local M = { 'tpope/vim-fugitive' } +return { + "tpope/vim-fugitive", -M.cmd = { 'G', 'Git' } + cmd = { "G", "Git" }, -M.keys = { - { 'gS', 'tab Git', desc = ' [S]status with fugitive' }, - { 'gb', 'Git blame', desc = ' [b]lame' } + keys = { + -- stylua: ignore start + { "gS", "tab Git", desc = " [S]status with fugitive" }, + { "gb", "Git blame", desc = " [b]lame" }, + -- stylua: ignore end + }, } - -return M - diff --git a/config/nvim/lua/fschauen/plugins/git-messenger.lua b/config/nvim/lua/fschauen/plugins/git-messenger.lua index ca58ef6..589bcd4 100644 --- a/config/nvim/lua/fschauen/plugins/git-messenger.lua +++ b/config/nvim/lua/fschauen/plugins/git-messenger.lua @@ -1,27 +1,30 @@ -local M = { 'rhysd/git-messenger.vim' } +return { + "rhysd/git-messenger.vim", -M.cmd = 'GitMessenger' + cmd = "GitMessenger", -M.keys = { - { 'gm', 'GitMessenger', desc = ' open [m]essenger' }, + keys = { + -- stylua: ignore start + { "gm", "GitMessenger", desc = " open [m]essenger" }, + -- stylua: ignore end + }, + + init = function() + -- Disable default mappings, as I have my own for lazy-loading. + vim.g.git_messenger_no_default_mappings = true + + -- Always move cursor into pop-up window immediately. + vim.g.git_messenger_always_into_popup = true + + -- Add a border to the floating window, otherwise it's confusing. + vim.g.git_messenger_floating_win_opts = { + border = "rounded", + } + + -- Make the UI a bit more compact by removing margins. + vim.g.git_messenger_popup_content_margins = false + + -- Extra arguments passed to `git blame`: + -- vim.g.git_messenger_extra_blame_args = '-w' + end, } - -M.init = function(--[[plugin]]_) - -- Disable default mappings, as I have my own for lazy-loading. - vim.g.git_messenger_no_default_mappings = true - - -- Always move cursor into pop-up window immediately. - vim.g.git_messenger_always_into_popup = true - - -- Add a border to the floating window, otherwise it's confusing. - vim.g.git_messenger_floating_win_opts = { border = 'rounded' } - - -- Make the UI a bit more compact by removing margins. - vim.g.git_messenger_popup_content_margins = false - - -- Extra arguments passed to `git blame`: - -- vim.g.git_messenger_extra_blame_args = '-w' -end - -return M - diff --git a/config/nvim/lua/fschauen/plugins/gitlinker.lua b/config/nvim/lua/fschauen/plugins/gitlinker.lua index 8f956e5..1301c26 100644 --- a/config/nvim/lua/fschauen/plugins/gitlinker.lua +++ b/config/nvim/lua/fschauen/plugins/gitlinker.lua @@ -1,39 +1,46 @@ -local M = { 'ruifm/gitlinker.nvim' } - -M.dependencies = { 'nvim-lua/plenary.nvim' } - local open_repo = function() - require('gitlinker').get_repo_url { action_callback = require('gitlinker.actions').open_in_browser } + require("gitlinker").get_repo_url { + action_callback = require("gitlinker.actions").open_in_browser, + } end local browser = function(mode) return function() - require('gitlinker').get_buf_range_url(mode, { action_callback = require('gitlinker.actions').open_in_browser }) + require("gitlinker").get_buf_range_url(mode, { + action_callback = require("gitlinker.actions").open_in_browser, + }) end end local clipboard = function(mode) return function() - require('gitlinker').get_buf_range_url(mode, { action_callback = require('gitlinker.actions').copy_to_clipboard }) + require("gitlinker").get_buf_range_url(mode, { + action_callback = require("gitlinker.actions").copy_to_clipboard, + }) end end -M.keys = { - { 'gr', open_repo, desc = ' open [r]epository in browser' }, - { 'gl', clipboard('n'), desc = ' copy perma[l]ink to clipboard' }, - { 'gl', clipboard('v'), desc = ' copy perma[l]ink to clipboard', mode = 'v' }, - { 'gL', browser('n'), desc = ' open perma[L]ink in browser' }, - { 'gL', browser('v'), desc = ' open perma[L]ink in browser', mode = 'v' }, +return { + "ruifm/gitlinker.nvim", + + dependencies = "nvim-lua/plenary.nvim", + + keys = { + -- stylua: ignore start + { "gr", open_repo, desc = " open [r]epository in browser" }, + { "gl", clipboard("n"), desc = " copy perma[l]ink to clipboard" }, + { "gl", clipboard("v"), desc = " copy perma[l]ink to clipboard", mode = "v" }, + { "gL", browser("n"), desc = " open perma[L]ink in browser" }, + { "gL", browser("v"), desc = " open perma[L]ink in browser", mode = "v" }, + -- stylua: ignore end + }, + + opts = function(_, opts) + return vim.tbl_deep_extend("force", opts or {}, { + mappings = nil, -- I'm defining my own mappings above. + callbacks = { + ["git.schauenburg.me"] = require("gitlinker.hosts").get_gitea_type_url, + }, + }) + end, } - -M.opts = function(--[[plugin]]_, opts) - return vim.tbl_deep_extend('force', opts or {}, { - mappings = nil, -- I'm defining my own mappings above. - callbacks = { - ['git.schauenburg.me'] = require('gitlinker.hosts').get_gitea_type_url, - }, - }) -end - -return M - diff --git a/config/nvim/lua/fschauen/plugins/indent-blankline.lua b/config/nvim/lua/fschauen/plugins/indent-blankline.lua index 2729c1a..ce6968d 100644 --- a/config/nvim/lua/fschauen/plugins/indent-blankline.lua +++ b/config/nvim/lua/fschauen/plugins/indent-blankline.lua @@ -1,37 +1,36 @@ -local M = { 'lukas-reineke/indent-blankline.nvim' } +local icons = require("fschauen.util.icons") -M.cmd = { - 'IBLEnable', - 'IBLDisable', - 'IBLToggle', - 'IBLEnableScope', - 'IBLDisableScope', - 'IBLToggleScope', -} +return { + "lukas-reineke/indent-blankline.nvim", -local toggle = require('fschauen.util.icons').ui.Toggle .. ' toggle ' + cmd = { + "IBLEnable", + "IBLDisable", + "IBLToggle", + "IBLEnableScope", + "IBLDisableScope", + "IBLToggleScope", + }, -M.keys = { - { 'si', 'IBLToggle', desc = toggle .. 'indent lines' }, - { 'so', 'IBLToggleScope', desc = toggle .. 'indent line scope' }, -} + keys = { + -- stylua: ignore start + { "si", "IBLToggle", desc = icons.ui.Toggle .. " toggle indent lines" }, + { "so", "IBLToggleScope", desc = icons.ui.Toggle .. " toggle indent line scope" }, + -- stylua: ignore end + }, -M.main = 'ibl' + main = "ibl", -M.opts = function(--[[plugin]]_, opts) - local icons = require('fschauen.util.icons') - return vim.tbl_deep_extend('force', opts or {}, { - enabled = false, - indent = { - char = icons.ui.LineLeft, - }, - scope = { - char = icons.ui.LineLeftBold, + opts = function(_, opts) + return vim.tbl_deep_extend("force", opts or {}, { enabled = false, - show_start = false, - show_end = false, - }, - }) -end - -return M + indent = { char = icons.ui.LineLeft }, + scope = { + char = icons.ui.LineLeftBold, + enabled = false, + show_start = false, + show_end = false, + }, + }) + end, +} diff --git a/config/nvim/lua/fschauen/plugins/lsp.lua b/config/nvim/lua/fschauen/plugins/lsp.lua index 8b10706..c81eebb 100644 --- a/config/nvim/lua/fschauen/plugins/lsp.lua +++ b/config/nvim/lua/fschauen/plugins/lsp.lua @@ -1,109 +1,130 @@ -local M = { 'neovim/nvim-lspconfig' } +local border = { border = "rounded" } -M.dependencies = { - 'williamboman/mason.nvim', - 'williamboman/mason-lspconfig.nvim', - 'Hoffs/omnisharp-extended-lsp.nvim', -} +local lsp_capabilities = function() + local basic = vim.lsp.protocol.make_client_capabilities() + local completion = vim.F.npcall(require, "cmp_nvim_lsp") + if completion then + return vim.tbl_deep_extend("force", basic, completion.default_capabilities()) + end + return basic +end -M.event = { 'BufReadPre', 'BufNewFile' } - -M.config = function( --[[plugin]] _, --[[opts]] _) - local border = { border = 'rounded' } - - local defaults = { - capabilities = vim.tbl_deep_extend('force', - vim.lsp.protocol.make_client_capabilities(), - vim.F.npcall(function() require('cmp_nvim_lsp').default_capabilities() end) or {}), - - handlers = { - ['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, border), - ['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, border), - }, - - on_attach = function( --[[client]] _, buffer) - local map = vim.keymap.set - local buf = vim.lsp.buf - local map_opts = { buffer = buffer } - map('n', 'c', buf.code_action, map_opts) - map('n', 'f', buf.format, map_opts) - map('n', 'gd', buf.definition, map_opts) - map('n', 'gD', buf.declaration, map_opts) - map('n', 'gi', buf.implementation, map_opts) - map('n', 'grr', buf.rename, map_opts) - map('n', 'gt', buf.type_definition, map_opts) - map('n', 'K', buf.hover, map_opts) - map('i', '', buf.signature_help, map_opts) - end, - - on_init = function(client, --[[init_result]] _) - -- Opt out of semantic highlighting because it has been causing the issues - -- https://github.com/neovim/nvim-lspconfig/issues/2542#issuecomment-1547019213 - if client.server_capabilities then - client.server_capabilities.semanticTokensProvider = false - end - end, - } - - local server_opts = setmetatable({ - lua_ls = function(opts) - return vim.tbl_deep_extend('force', opts, { - settings = { - Lua = { - -- I'm using lua only inside neovim, so the runtime is LuaJIT. - runtime = { version = 'LuaJIT' }, - - -- Get the language server to recognize the `vim` global. - diagnostics = { globals = { 'vim' } }, - - -- Make the server aware of Neovim runtime files. - workspace = { library = vim.api.nvim_get_runtime_file('', true) }, - - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { enable = false }, - }, - }, - }) - end, - omnisharp = function(opts) - return vim.tbl_deep_extend('force', opts, { - -- Use .editoconfig for code style, naming convention and analyzer settings. - enable_editorconfig_support = true, - - -- Show unimported types and add`using` directives. - enable_import_completion = true, - - -- Enable roslyn analyzers, code fixes, and rulesets. - enable_roslyn_analyzers = true, - - -- Don't include preview versions of the .NET SDK. - sdk_include_prereleases = false, - - handlers = { ['textDocument/definition'] = require('omnisharp_extended').handler }, - }) - end, - }, { - __index = function( --[[tbl]] _, --[[key]] _) - return function(opts) return opts end - end - }) - - require('lspconfig.ui.windows').default_options = border - require('mason').setup { ui = border } - require('mason-lspconfig').setup { - ensure_installed = { - 'clangd', - 'cmake', - 'lua_ls', - 'pyright', - }, - handlers = { - function(server_name) - local opts = server_opts[server_name](defaults) - require('lspconfig')[server_name].setup(opts) - end, - }, +local lsp_handlers = function() + return { + ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, border), + ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, border), } end -return M +local lsp_on_attach = function( --[[client]]_, buffer) + local map = vim.keymap.set + local opts = { buffer = buffer } + local buf = vim.lsp.buf + -- stylua: ignore start + map("n", "c", buf.code_action, opts) + map("n", "f", buf.format, opts) + map("n", "gd", buf.definition, opts) + map("n", "gD", buf.declaration, opts) + map("n", "gi", buf.implementation, opts) + map("n", "grr", buf.rename, opts) + map("n", "gt", buf.type_definition, opts) + map("n", "K", buf.hover, opts) + map("i", "", buf.signature_help, opts) + -- stylua: ignore end +end + +local lsp_on_init = function(client) + -- Opt out of semantic highlighting because it has been causing the issues + -- https://github.com/neovim/nvim-lspconfig/issues/2542#issuecomment-1547019213 + if client.server_capabilities then + client.server_capabilities.semanticTokensProvider = false + end +end + +local server_opts = setmetatable({ + lua_ls = function(opts) + return vim.tbl_deep_extend("force", opts, { + settings = { + Lua = { + -- I'm using lua only inside neovim, so the runtime is LuaJIT. + runtime = { version = "LuaJIT" }, + + -- Get the language server to recognize the `vim` global. + diagnostics = { globals = { "vim" } }, + + -- Make the server aware of Neovim runtime files. + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + }, + + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { enable = false }, + }, + }, + }) + end, + omnisharp = function(opts) + return vim.tbl_deep_extend("force", opts, { + -- Use .editoconfig for code style, naming convention and analyzer settings. + enable_editorconfig_support = true, + + -- Show unimported types and add`using` directives. + enable_import_completion = true, + + -- Enable roslyn analyzers, code fixes, and rulesets. + enable_roslyn_analyzers = true, + + -- Don't include preview versions of the .NET SDK. + sdk_include_prereleases = false, + + handlers = { + ["textDocument/definition"] = require("omnisharp_extended").handler, + }, + }) + end, +}, { + -- The default is a just a passthrough of the options. + __index = function() + return function(opts) + return opts + end + end, +}) + +return { + "neovim/nvim-lspconfig", + + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "Hoffs/omnisharp-extended-lsp.nvim", + }, + + event = { "BufReadPre", "BufNewFile" }, + + config = function() + local defaults = { + capabilities = lsp_capabilities(), + handlers = lsp_handlers(), + on_attach = lsp_on_attach, + lsp_on_init = lsp_on_init, + } + + require("lspconfig.ui.windows").default_options = border + require("mason").setup { ui = border } + require("mason-lspconfig").setup { + ensure_installed = { + "clangd", + "cmake", + "lua_ls", + "pyright", + }, + handlers = { + function(server_name) + local opts = server_opts[server_name](defaults) + require("lspconfig")[server_name].setup(opts) + end, + }, + } + end, +} diff --git a/config/nvim/lua/fschauen/plugins/lualine.lua b/config/nvim/lua/fschauen/plugins/lualine.lua index 89ac4b5..f3e7b60 100644 --- a/config/nvim/lua/fschauen/plugins/lualine.lua +++ b/config/nvim/lua/fschauen/plugins/lualine.lua @@ -4,9 +4,7 @@ local icons = require('fschauen.util.icons') local orange = '#d65d0e' local bright = '#ffffff' -- alternative: '#f9f5d7' -M.dependencies = { - 'nvim-tree/nvim-web-devicons', -} +M.dependencies = 'nvim-tree/nvim-web-devicons' M.config = function(--[[plugin]]_, --[[opts]]_) local window = require 'fschauen.window' diff --git a/config/nvim/lua/fschauen/plugins/luaref.lua b/config/nvim/lua/fschauen/plugins/luaref.lua index 8db4a01..4123b01 100644 --- a/config/nvim/lua/fschauen/plugins/luaref.lua +++ b/config/nvim/lua/fschauen/plugins/luaref.lua @@ -1,2 +1 @@ -return { 'milisims/nvim-luaref' } - +return { "milisims/nvim-luaref" } diff --git a/config/nvim/lua/fschauen/plugins/markdown-preview.lua b/config/nvim/lua/fschauen/plugins/markdown-preview.lua index dfabb6f..84f68a9 100644 --- a/config/nvim/lua/fschauen/plugins/markdown-preview.lua +++ b/config/nvim/lua/fschauen/plugins/markdown-preview.lua @@ -1,22 +1,19 @@ -local M = { 'iamcco/markdown-preview.nvim' } +return { + "iamcco/markdown-preview.nvim", -M.build = function() - vim.fn["mkdp#util#install"]() -end + build = function() + vim.fn["mkdp#util#install"]() + end, -M.cmd = { - 'MarkdownPreview', - 'MarkdownPreviewStop', - 'MarkdownPreviewToggle', + cmd = { + "MarkdownPreview", + "MarkdownPreviewStop", + "MarkdownPreviewToggle", + }, + + ft = "markdown", + + init = function() + vim.g.mkdp_theme = "dark" + end, } - -M.ft = { - 'markdown', -} - -M.init = function(--[[plugin]]_) - vim.g.mkdp_theme = 'dark' -end - -return M - diff --git a/config/nvim/lua/fschauen/plugins/neogit.lua b/config/nvim/lua/fschauen/plugins/neogit.lua index ede4adc..ec931a9 100644 --- a/config/nvim/lua/fschauen/plugins/neogit.lua +++ b/config/nvim/lua/fschauen/plugins/neogit.lua @@ -1,30 +1,39 @@ -local M = { 'NeogitOrg/neogit' } +local icons = require("fschauen.util.icons") -M.cmd = 'Neogit' +return { + "NeogitOrg/neogit", -M.dependencies = { 'nvim-lua/plenary.nvim' } + cmd = "Neogit", -M.keys = { - { 'gs', 'Neogit', desc = ' [s]tatus with neogit' }, -} + dependencies = "nvim-lua/plenary.nvim", -M.opts = function(--[[plugin]]_, opts) - local icons = require('fschauen.util.icons') - return vim.tbl_deep_extend('force', opts or {}, { - disable_hint = true, - signs = { - section = { icons.ui.Folder, icons.ui.EmptyFolderOpen }, - item = { icons.ui.ChevronRight, icons.ui.ChevronDown }, - hunk = { icons.ui.ChevronSmallRight, icons.ui.ChevronSmallDown }, - }, - mappings = { - status = { - o = 'GoToFile', - ['='] = 'Toggle', + keys = { + { "gs", "Neogit", desc = " [s]tatus with neogit" }, + }, + + opts = function(_, opts) + return vim.tbl_deep_extend("force", opts or {}, { + disable_hint = true, + signs = { + section = { + icons.ui.Folder, + icons.ui.EmptyFolderOpen, + }, + item = { + icons.ui.ChevronRight, + icons.ui.ChevronDown, + }, + hunk = { + icons.ui.ChevronSmallRight, + icons.ui.ChevronSmallDown, + }, }, - }, - }) -end - -return M - + mappings = { + status = { + o = "GoToFile", + ["="] = "Toggle", + }, + }, + }) + end, +} diff --git a/config/nvim/lua/fschauen/plugins/nerdy.lua b/config/nvim/lua/fschauen/plugins/nerdy.lua index 318a750..4ac1c77 100644 --- a/config/nvim/lua/fschauen/plugins/nerdy.lua +++ b/config/nvim/lua/fschauen/plugins/nerdy.lua @@ -1,18 +1,17 @@ -local M = { '2kabhishek/nerdy.nvim' } +local helper = require("fschauen.plugins.telescope").keymap_helper +local lhs, desc = helper.lhs, helper.description -M.cmd = 'Nerdy' +return { + "2kabhishek/nerdy.nvim", -M.dependencies = { - 'stevearc/dressing.nvim', - 'nvim-telescope/telescope.nvim', + cmd = "Nerdy", + + dependencies = { + "stevearc/dressing.nvim", + "nvim-telescope/telescope.nvim", + }, + + keys = { + { lhs("i"), "Nerdy", desc = desc("Nerd [i]cons") }, + }, } - -local ts = require('fschauen.plugins.telescope') -local lhs, desc = ts.keymap.lhs, ts.keymap.description - -M.keys = { - { lhs('i'), 'Nerdy', desc = desc('Nerd [i]cons') }, -} - -return M - diff --git a/config/nvim/lua/fschauen/plugins/nvim-notify.lua b/config/nvim/lua/fschauen/plugins/nvim-notify.lua index 6fcc8d9..e7065cd 100644 --- a/config/nvim/lua/fschauen/plugins/nvim-notify.lua +++ b/config/nvim/lua/fschauen/plugins/nvim-notify.lua @@ -1,53 +1,61 @@ -local M = { 'rcarriga/nvim-notify' } +local helper = require("fschauen.plugins.telescope").keymap_helper +local lhs, desc = helper.lhs, helper.description -local telescope_notify = function() - local ts = vim.F.npcall(require, 'telescope') - if not ts then return end +local telescope_notifications = function() + local telescope = vim.F.npcall(require, "telescope") + if not telescope then + vim.notify("Telescope is not installed!", vim.log.levels.WARN) + return + end - local theme = require('telescope.themes').get_dropdown { - results_title = ' Results ', - prompt_title = '  Notifications ', + local theme = require("telescope.themes").get_dropdown { + results_title = " Results ", + prompt_title = "  Notifications ", } - - local notify = ts.extensions.notify or ts.load_extension('notify') - notify.notify(theme) + telescope.load_extension("notify").notify(theme) end -local ts = require('fschauen.plugins.telescope') -local lhs, desc = ts.keymap.lhs, ts.keymap.description +local dismiss_notifications = function() + require("notify").dismiss() +end -M.keys = { - { 'n', 'Notifications', desc = 'Display notification history' }, - { '', function() require('notify').dismiss() end, desc = 'Dismiss notifications' }, - { lhs('n'), telescope_notify, desc = desc('[n]otifications') }, +return { + "rcarriga/nvim-notify", + + keys = { + -- stylua: ignore start + { "n", "Notifications", desc = "Display notification history" }, + { "", dismiss_notifications, desc = "Dismiss notifications" }, + { lhs("n"), telescope_notifications, desc = desc("[n]otifications") }, + -- stylua: ignore end + }, + + lazy = false, + + opts = function(_, opts) + local icons = require("fschauen.util.icons") + return vim.tbl_deep_extend("force", opts or {}, { + icons = { + ERROR = icons.diagnostics_bold.Error, + WARN = icons.diagnostics_bold.Warn, + INFO = icons.diagnostics.Info, + DEBUG = icons.diagnostics.Debug, + TRACE = icons.diagnostics.Trace, + }, + fps = 24, + max_width = 50, + minimum_width = 50, + render = "wrapped-compact", + stages = "fade", + time_formats = { + notification_history = "%F %T │ ", + }, + }) + end, + + config = function(_, opts) + local notify = require("notify") + notify.setup(opts) + vim.notify = notify + end, } - -M.lazy = false - -M.opts = function(--[[plugin]]_, opts) - local icons = require('fschauen.util.icons') - return vim.tbl_deep_extend('force', opts or {}, { - icons = { - ERROR = icons.diagnostics_bold.Error, - WARN = icons.diagnostics_bold.Warn, - INFO = icons.diagnostics.Info, - DEBUG = icons.diagnostics.Debug, - TRACE = icons.diagnostics.Trace, - }, - fps = 24, - max_width = 50, - minimum_width = 50, - render = 'wrapped-compact', - stages = 'fade', - time_formats = { notification_history = '%F %T │ ' }, - }) -end - -M.config = function(--[[plugin]]_, opts) - local notify = require('notify') - notify.setup(opts) - vim.notify = notify -end - -return M - diff --git a/config/nvim/lua/fschauen/plugins/nvim-tree.lua b/config/nvim/lua/fschauen/plugins/nvim-tree.lua index f9201b2..524a3d4 100644 --- a/config/nvim/lua/fschauen/plugins/nvim-tree.lua +++ b/config/nvim/lua/fschauen/plugins/nvim-tree.lua @@ -1,84 +1,91 @@ -local M = { 'nvim-tree/nvim-tree.lua' } +local on_attach = function(buffer) + local api = require("nvim-tree.api") -M.dependencies = { - 'nvim-tree/nvim-web-devicons', -} + -- Give me the default mappings except , which I replace with . + api.config.mappings.default_on_attach(buffer) + vim.keymap.del("n", "", { buffer = buffer }) -M.keys = { - { 'tt', 'NvimTreeToggle', desc = '󰙅 [t]oggle [t]ree' }, - { 'tf', 'NvimTreeFindFile', desc = '󰙅 Open [t]ree to current [f]ile ' }, -} + local map = vim.keymap.set + local opts = function(desc) + return { + desc = "󰙅 nvim-tree: " .. desc, + buffer = buffer, + silent = true, + } + end -M.opts = function(--[[plugin]]_, opts) - local icons = require('fschauen.util.icons') - return vim.tbl_deep_extend('force', opts or {}, { - disable_netrw = true, -- replace netrw with nvim-tree - hijack_cursor = true, -- keep the cursor on begin of the filename - sync_root_with_cwd = true, -- watch for `DirChanged` and refresh the tree + -- stylua: ignore start + map("n", "l", api.node.open.edit, opts("Open")) + map("n", "", api.node.open.edit, opts("Open")) + map("n", "", api.node.open.horizontal, opts("Open: Horizontal Split")) + map("n", "h", api.node.navigate.parent_close, opts("Close directory")) + -- stylua: ignore end +end - on_attach = function(buffer) - local api = require('nvim-tree.api') +return { + "nvim-tree/nvim-tree.lua", - -- Give me the default mappings except , which I replace with . - api.config.mappings.default_on_attach(buffer) - vim.keymap.del('n', '', { buffer = buffer }) + dependencies = "nvim-tree/nvim-web-devicons", - local opt = function(desc) - return { desc = '󰙅 nvim-tree: ' .. desc, buffer = buffer, silent = true } - end - vim.keymap.set('n', 'l', api.node.open.edit, opt('Open')) - vim.keymap.set('n', '', api.node.open.edit, opt('Open')) - vim.keymap.set('n', '', api.node.open.horizontal, opt('Open: Horizontal Split')) - vim.keymap.set('n', 'h', api.node.navigate.parent_close, opt('Close directory')) - end, + keys = { + -- stylua: ignore start + { "tt", "NvimTreeToggle", desc = "󰙅 [t]oggle [t]ree" }, + { "tf", "NvimTreeFindFile", desc = "󰙅 Open [t]ree to current [f]ile " }, + -- stylua: ignore end + }, - git = { - ignore = false, -- don't hide files from .gitignore - show_on_open_dirs = false, -- don't show indication if dir is open - }, - view = { - adaptive_size = true, -- resize the window based on the longest line - cursorline = false, -- don't enable 'cursorline' in the tree - width = 35, -- a little wider than the default 30 - }, - filters = { - dotfiles = false, -- show files starting with a . - custom = { '^\\.git' }, -- don't show .git directory - }, - renderer = { - add_trailing = true, -- add trailing / to folders - highlight_git = true, -- enable highlight based on git attributes - icons = { - webdev_colors = false, -- highlight icons with NvimTreeFileIcon - git_placement = 'signcolumn', - glyphs = { - default = icons.ui.File, - symlink = icons.ui.FileSymlink, - modified = icons.ui.Circle, - folder = { - arrow_closed = icons.ui.ChevronSmallRight, - arrow_open = icons.ui.ChevronSmallDown, - default = icons.ui.Folder, - open = icons.ui.FolderOpen, - empty = icons.ui.EmptyFolder, - empty_open = icons.ui.EmptyFolderOpen, - symlink = icons.ui.FolderSymlink, - symlink_open = icons.ui.FolderSymlink, - }, - git = { - untracked = icons.git.file.Untracked, - unstaged = icons.git.file.Unstaged, - staged = icons.git.file.Staged, - deleted = icons.git.file.Deleted, - unmerged = icons.git.file.Unmerged, - renamed = icons.git.file.Renamed, - ignored = icons.git.file.Ignored, + opts = function( --[[plugin]]_, opts) + local icons = require("fschauen.util.icons") + return vim.tbl_deep_extend("force", opts or {}, { + disable_netrw = true, -- replace netrw with nvim-tree + hijack_cursor = true, -- keep the cursor on begin of the filename + sync_root_with_cwd = true, -- watch for `DirChanged` and refresh the tree + on_attach = on_attach, + git = { + ignore = false, -- don't hide files from .gitignore + show_on_open_dirs = false, -- don't show indication if dir is open + }, + view = { + adaptive_size = true, -- resize the window based on the longest line + cursorline = false, -- don't enable 'cursorline' in the tree + width = 35, -- a little wider than the default 30 + }, + filters = { + dotfiles = false, -- show files starting with a . + custom = { "^\\.git" }, -- don't show .git directory + }, + renderer = { + add_trailing = true, -- add trailing / to folders + highlight_git = true, -- enable highlight based on git attributes + icons = { + webdev_colors = false, -- highlight icons with NvimTreeFileIcon + git_placement = "signcolumn", + glyphs = { + default = icons.ui.File, + symlink = icons.ui.FileSymlink, + modified = icons.ui.Circle, + folder = { + arrow_closed = icons.ui.ChevronSmallRight, + arrow_open = icons.ui.ChevronSmallDown, + default = icons.ui.Folder, + open = icons.ui.FolderOpen, + empty = icons.ui.EmptyFolder, + empty_open = icons.ui.EmptyFolderOpen, + symlink = icons.ui.FolderSymlink, + symlink_open = icons.ui.FolderSymlink, + }, + git = { + untracked = icons.git.file.Untracked, + unstaged = icons.git.file.Unstaged, + staged = icons.git.file.Staged, + deleted = icons.git.file.Deleted, + unmerged = icons.git.file.Unmerged, + renamed = icons.git.file.Renamed, + ignored = icons.git.file.Ignored, + }, }, }, }, - }, - }) -end - -return M - + }) + end, +} diff --git a/config/nvim/lua/fschauen/plugins/syntax.lua b/config/nvim/lua/fschauen/plugins/syntax.lua index 3f6d843..1b93dc7 100644 --- a/config/nvim/lua/fschauen/plugins/syntax.lua +++ b/config/nvim/lua/fschauen/plugins/syntax.lua @@ -1,7 +1,5 @@ return { - { 'mityu/vim-applescript', ft = 'applescript' }, - { 'chr4/nginx.vim', ft = 'nginx' }, - { 'keith/swift.vim', ft = 'swift'}, + { "mityu/vim-applescript", ft = "applescript" }, + { "chr4/nginx.vim", ft = "nginx" }, + { "keith/swift.vim", ft = "swift" }, } - - diff --git a/config/nvim/lua/fschauen/plugins/tabular.lua b/config/nvim/lua/fschauen/plugins/tabular.lua index b00a212..0a4284a 100644 --- a/config/nvim/lua/fschauen/plugins/tabular.lua +++ b/config/nvim/lua/fschauen/plugins/tabular.lua @@ -1,18 +1,17 @@ -local M = { 'godlygeek/tabular' } +return { + "godlygeek/tabular", -M.cmd ={ - 'AddTabularPattern', - 'AddTabularPipeline', - 'Tabularize', + cmd = { + "AddTabularPattern", + "AddTabularPipeline", + "Tabularize", + }, + + config = function() + if vim.fn.exists("g:tabular_loaded") == 1 then + vim.cmd([[ AddTabularPattern! first_comma /^[^,]*\zs,/ ]]) + vim.cmd([[ AddTabularPattern! first_colon /^[^:]*\zs:/ ]]) + vim.cmd([[ AddTabularPattern! first_equal /^[^=]*\zs=/ ]]) + end + end, } - -M.config = function(--[[plugin]]_, --[[opts]]_) - if vim.fn.exists('g:tabular_loaded') == 1 then - vim.cmd [[ AddTabularPattern! first_comma /^[^,]*\zs,/ ]] - vim.cmd [[ AddTabularPattern! first_colon /^[^:]*\zs:/ ]] - vim.cmd [[ AddTabularPattern! first_equal /^[^=]*\zs=/ ]] - end -end - -return M - diff --git a/config/nvim/lua/fschauen/plugins/telescope-file-browser.lua b/config/nvim/lua/fschauen/plugins/telescope-file-browser.lua index d717e5a..5029d26 100644 --- a/config/nvim/lua/fschauen/plugins/telescope-file-browser.lua +++ b/config/nvim/lua/fschauen/plugins/telescope-file-browser.lua @@ -1,17 +1,16 @@ -local M = { 'nvim-telescope/telescope-file-browser.nvim' } +local helper = require("fschauen.plugins.telescope").keymap_helper +local lhs, desc = helper.lhs, helper.description -M.dependencies = { 'nvim-telescope/telescope.nvim' } +return { + "nvim-telescope/telescope-file-browser.nvim", -local ts = require('fschauen.plugins.telescope') -local lhs, desc = ts.keymap.lhs, ts.keymap.description + dependencies = "nvim-telescope/telescope.nvim", -M.keys = { - { lhs('B'), 'Telescope file_browser' , desc = desc('file [B]rowser') }, + keys = { + { lhs("B"), "Telescope file_browser", desc = desc("file [B]rowser") }, + }, + + config = function() + require("telescope").load_extension("file_browser") + end, } - -M.config = function(--[[plugin]]_, --[[opts]]_) - require('telescope').load_extension('file_browser') -end - -return M - diff --git a/config/nvim/lua/fschauen/plugins/telescope.lua b/config/nvim/lua/fschauen/plugins/telescope.lua index 39aa3e3..8838b1b 100644 --- a/config/nvim/lua/fschauen/plugins/telescope.lua +++ b/config/nvim/lua/fschauen/plugins/telescope.lua @@ -1,182 +1,183 @@ -local M = { 'nvim-telescope/telescope.nvim' } +local util = require("fschauen.util") +local icons = require("fschauen.util.icons") -M.dependencies = { - 'nvim-telescope/telescope-fzf-native.nvim', - build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release ' .. - '&& cmake --build build --config Release ' .. - '&& cmake --install build --prefix build', -} +---Create the left hand side for a Telescope keymap. +local lhs = function(keys) + return "f" .. keys +end -M.cmd = 'Telescope' +---Create the description for a Telescope keymap. +local desc = function(text) + return icons.ui.Telescope .. " Telescope " .. text +end local builtin_picker = function(name, opts) return function(title) return function() - local picker = require('telescope.builtin')[name] - picker(vim.tbl_extend('force', opts or {}, { prompt_title = title })) + local picker = require("telescope.builtin")[name] + picker(vim.tbl_extend("force", opts or {}, { + prompt_title = title, + })) end end end -local util = require('fschauen.util') -local icons = require('fschauen.util.icons') - local pickers = setmetatable({ - all_files = builtin_picker('find_files', { + all_files = builtin_picker("find_files", { hidden = true, no_ignore = true, no_ignore_parent = true, }), - colorscheme = builtin_picker('colorscheme', { - enable_preview = true, - }), - diagnostics = builtin_picker('diagnostics', { - bufnr = 0 - }), - dotfiles = builtin_picker('find_files', { - cwd = '~/.dotfiles', - hidden = true, - }), + colorscheme = builtin_picker("colorscheme", { enable_preview = true }), + diagnostics = builtin_picker("diagnostics", { bufnr = 0 }), + dotfiles = builtin_picker("find_files", { cwd = "~/.dotfiles", hidden = true }), selection = function(title) return function() local text = util.get_selected_text() - return require('telescope.builtin').grep_string { - prompt_title = string.format(title .. ': %s ', text), + return require("telescope.builtin").grep_string { + prompt_title = string.format(title .. ": %s ", text), search = text, } end end, - here = builtin_picker('current_buffer_fuzzy_find'), + here = builtin_picker("current_buffer_fuzzy_find"), }, { -- Fall back to telescope's built-in pickers if a custom one is not defined -- above, but make sure to keep the title we defined. - __index = function( --[[tbl]] _, key) + __index = function(_, key) return builtin_picker(key) - end + end, }) -M.keymap = { - lhs = function(keys) return 'f' .. keys end, - description = function(text) return icons.ui.Telescope .. ' Telescope ' .. text end +return { + "nvim-telescope/telescope.nvim", + + dependencies = { + "nvim-telescope/telescope-fzf-native.nvim", + build = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release " + .. "&& cmake --build build --config Release " + .. "&& cmake --install build --prefix build", + }, + + cmd = "Telescope", + + keymap_helper = { lhs = lhs, description = desc }, + + keys = { + -- stylua: ignore start + { lhs"a", pickers.autocommands " Autocommands" , desc = desc("[a]utocommands") }, + { lhs"b", pickers.buffers " Buffers" , desc = desc("[b]uffers") }, + --lhs"B" used in telescope-file-browser + { lhs"c", pickers.colorscheme " Colorschemes" , desc = desc("[c]olorschemes") }, + { lhs"C", pickers.commands " Commands" , desc = desc("[C]ommands") }, + { lhs"d", pickers.diagnostics "󰀪 Diagnostics" , desc = desc("[d]iagnostics") }, + --lhs"e" + { lhs"f", pickers.find_files " Files" , desc = desc("[f]ind files") }, + { lhs"F", pickers.all_files " ALL files" , desc = desc("all [F]iles") }, + { lhs"gr", pickers.live_grep " Live grep" , desc = desc("Live [gr]ep") }, + { lhs"gf", pickers.git_files " Git files" , desc = desc("[g]it [f]iles") }, + { lhs"gc", pickers.git_commits " Commits" , desc = desc("[g]it [c]ommits") }, + { lhs"h", pickers.here " Current buffer" , desc = desc("[b]uffer [h]ere") }, + { lhs"H", pickers.highlights "󰌶 Highlights" , desc = desc("[H]ighlights") }, + --lhs"i" used in nerdy + { lhs"j", pickers.jumplist " Jumplist" , desc = desc("[j]umplist") }, + { lhs"k", pickers.keymaps " Keymaps" , desc = desc("[k]eymaps") }, + { lhs"K", pickers.help_tags " Help tags" , desc = desc("[K] help/documentation") }, + { lhs"l", pickers.loclist " Location list" , desc = desc("[l]ocation List") }, + { lhs"m", pickers.man_pages " Man pages" , desc = desc("[m]an pages") }, + --lhs"n" used in vim-notify + { lhs"o", pickers.vim_options " Vim options" , desc = desc("[o]ptions") }, + --lhs"p" + { lhs"q", pickers.quickfix " Quickfix" , desc = desc("[q]uickfix") }, + { lhs"r", pickers.lsp_references " References" , desc = desc("[r]eferences") }, + { lhs"R", pickers.registers "󱓥 Registers" , desc = desc("[R]registers") }, + { lhs"s", pickers.lsp_document_symbols "󰫧 Document Symbols " , desc = desc("LSP document [s]ymbols") }, + { lhs"S", pickers.lsp_workspace_symbols "󱄑 Workspace Symbols " , desc = desc("LSP workspace [S]ymbols") }, + --lhs"t" used in todo_comments + { lhs"T", pickers.treesitter " Treesitter symbols" , desc = desc("[T]reesitter Symbols") }, + --lhs"u" + --lhs"v" + { lhs"w", pickers.selection " Grep" , desc = desc("[w]word under cursor") }, + { lhs"w", pickers.selection " Grep", mode = "v" , desc = desc("[w]ord(s) selected") }, + --lhs"x" + --lhs"y" + { lhs"z", pickers.spell_suggest "󰓆 Spelling suggestions" , desc = desc("[z] spell suggestions") }, + { lhs".", pickers.dotfiles " Dotfiles" , desc = desc("[.]dotfiles") }, + { lhs":", pickers.command_history " Command history" , desc = desc("[:]command history") }, + { lhs"/", pickers.search_history " Search history" , desc = desc("[/]search history") }, + { lhs"", pickers.resume "󰐎 Resume" , desc = desc("Resume ") }, + -- stylua: ignore end + }, + + opts = function(_, opts) + local actions = require("telescope.actions") + local layout = require("telescope.actions.layout") + local trouble = vim.F.npcall(require, "trouble.providers.telescope") or {} + + local mappings = { + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + [""] = actions.preview_scrolling_down, + [""] = actions.preview_scrolling_up, + [""] = layout.cycle_layout_next, + [""] = layout.toggle_mirror, + [""] = layout.toggle_preview, + [""] = actions.select_horizontal, + [""] = false, + [""] = actions.close, + [""] = actions.smart_send_to_qflist + actions.open_qflist, + [""] = actions.smart_send_to_loclist + actions.open_loclist, + [""] = trouble.smart_open_with_trouble, + } + + return vim.tbl_deep_extend("force", opts or {}, { + defaults = { + mappings = { i = mappings, n = mappings }, + + prompt_prefix = " " .. icons.ui.Telescope .. " ", + selection_caret = icons.ui.Play .. " ", + + multi_icon = icons.ui.Checkbox .. " ", + scroll_strategy = "limit", -- Don't wrap around in results. + + dynamic_preview_title = true, + + layout_strategy = "flex", + layout_config = { + width = 0.9, + height = 0.9, + flex = { flip_columns = 180 }, + horizontal = { preview_width = 0.5 }, + vertical = { preview_height = 0.5 }, + }, + cycle_layout_list = { + "horizontal", + "vertical", + }, + }, + pickers = { + buffers = { + mappings = { + n = { x = actions.delete_buffer }, + }, + }, + colorscheme = { theme = "dropdown" }, + spell_suggest = { theme = "cursor" }, + }, + extensions = { + file_browser = { theme = "ivy" }, + }, + }) + end, + + config = function(_, opts) + require("telescope").setup(opts) + require("telescope").load_extension("fzf") + vim.api.nvim_create_autocmd("User", { + desc = "Enable line number in Telescope previewers.", + group = vim.api.nvim_create_augroup("fschauen.telescope", { clear = true }), + pattern = "TelescopePreviewerLoaded", + command = "setlocal number", + }) + end, } -local lhs, desc = M.keymap.lhs, M.keymap.description - -M.keys = { - { lhs'a', pickers.autocommands ' Autocommands' , desc = desc('[a]utocommands') }, - { lhs'b', pickers.buffers ' Buffers' , desc = desc('[b]uffers') }, - --lhs'B' used in telescope-file-browser - { lhs'c', pickers.colorscheme ' Colorschemes' , desc = desc('[c]olorschemes') }, - { lhs'C', pickers.commands ' Commands' , desc = desc('[C]ommands') }, - { lhs'd', pickers.diagnostics '󰀪 Diagnostics' , desc = desc('[d]iagnostics') }, - --lhs'e' - { lhs'f', pickers.find_files ' Files' , desc = desc('[f]ind files') }, - { lhs'F', pickers.all_files ' ALL files' , desc = desc('all [F]iles') }, - { lhs'gr', pickers.live_grep ' Live grep' , desc = desc('Live [gr]ep') }, - { lhs'gf', pickers.git_files ' Git files' , desc = desc('[g]it [f]iles') }, - { lhs'gc', pickers.git_commits ' Commits' , desc = desc('[g]it [c]ommits') }, - { lhs'h', pickers.here ' Current buffer' , desc = desc('[b]uffer [h]ere') }, - { lhs'H', pickers.highlights '󰌶 Highlights' , desc = desc('[H]ighlights') }, - --lhs'i' used in nerdy - { lhs'j', pickers.jumplist ' Jumplist' , desc = desc('[j]umplist') }, - { lhs'k', pickers.keymaps ' Keymaps' , desc = desc('[k]eymaps') }, - { lhs'K', pickers.help_tags ' Help tags' , desc = desc('[K] help/documentation') }, - { lhs'l', pickers.loclist ' Location list' , desc = desc('[l]ocation List') }, - { lhs'm', pickers.man_pages ' Man pages' , desc = desc('[m]an pages') }, - --lhs'n' used in vim-notify - { lhs'o', pickers.vim_options ' Vim options' , desc = desc('[o]ptions') }, - --lhs'p' - { lhs'q', pickers.quickfix ' Quickfix' , desc = desc('[q]uickfix') }, - { lhs'r', pickers.lsp_references ' References' , desc = desc('[r]eferences') }, - { lhs'R', pickers.registers '󱓥 Registers' , desc = desc('[R]registers') }, - { lhs's', pickers.lsp_document_symbols '󰫧 Document Symbols ' , desc = desc('LSP document [s]ymbols') }, - { lhs'S', pickers.lsp_workspace_symbols '󱄑 Workspace Symbols ' , desc = desc('LSP workspace [S]ymbols') }, - --lhs't' used in todo_comments - { lhs'T', pickers.treesitter ' Treesitter symbols' , desc = desc('[T]reesitter Symbols') }, - --lhs'u' - --lhs'v' - { lhs'w', pickers.selection ' Grep' , desc = desc('[w]word under cursor') }, - { lhs'w', pickers.selection ' Grep', mode = 'v' , desc = desc('[w]ord(s) selected') }, - --lhs'x' - --lhs'y' - { lhs'z', pickers.spell_suggest '󰓆 Spelling suggestions' , desc = desc('[z] spell suggestions') }, - { lhs'.', pickers.dotfiles ' Dotfiles' , desc = desc('[.]dotfiles') }, - { lhs':', pickers.command_history ' Command history' , desc = desc('[:]command history') }, - { lhs'/', pickers.search_history ' Search history' , desc = desc('[/]search history') }, - { lhs'', pickers.resume '󰐎 Resume' , desc = desc('Resume ') }, -} - -M.opts = function(--[[plugin]]_, opts) - local actions = require('telescope.actions') - local layout = require('telescope.actions.layout') - local trouble = vim.F.npcall(require, 'trouble.providers.telescope') or {} - - local mappings = { - [''] = actions.cycle_history_next, - [''] = actions.cycle_history_prev, - [''] = actions.preview_scrolling_down, - [''] = actions.preview_scrolling_up, - [''] = layout.cycle_layout_next, - [''] = layout.toggle_mirror, - [''] = layout.toggle_preview, - [''] = actions.select_horizontal, - [''] = false, - [''] = actions.close, - [''] = actions.smart_send_to_qflist + actions.open_qflist, - [''] = actions.smart_send_to_loclist + actions.open_loclist, - [''] = trouble.smart_open_with_trouble, - } - - return vim.tbl_deep_extend('force', opts or {}, { - defaults = { - mappings = { i = mappings, n = mappings }, - - prompt_prefix = ' ' .. icons.ui.Telescope .. ' ', - selection_caret = icons.ui.Play .. ' ', - - multi_icon = icons.ui.Checkbox .. ' ', - scroll_strategy = 'limit', -- Don't wrap around in results. - - dynamic_preview_title = true, - - layout_strategy = 'flex', - layout_config = { - width = 0.9, - height = 0.9, - flex = { flip_columns = 180 }, - horizontal = { preview_width = 0.5 }, - vertical = { preview_height = 0.5 }, - }, - cycle_layout_list = { 'horizontal', 'vertical' }, - }, - pickers = { - buffers = { - mappings = { n = { x = actions.delete_buffer } }, - }, - colorscheme = { - theme = 'dropdown', - }, - spell_suggest = { - theme = 'cursor', - }, - }, - extensions = { - file_browser = { - theme = 'ivy' - }, - }, - }) -end - -M.config = function( --[[plugin]] _, opts) - require('telescope').setup(opts) - require('telescope').load_extension('fzf') - vim.api.nvim_create_autocmd('User', { - desc = 'Enable line number in Telescope previewers.', - group = vim.api.nvim_create_augroup('fschauen.telescope', { clear = true }), - pattern = 'TelescopePreviewerLoaded', - command = 'setlocal number' - }) -end - -return M - diff --git a/config/nvim/lua/fschauen/plugins/text-case.lua b/config/nvim/lua/fschauen/plugins/text-case.lua index 43a86c4..42183b5 100644 --- a/config/nvim/lua/fschauen/plugins/text-case.lua +++ b/config/nvim/lua/fschauen/plugins/text-case.lua @@ -1,8 +1,7 @@ -local M = { 'johmsalas/text-case.nvim' } +return { + "johmsalas/text-case.nvim", -M.event = { 'BufReadPost', 'BufNewFile' } - -M.opts = { prefix = 'c' } - -return M + event = { "BufReadPost", "BufNewFile" }, + opts = { prefix = "c" }, +} diff --git a/config/nvim/lua/fschauen/plugins/todo-comments.lua b/config/nvim/lua/fschauen/plugins/todo-comments.lua index 246157d..eedacdd 100644 --- a/config/nvim/lua/fschauen/plugins/todo-comments.lua +++ b/config/nvim/lua/fschauen/plugins/todo-comments.lua @@ -1,40 +1,39 @@ -local M = { 'folke/todo-comments.nvim' } +local helper = require("fschauen.plugins.telescope").keymap_helper +local lhs, desc = helper.lhs, helper.description -M.dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-telescope/telescope.nvim', +return { + "folke/todo-comments.nvim", + + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope.nvim", + }, + + event = { "BufReadPost", "BufNewFile" }, + + keys = { + { lhs("t"), "TodoTelescope", desc = desc("[t]odos") }, + }, + + opts = function(_, opts) + local icons = require("fschauen.util.icons") + return vim.tbl_deep_extend("force", opts or {}, { + keywords = { + TODO = { icon = icons.ui.Checkbox }, + FIX = { icon = icons.ui.Bug }, + HACK = { icon = icons.ui.Fire }, + WARN = { icon = icons.ui.Warning }, + PERF = { icon = icons.ui.Gauge }, + NOTE = { icon = icons.ui.Note }, + TEST = { icon = icons.ui.TestTube }, + }, + gui_style = { fg = "bold" }, + highlight = { + multiline = false, + before = "fg", + keyword = "wide_fg", + after = "", + }, + }) + end, } - -M.event = { 'BufReadPost', 'BufNewFile' } - -local ts = require('fschauen.plugins.telescope') -local lhs, desc = ts.keymap.lhs, ts.keymap.description - -M.keys = { - { lhs('t'), 'TodoTelescope', desc = desc('[t]odos') }, -} - -M.opts = function(--[[plugin]]_, opts) - local icons = require('fschauen.util.icons') - return vim.tbl_deep_extend('force', opts or {}, { - keywords = { - TODO = { icon = icons.ui.Checkbox }, - FIX = { icon = icons.ui.Bug }, - HACK = { icon = icons.ui.Fire }, - WARN = { icon = icons.ui.Warning }, - PERF = { icon = icons.ui.Gauge }, - NOTE = { icon = icons.ui.Note }, - TEST = { icon = icons.ui.TestTube }, - }, - gui_style = { fg = 'bold' }, - highlight = { - multiline = false, - before = 'fg', - keyword = 'wide_fg', - after = '', - } - }) -end - -return M - diff --git a/config/nvim/lua/fschauen/plugins/treesitter.lua b/config/nvim/lua/fschauen/plugins/treesitter.lua index 6e0c658..6dfb1b5 100644 --- a/config/nvim/lua/fschauen/plugins/treesitter.lua +++ b/config/nvim/lua/fschauen/plugins/treesitter.lua @@ -1,105 +1,96 @@ -local M = { 'nvim-treesitter/nvim-treesitter' } +return { + "nvim-treesitter/nvim-treesitter", -M.build = ':TSUpdate' + build = ":TSUpdate", -M.cmd = { - 'TSInstall', - 'TSUpdate', - 'TSUpdateSync', -} + cmd = { "TSInstall", "TSUpdate", "TSUpdateSync" }, -M.dependencies = { - 'nvim-treesitter/nvim-treesitter-refactor', - 'nvim-treesitter/nvim-treesitter-textobjects', - 'nvim-treesitter/playground', -} + dependencies = { + "nvim-treesitter/nvim-treesitter-refactor", + "nvim-treesitter/nvim-treesitter-textobjects", + "nvim-treesitter/playground", + }, -M.event = 'VeryLazy' + event = "VeryLazy", -M.keys = { - { 'Tp', 'TSPlaygroundToggle', desc = ' [T]reesitter [p]layground (toggle)' }, - { 'Th', 'TSHighlightCapturesUnderCursor', desc = ' [T]reesitter [h]ighlights' }, - { 'Tn', 'TSNodeUnderCursor', desc = ' [T]reesitter [n]ode under cursor' }, -} + keys = { + -- stylua: ignore start + { "Tp", "TSPlaygroundToggle", desc = " [T]reesitter [p]layground (toggle)" }, + { "Th", "TSHighlightCapturesUnderCursor", desc = " [T]reesitter [h]ighlights" }, + { "Tn", "TSNodeUnderCursor", desc = " [T]reesitter [n]ode under cursor" }, + -- stylua: ignore end + }, -M.config = function(--[[plugin]]_, --[[opts]]_) - require('nvim-treesitter.configs').setup { - ensure_installed = { - 'bash', - 'c', - 'cpp', - 'haskell', - 'html', - 'javascript', - 'latex', - 'lua', - 'make', - 'markdown', - 'markdown_inline', - 'python', - 'query', - 'toml', - 'vim', - 'vimdoc', - 'yaml', - }, - highlight = { - enable = true, - disable = { - 'vimdoc', + config = function() + require("nvim-treesitter.configs").setup { + ensure_installed = { + "bash", + "c", + "cpp", + "haskell", + "html", + "javascript", + "latex", + "lua", + "make", + "markdown", + "markdown_inline", + "python", + "query", + "toml", + "vim", + "vimdoc", + "yaml", }, - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = 'gnn', -- mapped in normal mode - node_incremental = '', -- mapped in visual mode - node_decremental = '', -- mapped in visual mode - scope_incremental = nil, -- disabled, normally mapped in visual mode + highlight = { + enable = true, + disable = { "vimdoc" }, }, - }, - refactor = { - highlight_definitions = { enable = true }, - highlight_current_scope = { enable = false }, - smart_rename = { + incremental_selection = { enable = true, keymaps = { - smart_rename = 'grr', + init_selection = "gnn", -- mapped in normal mode + node_incremental = "", -- mapped in visual mode + node_decremental = "", -- mapped in visual mode + scope_incremental = nil, -- disabled, normally mapped in visual mode }, }, - navigation = { - enable = true, - keymaps = { - goto_definition = 'gd', -- default: 'gnd' - list_definitions = nil, -- disabled, default: 'gnD' - list_definitions_toc = 'gO', - goto_next_usage = '', - goto_previous_usage = '', + refactor = { + highlight_definitions = { enable = true }, + highlight_current_scope = { enable = false }, + smart_rename = { + enable = true, + keymaps = { smart_rename = "grr" }, + }, + navigation = { + enable = true, + keymaps = { + goto_definition = "gd", -- default: 'gnd' + list_definitions = nil, -- disabled, default: 'gnD' + list_definitions_toc = "gO", + goto_next_usage = "", + goto_previous_usage = "", + }, }, }, - }, - textobjects = { - select = { - enable = true, - keymaps = { - ['ab'] = '@block.outer', - ['ib'] = '@block.inner', - ['ac'] = '@conditional.outer', - ['ic'] = '@conditional.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['al'] = '@loop.outer', - ['il'] = '@loop.inner', - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', + textobjects = { + select = { + enable = true, + keymaps = { + ["ab"] = "@block.outer", + ["ib"] = "@block.inner", + ["ac"] = "@conditional.outer", + ["ic"] = "@conditional.inner", + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["al"] = "@loop.outer", + ["il"] = "@loop.inner", + ["aa"] = "@parameter.outer", + ["ia"] = "@parameter.inner", + }, }, }, - }, - playground = { - enable = true, - }, - } -end - -return M - + playground = { enable = true }, + } + end, +} diff --git a/config/nvim/lua/fschauen/plugins/trouble.lua b/config/nvim/lua/fschauen/plugins/trouble.lua index 5fd1ad9..1c9fb5b 100644 --- a/config/nvim/lua/fschauen/plugins/trouble.lua +++ b/config/nvim/lua/fschauen/plugins/trouble.lua @@ -1,17 +1,18 @@ -local M = { 'folke/trouble.nvim' } +return { + "folke/trouble.nvim", -M.dependencies = { 'nvim-tree/nvim-web-devicons' } + dependencies = "nvim-tree/nvim-web-devicons", -M.keys = { - { 'lt', 'TroubleToggle', desc = '󱠪 trouble [t]toggle' }, - { 'lw', 'TroubleToggle workspace_diagnostics', desc = '󱠪 trouble [w]orkspace' }, - { 'ld', 'TroubleToggle document_diagnostics', desc = '󱠪 trouble [d]ocument' }, + keys = { + -- stylua: ignore start + { "lt", "TroubleToggle", desc = "󱠪 trouble [t]toggle" }, + { "lw", "TroubleToggle workspace_diagnostics", desc = "󱠪 trouble [w]orkspace" }, + { "ld", "TroubleToggle document_diagnostics", desc = "󱠪 trouble [d]ocument" }, + -- stylua: ignore end + }, + + opts = { + padding = false, -- don't add an extra new line of top of the list + auto_preview = false, -- don't preview automatically + }, } - -M.opts = { - padding = false, -- don't add an extra new line of top of the list - auto_preview = false, -- don't preview automatically -} - -return M - diff --git a/config/nvim/lua/fschauen/plugins/undotree.lua b/config/nvim/lua/fschauen/plugins/undotree.lua index ff2a6f1..5b40bea 100644 --- a/config/nvim/lua/fschauen/plugins/undotree.lua +++ b/config/nvim/lua/fschauen/plugins/undotree.lua @@ -1,18 +1,17 @@ -local M = { 'mbbill/undotree' } +return { + "mbbill/undotree", -M.init = function(--[[plugin]]_) - vim.g.undotree_WindowLayout = 2 -- tree: left, diff: bottom - vim.g.undotree_DiffAutoOpen = 0 -- don't open diff by default - vim.g.undotree_SetFocusWhenToggle = 1 - vim.g.undotree_TreeNodeShape = '' - vim.g.undotree_TreeVertShape = '│' - vim.g.undotree_TreeSplitShape = '╱' - vim.g.undotree_TreeReturnShape = '╲' -end + init = function() + vim.g.undotree_WindowLayout = 2 -- tree: left, diff: bottom + vim.g.undotree_DiffAutoOpen = 0 -- don't open diff by default + vim.g.undotree_SetFocusWhenToggle = 1 + vim.g.undotree_TreeNodeShape = "" + vim.g.undotree_TreeVertShape = "│" + vim.g.undotree_TreeSplitShape = "╱" + vim.g.undotree_TreeReturnShape = "╲" + end, -M.keys = { - { 'u', 'UndotreeToggle' }, + keys = { + { "u", "UndotreeToggle" }, + }, } - -return M - diff --git a/config/nvim/lua/fschauen/plugins/virt-column.lua b/config/nvim/lua/fschauen/plugins/virt-column.lua index 67d8809..f213342 100644 --- a/config/nvim/lua/fschauen/plugins/virt-column.lua +++ b/config/nvim/lua/fschauen/plugins/virt-column.lua @@ -1,26 +1,25 @@ -local M = { 'lukas-reineke/virt-column.nvim' } - -M.event = { 'BufReadPost', 'BufNewFile' } - local toggle_colorcolumn = function() - if vim.o.colorcolumn == '' then - vim.o.colorcolumn = '+1' -- one after 'textwidth' + if vim.o.colorcolumn == "" then + vim.o.colorcolumn = "+1" -- one after 'textwidth' else - vim.o.colorcolumn = '' -- none + vim.o.colorcolumn = "" -- none end end -local toggle = require('fschauen.util.icons').ui.Toggle .. ' toggle ' +local icons = require("fschauen.util.icons") -M.keys = { - { 'sc', toggle_colorcolumn, desc = toggle .. 'virtual colunn' }, +return { + "lukas-reineke/virt-column.nvim", + + event = { "BufReadPost", "BufNewFile" }, + + keys = { + { "sc", toggle_colorcolumn, desc = icons.ui.Toggle .. " toggle virtual colunn" }, + }, + + opts = function(_, opts) + return vim.tbl_deep_extend("force", opts or {}, { + char = icons.ui.LineMiddle, + }) + end, } - -M.opts = function(--[[plugin]]_, opts) - return vim.tbl_deep_extend('force', opts or {}, { - char = require('fschauen.util.icons').ui.LineMiddle, - }) -end - -return M - diff --git a/config/nvim/lua/fschauen/plugins/whitespace.lua b/config/nvim/lua/fschauen/plugins/whitespace.lua index 248ebc4..b139e8f 100644 --- a/config/nvim/lua/fschauen/plugins/whitespace.lua +++ b/config/nvim/lua/fschauen/plugins/whitespace.lua @@ -1,23 +1,22 @@ -local M = { 'ntpeters/vim-better-whitespace' } +return { + "ntpeters/vim-better-whitespace", -M.init = function(--[[plugin]]_) - vim.g.better_whitespace_filetypes_blacklist = { - 'diff', - 'fugitive', - 'git', - 'gitcommit', - 'help', - } -end + event = { "BufReadPost", "BufNewFile" }, -M.event = { 'BufReadPost', 'BufNewFile' } + init = function() + vim.g.better_whitespace_filetypes_blacklist = { + "diff", + "fugitive", + "git", + "gitcommit", + "help", + } + end, -M.keys = { - { 'ww', 'ToggleWhitespace' }, - { 'wj', 'NextTrailingWhitespace' }, - { 'wk', 'PrevTrailingWhitespace' }, - { 'W', 'StripWhitespace' }, + keys = { + { "ww", "ToggleWhitespace" }, + { "wj", "NextTrailingWhitespace" }, + { "wk", "PrevTrailingWhitespace" }, + { "W", "StripWhitespace" }, + }, } - -return M - diff --git a/config/nvim/stylua.toml b/config/nvim/stylua.toml new file mode 100644 index 0000000..254e2da --- /dev/null +++ b/config/nvim/stylua.toml @@ -0,0 +1,7 @@ +column_width = 100 +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferDouble" +call_parentheses = "NoSingleTable" +collapse_simple_statement = "Never" +