From dc5f34260ea19f8dfcedb7092d8681eee0ff0d77 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Tue, 8 Aug 2023 05:04:47 +0200 Subject: [PATCH] vim: lazy load as many plugins as possible --- config/nvim/lua/fschauen/init.lua | 2 + .../nvim/lua/fschauen/plugins/colorizer.lua | 2 + .../nvim/lua/fschauen/plugins/colorscheme.lua | 13 +- config/nvim/lua/fschauen/plugins/comment.lua | 59 ++-- config/nvim/lua/fschauen/plugins/fugitive.lua | 10 +- .../lua/fschauen/plugins/indent-blankline.lua | 2 + config/nvim/lua/fschauen/plugins/init.lua | 2 - config/nvim/lua/fschauen/plugins/neogit.lua | 33 +- config/nvim/lua/fschauen/plugins/nginx.lua | 5 + .../nvim/lua/fschauen/plugins/nvim-tree.lua | 24 +- config/nvim/lua/fschauen/plugins/swift.lua | 6 + .../nvim/lua/fschauen/plugins/telescope.lua | 314 +++++++++--------- .../lua/fschauen/plugins/todo-comments.lua | 18 +- .../nvim/lua/fschauen/plugins/treesitter.lua | 33 +- config/nvim/lua/fschauen/plugins/trouble.lua | 20 +- config/nvim/lua/fschauen/plugins/undotree.lua | 8 +- .../plugins/vim-better-whitespace.lua | 14 +- .../nvim/lua/fschauen/plugins/virt-column.lua | 30 +- 18 files changed, 305 insertions(+), 290 deletions(-) create mode 100644 config/nvim/lua/fschauen/plugins/nginx.lua create mode 100644 config/nvim/lua/fschauen/plugins/swift.lua diff --git a/config/nvim/lua/fschauen/init.lua b/config/nvim/lua/fschauen/init.lua index cf62d03..8627f81 100644 --- a/config/nvim/lua/fschauen/init.lua +++ b/config/nvim/lua/fschauen/init.lua @@ -10,3 +10,5 @@ require 'fschauen.filetypes' require 'fschauen.diagnostics' require 'fschauen.lazy' +vim.cmd [[colorscheme gruvbox]] + diff --git a/config/nvim/lua/fschauen/plugins/colorizer.lua b/config/nvim/lua/fschauen/plugins/colorizer.lua index 725e8f2..f8c5420 100644 --- a/config/nvim/lua/fschauen/plugins/colorizer.lua +++ b/config/nvim/lua/fschauen/plugins/colorizer.lua @@ -3,6 +3,8 @@ return { cond = vim.opt.termguicolors:get(), + event = { 'BufReadPost', 'BufNewFile' }, + config = function() require('colorizer').setup(nil, { mode = 'foreground', diff --git a/config/nvim/lua/fschauen/plugins/colorscheme.lua b/config/nvim/lua/fschauen/plugins/colorscheme.lua index 8a971da..ac61210 100644 --- a/config/nvim/lua/fschauen/plugins/colorscheme.lua +++ b/config/nvim/lua/fschauen/plugins/colorscheme.lua @@ -1,14 +1,5 @@ return { - { - 'fschauen/solarized.nvim', - dev = true, - }, - { - 'fschauen/gruvbox.nvim', - dev = true, - config = function () - vim.cmd [[colorscheme gruvbox]] - end, - }, + { 'fschauen/solarized.nvim', dev = true, lazy =true }, + { 'fschauen/gruvbox.nvim', dev = true, lazy = true }, } diff --git a/config/nvim/lua/fschauen/plugins/comment.lua b/config/nvim/lua/fschauen/plugins/comment.lua index 02d1a32..a9ff118 100644 --- a/config/nvim/lua/fschauen/plugins/comment.lua +++ b/config/nvim/lua/fschauen/plugins/comment.lua @@ -1,39 +1,38 @@ return { 'numToStr/Comment.nvim', - config = function() - require('Comment').setup { - padding = true, -- Add a space between comment and the line - sticky = true, -- Whether the cursor should stay at its position - ignore = nil, -- Lines to be ignored while (un)comment + lazy = false, -- recommended in the README - -- NORMAL mode mappings - toggler = { - line = 'gcc', -- Line-comment toggle keymap - block = 'gbc', -- Block-comment toggle keymap - }, + opts = { + padding = true, -- Add a space between comment and the line + sticky = true, -- Whether the cursor should stay at its position + ignore = nil, -- Lines to be ignored while (un)comment - -- NORMAL and VISUAL mode mappings - opleader = { - line = 'gc', -- Line-comment keymap - block = 'gb', -- Block-comment keymap - }, + -- NORMAL mode mappings + toggler = { + line = 'gcc', -- Line-comment toggle keymap + block = 'gbc', -- Block-comment toggle keymap + }, - extra = { - above = 'gcO', -- Add comment on the line above - below = 'gco', -- Add comment on the line below - eol = 'gcA', -- Add comment at the end of line - }, + -- NORMAL and VISUAL mode mappings + opleader = { + line = 'gc', -- Line-comment keymap + block = 'gb', -- Block-comment keymap + }, - -- Enable keybindings - mappings = { - basic = true, -- Operator-pending mapping; `gcc` `gbc` `gc[count]{motion}` `gb[count]{motion}` - extra = true, -- Extra mapping; `gco`, `gcO`, `gcA` - }, + extra = { + above = 'gcO', -- Add comment on the line above + below = 'gco', -- Add comment on the line below + eol = 'gcA', -- Add comment at the end of line + }, - pre_hook = nil, -- Function to call before (un)comment - post_hook = nil, -- Function to call after (un)comment - } - end + -- Enable keybindings + mappings = { + basic = true, -- Operator-pending mapping; `gcc` `gbc` `gc[count]{motion}` `gb[count]{motion}` + extra = true, -- Extra mapping; `gco`, `gcO`, `gcA` + }, + + pre_hook = nil, -- Function to call before (un)comment + post_hook = nil, -- Function to call after (un)comment + }, } - diff --git a/config/nvim/lua/fschauen/plugins/fugitive.lua b/config/nvim/lua/fschauen/plugins/fugitive.lua index f583eb0..b943779 100644 --- a/config/nvim/lua/fschauen/plugins/fugitive.lua +++ b/config/nvim/lua/fschauen/plugins/fugitive.lua @@ -1,10 +1,10 @@ return { 'tpope/vim-fugitive', - config = function() - vim.keymap.set('n', 'gg', ':Git ') - vim.keymap.set('n', 'gs', 'tab Git') - vim.keymap.set('n', 'gb', 'Git blame') - end, + keys = { + { 'gg', ':Git ' }, + { 'gs', 'tab Git' }, + { 'gb', 'Git blame' } + }, } diff --git a/config/nvim/lua/fschauen/plugins/indent-blankline.lua b/config/nvim/lua/fschauen/plugins/indent-blankline.lua index 9607ba5..9806e97 100644 --- a/config/nvim/lua/fschauen/plugins/indent-blankline.lua +++ b/config/nvim/lua/fschauen/plugins/indent-blankline.lua @@ -1,6 +1,8 @@ return { 'lukas-reineke/indent-blankline.nvim', + lazy = false, -- trows an error when lazy loading + config = function() require('indent_blankline').setup { enabled = false, diff --git a/config/nvim/lua/fschauen/plugins/init.lua b/config/nvim/lua/fschauen/plugins/init.lua index 7b9c46f..d9168d5 100644 --- a/config/nvim/lua/fschauen/plugins/init.lua +++ b/config/nvim/lua/fschauen/plugins/init.lua @@ -1,7 +1,5 @@ return { 'nvim-lua/plenary.nvim', 'milisims/nvim-luaref', - 'keith/swift.vim', - 'chr4/nginx.vim', } diff --git a/config/nvim/lua/fschauen/plugins/neogit.lua b/config/nvim/lua/fschauen/plugins/neogit.lua index c6dc4d5..7268434 100644 --- a/config/nvim/lua/fschauen/plugins/neogit.lua +++ b/config/nvim/lua/fschauen/plugins/neogit.lua @@ -1,23 +1,22 @@ return { 'NeogitOrg/neogit', - config = function() - require('neogit').setup { - disable_hint = true, - signs = { - section = { '', ''}, - item = { '', ''}, - hunk = { '', ''}, + opts = { + disable_hint = true, + signs = { + section = { '', '' }, + item = { '', '' }, + hunk = { '', '' }, + }, + mappings = { + status = { + o = 'GoToFile', + [''] = 'Toggle', }, - mappings = { - status = { - o = 'GoToFile', - [''] = 'Toggle', - }, - }, - } + }, + }, - vim.keymap.set('n', 'gn', 'Neogit') - end, + keys = { + { 'gn', 'Neogit' }, + }, } - diff --git a/config/nvim/lua/fschauen/plugins/nginx.lua b/config/nvim/lua/fschauen/plugins/nginx.lua new file mode 100644 index 0000000..6218ee0 --- /dev/null +++ b/config/nvim/lua/fschauen/plugins/nginx.lua @@ -0,0 +1,5 @@ +return { + 'chr4/nginx.vim', + + ft = 'nginx', +} diff --git a/config/nvim/lua/fschauen/plugins/nvim-tree.lua b/config/nvim/lua/fschauen/plugins/nvim-tree.lua index 4afbd3e..f999d89 100644 --- a/config/nvim/lua/fschauen/plugins/nvim-tree.lua +++ b/config/nvim/lua/fschauen/plugins/nvim-tree.lua @@ -1,5 +1,9 @@ -local config = function() - require('nvim-tree').setup { +return { + 'nvim-tree/nvim-tree.lua', + + dependencies = { 'nvim-tree/nvim-web-devicons' }, + + opts = { 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 @@ -37,16 +41,12 @@ local config = function() group_empty = true, -- folders that contain only one folder are grouped highlight_git = true, -- enable highlight based on git attributes }, - } + }, - vim.keymap.set('n', 'nn', 'NvimTreeOpen') - vim.keymap.set('n', 'nf', 'NvimTreeFindFile') - vim.keymap.set('n', 'nc', 'NvimTreeClose') -end - -return { - 'nvim-tree/nvim-tree.lua', - dependencies = { 'nvim-tree/nvim-web-devicons' }, - config = config, + keys = { + { 'nn', 'NvimTreeOpen' }, + { 'nf', 'NvimTreeFindFile' }, + { 'nc', 'NvimTreeClose' }, + }, } diff --git a/config/nvim/lua/fschauen/plugins/swift.lua b/config/nvim/lua/fschauen/plugins/swift.lua new file mode 100644 index 0000000..537e980 --- /dev/null +++ b/config/nvim/lua/fschauen/plugins/swift.lua @@ -0,0 +1,6 @@ + return { + 'keith/swift.vim', + + ft = 'swift', + } + diff --git a/config/nvim/lua/fschauen/plugins/telescope.lua b/config/nvim/lua/fschauen/plugins/telescope.lua index c7c0925..fe0258a 100644 --- a/config/nvim/lua/fschauen/plugins/telescope.lua +++ b/config/nvim/lua/fschauen/plugins/telescope.lua @@ -1,4 +1,4 @@ -T = { +return { 'nvim-telescope/telescope.nvim', dependencies = { @@ -11,180 +11,176 @@ T = { }, }, - trigger = 'f', -- my addition, not used by lazy.nvim -} + config = function() + local telescope = require 'telescope' + local actions = require 'telescope.actions' + local actions_layout = require 'telescope.actions.layout' -T.config = function() - local telescope = require 'telescope' - local actions = require 'telescope.actions' - local actions_layout = require 'telescope.actions.layout' + local mappings = { + [''] = actions_layout.cycle_layout_next, + [''] = actions_layout.toggle_mirror, + [''] = actions.smart_send_to_qflist + actions.open_qflist, + [''] = actions.smart_send_to_loclist + actions.open_loclist, + [''] = actions.close, - local mappings = { - [''] = actions_layout.cycle_layout_next, - [''] = actions_layout.toggle_mirror, - [''] = actions.smart_send_to_qflist + actions.open_qflist, - [''] = actions.smart_send_to_loclist + actions.open_loclist, - [''] = actions.close, + [''] = actions.preview_scrolling_down, + [''] = actions.preview_scrolling_up, - [''] = actions.preview_scrolling_down, - [''] = actions.preview_scrolling_up, + [''] = actions.cycle_history_next, + [''] = actions.cycle_history_prev, + } - [''] = actions.cycle_history_next, - [''] = actions.cycle_history_prev, - } + local trouble = vim.F.npcall(require, 'trouble.providers.telescope') + if trouble then + mappings[''] = trouble.open_with_trouble + end - local trouble = vim.F.npcall(require, 'trouble.providers.telescope') - if trouble then - mappings[''] = trouble.open_with_trouble - end + telescope.setup { + defaults = { + -- ╭────────╮ + -- │ Keymap │ + -- ╰────────╯ + mappings = { i = mappings, n = mappings }, - telescope.setup { - defaults = { - -- ╭────────╮ - -- │ Keymap │ - -- ╰────────╯ - mappings = { i = mappings, n = mappings }, + -- ╭────────╮ + -- │ Prompt │ + -- ╰────────╯ + prompt_prefix = ' ❯ ', + selection_caret = ' ', -- Other ideas:  ➔  - -- ╭────────╮ - -- │ Prompt │ - -- ╰────────╯ - prompt_prefix = ' ❯ ', - selection_caret = ' ', -- Other ideas:  ➔  + -- ╭─────────╮ + -- │ Results │ + -- ╰─────────╯ + multi_icon = ' ', + scroll_strategy = 'limit', -- Don't wrap around in results. - -- ╭─────────╮ - -- │ Results │ - -- ╰─────────╯ - multi_icon = ' ', - scroll_strategy = 'limit', -- Don't wrap around in results. + -- ╭─────────╮ + -- │ Preview │ + -- ╰─────────╯ + dynamic_preview_title = true, - -- ╭─────────╮ - -- │ Preview │ - -- ╰─────────╯ - dynamic_preview_title = true, - - -- ╭────────╮ - -- │ Layout │ - -- ╰────────╯ - layout_strategy = 'flex', - layout_config = { - width = 0.9, - height = 0.9, - flex = { flip_columns = 130 }, - horizontal = { preview_width = 0.5, preview_cutoff = 130 }, - vertical = { preview_height = 0.5 }, + -- ╭────────╮ + -- │ Layout │ + -- ╰────────╯ + layout_strategy = 'flex', + layout_config = { + width = 0.9, + height = 0.9, + flex = { flip_columns = 130 }, + horizontal = { preview_width = 0.5, preview_cutoff = 130 }, + vertical = { preview_height = 0.5 }, + }, + cycle_layout_list = { 'horizontal', 'vertical' }, }, - cycle_layout_list = { 'horizontal', 'vertical' }, - }, - extensions = { - file_browser = { theme = 'ivy' }, - }, - } + extensions = { + file_browser = { theme = 'ivy' }, + }, + } - local themes = require 'telescope.themes' - local ts = require 'telescope.builtin' - local my = { - all_files = function(opts) - ts.find_files(vim.tbl_extend('keep', opts or {}, { - hidden = true, - no_ignore = true, - no_ignore_parent = true, - })) - end, - colorschemes = function(opts) - ts.colorscheme(themes.get_dropdown(vim.tbl_extend('keep', opts or {}, { - enable_preview = true, - }))) - end, - diagnostics = function(opts) - ts.diagnostics(vim.tbl_extend('keep', opts or {}, { bufnr = 0 })) - end, - dotfiles = function(opts) - ts.find_files(vim.tbl_extend('keep', opts or {}, { - cwd = '~/.dotfiles', - hidden = true, - })) - end, - selection = function(_) - local selected = require('fschauen.util').get_selected_text() - ts.grep_string { - prompt_title = string.format('  Grep: %s ', selected), - search = selected, - } - end, - spell_suggest = function(opts) - ts.spell_suggest(themes.get_cursor(opts)) - end, - here = function(opts) - ts.current_buffer_fuzzy_find(opts) - end, - } + local themes = require 'telescope.themes' + local ts = require 'telescope.builtin' + local my = { + all_files = function(opts) + ts.find_files(vim.tbl_extend('keep', opts or {}, { + hidden = true, + no_ignore = true, + no_ignore_parent = true, + })) + end, + colorschemes = function(opts) + ts.colorscheme(themes.get_dropdown(vim.tbl_extend('keep', opts or {}, { + enable_preview = true, + }))) + end, + diagnostics = function(opts) + ts.diagnostics(vim.tbl_extend('keep', opts or {}, { bufnr = 0 })) + end, + dotfiles = function(opts) + ts.find_files(vim.tbl_extend('keep', opts or {}, { + cwd = '~/.dotfiles', + hidden = true, + })) + end, + selection = function(_) + local selected = require('fschauen.util').get_selected_text() + ts.grep_string { + prompt_title = string.format('  Grep: %s ', selected), + search = selected, + } + end, + spell_suggest = function(opts) + ts.spell_suggest(themes.get_cursor(opts)) + end, + here = function(opts) + ts.current_buffer_fuzzy_find(opts) + end, + } - local map = function(keymap) - for mode, list in pairs(keymap) do - for _, row in ipairs(list) do - local lhs, picker, title, desc = row[1], row[2], row[3], row[4] - local rhs = function() picker { prompt_title = ' ' .. title .. ' ' } end - vim.keymap.set(mode, T.trigger .. lhs, rhs, { desc = ' ' .. desc }) + local map = function(keymap) + for mode, list in pairs(keymap) do + for _, row in ipairs(list) do + local lhs, picker, title, desc = row[1], row[2], row[3], row[4] + local rhs = function() picker { prompt_title = ' ' .. title .. ' ' } end + vim.keymap.set(mode, 'f' .. lhs, rhs, { desc = ' ' .. desc }) + end end end - end - map { - -- ╭────╮ ╭──────╮ ╭────────────╮ ╭───────────────────╮ - -- │keys│ │picker│ │prompt title│ │mapping description│ - -- ╰────╯ ╰──────╯ ╰────────────╯ ╰───────────────────╯ - n = { - { 'a', ts.autocommands , ' Autocommands' , '[a]utocommands' }, - { 'b', ts.buffers , ' Buffers' , '[b]uffers' }, - { 'c', my.colorschemes , ' Colorschemes' , '[c]olorschemes' }, - { 'dd', my.diagnostics , '󰀪 Document Diagnostics' , '[d]iagnostics [d]ocument' }, - { 'dw', ts.diagnostics , '󰀪 Workspace Diagnostics', '[d]iagnostics [w]orkspace' }, - -- e - { 'f', ts.find_files , ' Files' , '[f]ind files' }, - { 'F', my.all_files , ' ALL files' , 'all [F]iles' }, - { 'gr', ts.live_grep , ' Live grep' , 'Live [gr]ep' }, - { 'gf', ts.git_files , ' Git files' , '[g]it [f]iles' }, - { 'gc', ts.git_commits , ' Commits' , '[g]it [c]ommits' }, - { 'h', my.here , ' Current buffer' , '[b]uffer [h]ere' }, - { 'H', ts.highlights , '󰌶 Highlights' , '[H]ighlights' }, - -- i - { 'j', ts.jumplist , ' Jumplist' , '[j]umplist' }, - { 'k', ts.keymaps , ' Keymaps' , '[k]eymaps' }, - { 'K', ts.help_tags , ' Help tags' , '[K] help/documentation' }, - { 'l', ts.loclist , ' Location list' , '[l]ocation List' }, - { 'm', ts.man_pages , ' Man pages' , '[m]an pages' }, - -- n - { 'o', ts.vim_options , ' Vim options' , 'vim [o]ptions' }, - -- p - { 'q', ts.quickfix , ' Quickfix' , '[q]uickfix' }, - { 'r', ts.lsp_references , ' References' , '[r]eferences' }, - { 'R', ts.registers , '󱓥 Registers' , '[R]registers' }, - { 's', ts.lsp_document_symbols , '󰫧 Document Symbols ' , 'lsp document [s]ymbols' }, - { 'S', ts.lsp_workspace_symbols , '󱄑 Workspace Symbols ' , 'lsp workspace [S]ymbols' }, - --'t' used in todo-comments - { 'T', ts.treesitter , ' Treesitter symbols' , '[T]reesitter Symbols' }, - -- u - -- v - { 'w', my.selection , '' --[[dynamic]] , '[w]word under cursor' }, - -- x - -- y - { 'z', my.spell_suggest , '󰓆 Spelling suggestions' , '[z] spell suggestions' }, - { '.', my.dotfiles , ' Dotfiles' , '[.]dotfiles' }, - { ':', ts.command_history , ' Command history' , '[:]command history' }, - { '?', ts.commands , ' Commands' , 'commands [?]' }, - { '/', ts.search_history , ' Search history' , '[/]search history' }, - {'', ts.resume , '󰐎 Resume' , 'Resume' }, - }, - v = { - { 's', my.selection , '' --[[dynamic]] , 'visual [s]election' }, + map { + -- ╭────╮ ╭──────╮ ╭────────────╮ ╭───────────────────╮ + -- │keys│ │picker│ │prompt title│ │mapping description│ + -- ╰────╯ ╰──────╯ ╰────────────╯ ╰───────────────────╯ + n = { + { 'a', ts.autocommands , ' Autocommands' , '[a]utocommands' }, + { 'b', ts.buffers , ' Buffers' , '[b]uffers' }, + { 'c', my.colorschemes , ' Colorschemes' , '[c]olorschemes' }, + { 'dd', my.diagnostics , '󰀪 Document Diagnostics' , '[d]iagnostics [d]ocument' }, + { 'dw', ts.diagnostics , '󰀪 Workspace Diagnostics', '[d]iagnostics [w]orkspace' }, + -- e + { 'f', ts.find_files , ' Files' , '[f]ind files' }, + { 'F', my.all_files , ' ALL files' , 'all [F]iles' }, + { 'gr', ts.live_grep , ' Live grep' , 'Live [gr]ep' }, + { 'gf', ts.git_files , ' Git files' , '[g]it [f]iles' }, + { 'gc', ts.git_commits , ' Commits' , '[g]it [c]ommits' }, + { 'h', my.here , ' Current buffer' , '[b]uffer [h]ere' }, + { 'H', ts.highlights , '󰌶 Highlights' , '[H]ighlights' }, + -- i + { 'j', ts.jumplist , ' Jumplist' , '[j]umplist' }, + { 'k', ts.keymaps , ' Keymaps' , '[k]eymaps' }, + { 'K', ts.help_tags , ' Help tags' , '[K] help/documentation' }, + { 'l', ts.loclist , ' Location list' , '[l]ocation List' }, + { 'm', ts.man_pages , ' Man pages' , '[m]an pages' }, + -- n + { 'o', ts.vim_options , ' Vim options' , 'vim [o]ptions' }, + -- p + { 'q', ts.quickfix , ' Quickfix' , '[q]uickfix' }, + { 'r', ts.lsp_references , ' References' , '[r]eferences' }, + { 'R', ts.registers , '󱓥 Registers' , '[R]registers' }, + { 's', ts.lsp_document_symbols , '󰫧 Document Symbols ' , 'lsp document [s]ymbols' }, + { 'S', ts.lsp_workspace_symbols , '󱄑 Workspace Symbols ' , 'lsp workspace [S]ymbols' }, + --'t' used in todo-comments + { 'T', ts.treesitter , ' Treesitter symbols' , '[T]reesitter Symbols' }, + -- u + -- v + { 'w', my.selection , '' --[[dynamic]] , '[w]word under cursor' }, + -- x + -- y + { 'z', my.spell_suggest , '󰓆 Spelling suggestions' , '[z] spell suggestions' }, + { '.', my.dotfiles , ' Dotfiles' , '[.]dotfiles' }, + { ':', ts.command_history , ' Command history' , '[:]command history' }, + { '?', ts.commands , ' Commands' , 'commands [?]' }, + { '/', ts.search_history , ' Search history' , '[/]search history' }, + {'', ts.resume , '󰐎 Resume' , 'Resume' }, + }, + v = { + { 's', my.selection , '' --[[dynamic]] , 'visual [s]election' }, + } } - } - telescope.load_extension 'fzf' - telescope.load_extension 'file_browser' - vim.keymap.set('n', 'fB', 'Telescope file_browser', { desc = ' [f]ile [B]rowser' }) -end - -return T + telescope.load_extension 'fzf' + telescope.load_extension 'file_browser' + vim.keymap.set('n', 'fB', 'Telescope file_browser', { desc = ' [f]ile [B]rowser' }) + end, +} diff --git a/config/nvim/lua/fschauen/plugins/todo-comments.lua b/config/nvim/lua/fschauen/plugins/todo-comments.lua index 44f6994..d08ed16 100644 --- a/config/nvim/lua/fschauen/plugins/todo-comments.lua +++ b/config/nvim/lua/fschauen/plugins/todo-comments.lua @@ -1,13 +1,19 @@ -local telescope = vim.F.npcall(require, 'fschauen.plugins.telescope') -local trigger = telescope and telescope.trigger or 'f' - return { 'folke/todo-comments.nvim', - dependencies = { 'nvim-lua/plenary.nvim' }, + + dependencies = { + 'nvim-lua/plenary.nvim' + }, + config = true, - event = { 'BufReadPost', 'BufNewFile' }, + + event = { + 'BufReadPost', + 'BufNewFile' + }, + keys = { - { trigger .. 't', 'TodoTelescope' }, + { 'ft', 'TodoTelescope' }, }, } diff --git a/config/nvim/lua/fschauen/plugins/treesitter.lua b/config/nvim/lua/fschauen/plugins/treesitter.lua index 7190a5f..e001194 100644 --- a/config/nvim/lua/fschauen/plugins/treesitter.lua +++ b/config/nvim/lua/fschauen/plugins/treesitter.lua @@ -1,5 +1,15 @@ -local config = function() - require('nvim-treesitter.configs').setup { +return { + 'nvim-treesitter/nvim-treesitter', + + dependencies = { + 'nvim-treesitter/nvim-treesitter-refactor', + 'nvim-treesitter/nvim-treesitter-textobjects', + 'nvim-treesitter/playground', + }, + + main = 'nvim-treesitter.configs', + + opts = { ensure_installed = { 'bash', 'c', @@ -81,21 +91,14 @@ local config = function() playground = { enable = true, }, - } + }, - vim.keymap.set('n', 'tp', 'TSPlaygroundToggle') - vim.keymap.set('n', 'th', 'TSHighlightCapturesUnderCursor') - vim.keymap.set('n', 'tn', 'TSNodeUnderCursor') -end + event = { 'BufReadPost', 'BufNewFile' }, -return { - 'nvim-treesitter/nvim-treesitter', - - config = config, - dependencies = { - 'nvim-treesitter/nvim-treesitter-refactor', - 'nvim-treesitter/nvim-treesitter-textobjects', - 'nvim-treesitter/playground', + keys = { + { 'tp', 'TSPlaygroundToggle' }, + { 'th', 'TSHighlightCapturesUnderCursor' }, + { 'tn', 'TSNodeUnderCursor' }, }, } diff --git a/config/nvim/lua/fschauen/plugins/trouble.lua b/config/nvim/lua/fschauen/plugins/trouble.lua index 49416e3..3d99339 100644 --- a/config/nvim/lua/fschauen/plugins/trouble.lua +++ b/config/nvim/lua/fschauen/plugins/trouble.lua @@ -3,17 +3,15 @@ return { dependencies = { 'nvim-tree/nvim-web-devicons' }, - config = function() - local trouble = require('trouble') + opts = { + padding = false, -- don't add an extra new line of top of the list + auto_preview = false, -- don't preview automatically + }, - trouble.setup { - padding = false, -- don't add an extra new line of top of the list - auto_preview = false, -- don't preview automatically - } - - vim.keymap.set('n', 'lt', 'TroubleToggle') - vim.keymap.set('n', 'lw', 'TroubleToggle workspace_diagnostics') - vim.keymap.set('n', 'ld', 'TroubleToggle document_diagnostics') - end + keys = { + { 'lt', 'TroubleToggle' }, + { 'lw', 'TroubleToggle workspace_diagnostics' }, + { 'ld', 'TroubleToggle document_diagnostics' }, + }, } diff --git a/config/nvim/lua/fschauen/plugins/undotree.lua b/config/nvim/lua/fschauen/plugins/undotree.lua index 1d94263..50e3c4f 100644 --- a/config/nvim/lua/fschauen/plugins/undotree.lua +++ b/config/nvim/lua/fschauen/plugins/undotree.lua @@ -13,8 +13,10 @@ return { vim.g.undotree_TreeReturnShape = '╲' end, - config = function() - vim.keymap.set('n', 'u', 'UndotreeToggle') - end + config = false, + + keys = { + { 'u', 'UndotreeToggle' }, + }, } diff --git a/config/nvim/lua/fschauen/plugins/vim-better-whitespace.lua b/config/nvim/lua/fschauen/plugins/vim-better-whitespace.lua index 01cca4a..42dd844 100644 --- a/config/nvim/lua/fschauen/plugins/vim-better-whitespace.lua +++ b/config/nvim/lua/fschauen/plugins/vim-better-whitespace.lua @@ -11,11 +11,13 @@ return { } end, - config = function() - vim.keymap.set('n', 'ww', 'ToggleWhitespace') - vim.keymap.set('n', 'wj', 'NextTrailingWhitespace') - vim.keymap.set('n', 'wk', 'PrevTrailingWhitespace') - vim.keymap.set('n', 'wd', 'StripWhitespace') - end, + config = false, + + keys ={ + { 'ww', 'ToggleWhitespace' }, + { 'wj', 'NextTrailingWhitespace' }, + { 'wk', 'PrevTrailingWhitespace' }, + { 'wd', 'StripWhitespace' }, + }, } diff --git a/config/nvim/lua/fschauen/plugins/virt-column.lua b/config/nvim/lua/fschauen/plugins/virt-column.lua index fdfd0c7..e48cdfa 100644 --- a/config/nvim/lua/fschauen/plugins/virt-column.lua +++ b/config/nvim/lua/fschauen/plugins/virt-column.lua @@ -1,20 +1,24 @@ return { 'lukas-reineke/virt-column.nvim', - config = function() - require('virt-column').setup { - char = '│', - } + opts = { + char = '│', + }, - local toggle_virtual_column = function() - if vim.o.colorcolumn == '' then - vim.o.colorcolumn = '+1' -- one after 'textwidth' - else - vim.o.colorcolumn = '' -- none - end - end + event = { 'BufReadPost', 'BufNewFile' }, - vim.keymap.set('n', 'sc', toggle_virtual_column) - end, + keys ={ + { + 'sc', + function() + if vim.o.colorcolumn == '' then + vim.o.colorcolumn = '+1' -- one after 'textwidth' + else + vim.o.colorcolumn = '' -- none + end + end, + 'Toggle virtual colunn' + }, + }, }