From f9d34430aec54f19d614eac926e6da0108b4bd5f Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 2 Oct 2022 21:27:44 +0200 Subject: [PATCH 01/11] removed workarounds for old vim version --- lua/setup/lualine.lua | 73 ++++++++++++-------------------------- lua/setup/my_lspconfig.lua | 12 ++----- 2 files changed, 25 insertions(+), 60 deletions(-) diff --git a/lua/setup/lualine.lua b/lua/setup/lualine.lua index b425551..a097b6f 100644 --- a/lua/setup/lualine.lua +++ b/lua/setup/lualine.lua @@ -1,50 +1,23 @@ -if vim.version().minor >= 8 then - local function status_line() - local file_name = "%-.32t" - local modified = " %-m" - local right_align = "%=" - local line_no = "%10([%l/%L%)]" - local pct_thru_file = "%5p%%" - - return string.format( - "%s%s%s%s%s", - file_name, - modified, - right_align, - line_no, - pct_thru_file - ) - end - - vim.opt.laststatus = 3 - -- vim.opt.winbar = status_line() - require('lualine').setup({ - options = { theme = 'gruvbox' }, - sections = { lualine_c = { 'getcwd', { 'filename', path = 1, file_status = true } } }, - inactive_sections = { lualine_c = { 'getcwd', { 'filename', path = 1, file_status = true } } }, - globalstatus = true, - winbar = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { { 'filename', path = 1, file_status = true } }, - lualine_x = {}, - lualine_y = {}, - lualine_z = {} - }, - inactive_winbar = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { { 'filename', path = 1, file_status = true } }, - lualine_x = {}, - lualine_y = {}, - lualine_z = {} - }, - }) -else - require('lualine').setup({ - options = { theme = 'gruvbox' }, - sections = { lualine_c = { 'filename' } }, - globalstatus = false, - -- inactive_sections = { lualine_c = { 'filename' } }, - }) -end +vim.opt.laststatus = 3 +require('lualine').setup({ + options = { theme = 'gruvbox' }, + sections = { lualine_c = { 'getcwd', { 'filename', path = 1, file_status = true } } }, + inactive_sections = { lualine_c = { 'getcwd', { 'filename', path = 1, file_status = true } } }, + globalstatus = true, + winbar = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { { 'filename', path = 1, file_status = true } }, + lualine_x = {}, + lualine_y = {}, + lualine_z = {} + }, + inactive_winbar = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { { 'filename', path = 1, file_status = true } }, + lualine_x = {}, + lualine_y = {}, + lualine_z = {} + }, +}) diff --git a/lua/setup/my_lspconfig.lua b/lua/setup/my_lspconfig.lua index 7ec3cff..b358981 100644 --- a/lua/setup/my_lspconfig.lua +++ b/lua/setup/my_lspconfig.lua @@ -63,18 +63,10 @@ local on_attach = function(client, bufnr) -- Set some keybinds conditional on server capabilities if client.server_capabilities.documentFormattingProvider then - if vim.version().minor >= 8 then - vim.keymap.set('n', 'f', vim.lsp.buf.format, opts) - else - vim.keymap.set('n', 'f', vim.lsp.buf.formatting, opts) - end + vim.keymap.set('n', 'f', vim.lsp.buf.format, opts) end if client.server_capabilities.documentRangeFormattingProvider then - if vim.version().minor >= 8 then - vim.keymap.set('v', 'f', vim.lsp.buf.format, opts) - else - vim.keymap.set('v', 'f', vim.lsp.buf.range_formatting, opts) - end + vim.keymap.set('v', 'f', vim.lsp.buf.range_formatting, opts) end -- Set autocommands conditional on server_capabilities From d91ae17970e3b4bce275ab1a74c51af07949cadd Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 5 Oct 2022 11:52:28 +0200 Subject: [PATCH 02/11] fixed highlight keymapping --- lua/my_keymappings.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lua/my_keymappings.lua b/lua/my_keymappings.lua index 3496eee..6b4405c 100644 --- a/lua/my_keymappings.lua +++ b/lua/my_keymappings.lua @@ -25,10 +25,14 @@ vim.keymap.set({ 'n', 'x' }, '', 'g', opts) vim.keymap.set('x', '<', '', '>gv') +local function hlWord() + local current_word = vim.call('expand','') + vim.fn.setreg('/', current_word) + vim.api.nvim_command "set hlsearch" +end -- Highlight word under cursor -vim.keymap.set('n', "'", ':let @/=\'\\<=expand("")\\>\':set hls', { noremap = true, silent = true }) --- vim.keymap.set('v', "'", "y:let @/='=escape(@\",'/\\')':set hls") -vim.keymap.set('x', "'", "y:let @/='=escape(@\",'/\\')':set hls", { noremap = true, silent = true }) +vim.keymap.set('n', "'", hlWord, { noremap = true, silent = false }) +vim.keymap.set('x', "'", 'y/\\V"N', { noremap = true, silent = true }) -- Close Buffer vim.keymap.set('n', '', ':bd') From edc73d36390f43af979be62a67ab3180d58da4fd Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 5 Oct 2022 11:53:26 +0200 Subject: [PATCH 03/11] small fix for highlight word --- lua/my_keymappings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/my_keymappings.lua b/lua/my_keymappings.lua index 6b4405c..24fcd6f 100644 --- a/lua/my_keymappings.lua +++ b/lua/my_keymappings.lua @@ -27,7 +27,7 @@ vim.keymap.set('x', '>', '>gv') local function hlWord() local current_word = vim.call('expand','') - vim.fn.setreg('/', current_word) + vim.fn.setreg('/', "\\<" .. current_word .. "\\>") vim.api.nvim_command "set hlsearch" end -- Highlight word under cursor From 739b2154eb95f37526176d0f58351382578e0fb0 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 5 Oct 2022 11:59:35 +0200 Subject: [PATCH 04/11] use more lua functions --- lua/my_keymappings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/my_keymappings.lua b/lua/my_keymappings.lua index 24fcd6f..f161bbb 100644 --- a/lua/my_keymappings.lua +++ b/lua/my_keymappings.lua @@ -28,7 +28,7 @@ vim.keymap.set('x', '>', '>gv') local function hlWord() local current_word = vim.call('expand','') vim.fn.setreg('/', "\\<" .. current_word .. "\\>") - vim.api.nvim_command "set hlsearch" + vim.opt.hlsearch = true end -- Highlight word under cursor vim.keymap.set('n', "'", hlWord, { noremap = true, silent = false }) From 570b9fe329385c1b31d108dbf7036c023fcf3e69 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 5 Oct 2022 12:02:21 +0200 Subject: [PATCH 05/11] highlight word to silent --- lua/my_keymappings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/my_keymappings.lua b/lua/my_keymappings.lua index f161bbb..f93b93a 100644 --- a/lua/my_keymappings.lua +++ b/lua/my_keymappings.lua @@ -31,7 +31,7 @@ local function hlWord() vim.opt.hlsearch = true end -- Highlight word under cursor -vim.keymap.set('n', "'", hlWord, { noremap = true, silent = false }) +vim.keymap.set('n', "'", hlWord, { noremap = true, silent = true }) vim.keymap.set('x', "'", 'y/\\V"N', { noremap = true, silent = true }) -- Close Buffer From d0c31ea3b73e0c9db1bcecf31c6fec3a1052b4b6 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 5 Oct 2022 19:36:13 +0200 Subject: [PATCH 06/11] lazy loading of dap and cmake --- lua/my_plugins.lua | 35 +++++++++++++++++++++++++++++------ lua/setup/my_dap.lua | 19 +++++++++++-------- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/lua/my_plugins.lua b/lua/my_plugins.lua index d9d3bf5..f8d5a50 100644 --- a/lua/my_plugins.lua +++ b/lua/my_plugins.lua @@ -105,12 +105,19 @@ return require('packer').startup(function() { 'hrsh7th/cmp-nvim-lsp-signature-help' }, { 'p00f/clangd_extensions.nvim' }, }, + as = 'cmp', config = get_setup('cmp'), }) use({ 'L3MON4D3/LuaSnip', config = get_setup('luasnip') }) use({ 'rafamadriz/friendly-snippets' }) use({ 'onsails/lspkind-nvim' }) - use({ 'Shatur/neovim-cmake', requires = { 'mfussenegger/nvim-dap' }, config = get_setup('cmake') }) + use({ 'Shatur/neovim-cmake', + requires = { 'mfussenegger/nvim-dap' }, + config = get_setup('cmake'), + opt = true, + module = 'cmake', + cmd = 'CMake' + }) use({ 'hoob3rt/lualine.nvim', requires = { 'kyazdani42/nvim-web-devicons', opt = true }, @@ -214,12 +221,28 @@ return require('packer').startup(function() 'mfussenegger/nvim-dap', requires = { 'mfussenegger/nvim-dap-python', - 'theHamsta/nvim-dap-virtual-text', - 'nvim-telescope/telescope-dap.nvim', - 'rcarriga/cmp-dap', - 'rcarriga/nvim-dap-ui' + { + 'theHamsta/nvim-dap-virtual-text', + module = 'nvim-dap-virtual-text' + }, + { + 'nvim-telescope/telescope-dap.nvim', + module = 'telescope._extensions.dap', + requires = 'telescope.nvim', + }, + { + 'rcarriga/cmp-dap', + requires = 'cmp' + }, + { + 'rcarriga/nvim-dap-ui', + module = 'dapui' + }, }, - config = get_setup('my_dap') + keys = { '', '' }, + module = 'dap', + config = get_setup('my_dap'), + opt = true, } use { 'sindrets/diffview.nvim', diff --git a/lua/setup/my_dap.lua b/lua/setup/my_dap.lua index 53b41ce..b4f38a9 100644 --- a/lua/setup/my_dap.lua +++ b/lua/setup/my_dap.lua @@ -1,4 +1,5 @@ dap = require('dap') + local opts = { noremap = true, silent = false } -- vim.keymap.set('n', '', dap.continue(), opts) vim.keymap.set('n', '', ":lua require('dap').continue()", opts) @@ -28,7 +29,9 @@ dap.adapters.python = { }; } -local dap, dapui = require("dap"), require("dapui") +local dap= require("dap") +local dapui = require("dapui") +dapui.setup() dap.listeners.after.event_initialized["dapui_config"] = function() dapui.open() end @@ -149,11 +152,11 @@ dap.configurations.cpp = { -- EXTENSIONS -require("nvim-dap-virtual-text").setup() +require('nvim-dap-virtual-text').setup() require('telescope').load_extension('dap') --- require("cmp").setup.filetype({ "dap-repl", "dapui_watches" }, { --- sources = { --- { name = "dap" }, --- }, --- }) -require("dapui").setup() +require('cmp').setup.filetype({ 'dap-repl', 'dapui_watches', 'dapui_hover' }, { + sources = { + { name = 'dap' }, + }, +}) + From 7629d6d57efc0472f18b732bf4c88eeea3e5bff0 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 5 Oct 2022 19:36:26 +0200 Subject: [PATCH 07/11] fixed format mode --- lua/setup/my_lspconfig.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/setup/my_lspconfig.lua b/lua/setup/my_lspconfig.lua index b358981..4ed5411 100644 --- a/lua/setup/my_lspconfig.lua +++ b/lua/setup/my_lspconfig.lua @@ -66,7 +66,7 @@ local on_attach = function(client, bufnr) vim.keymap.set('n', 'f', vim.lsp.buf.format, opts) end if client.server_capabilities.documentRangeFormattingProvider then - vim.keymap.set('v', 'f', vim.lsp.buf.range_formatting, opts) + vim.keymap.set('x', 'f', vim.lsp.buf.format, opts) end -- Set autocommands conditional on server_capabilities From 1e8201cd13ddc16e83d461cdb56114a3e1958219 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 5 Oct 2022 22:26:37 +0200 Subject: [PATCH 08/11] lazy loading aerial --- lua/my_plugins.lua | 9 ++++++++- lua/setup/aerial.lua | 1 + lua/setup/telescope.lua | 1 - 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lua/my_plugins.lua b/lua/my_plugins.lua index f8d5a50..34c41cd 100644 --- a/lua/my_plugins.lua +++ b/lua/my_plugins.lua @@ -205,7 +205,14 @@ return require('packer').startup(function() } use { 'stevearc/aerial.nvim', - config = get_setup('aerial') + requires = { + 'telescope' + }, + config = get_setup('aerial'), + opt = true, + keys = { 's', 's' }, + module = 'aerial', + cmd = 'AerialToggle' } use { 'm-demare/hlargs.nvim', diff --git a/lua/setup/aerial.lua b/lua/setup/aerial.lua index 2ddd243..a6be18f 100644 --- a/lua/setup/aerial.lua +++ b/lua/setup/aerial.lua @@ -4,3 +4,4 @@ require('aerial').setup({ filter_kind = false, show_guides = true, }) +require('telescope').load_extension('aerial') diff --git a/lua/setup/telescope.lua b/lua/setup/telescope.lua index c452716..f18d02f 100644 --- a/lua/setup/telescope.lua +++ b/lua/setup/telescope.lua @@ -49,4 +49,3 @@ require('telescope').setup({ }) require('telescope').load_extension('fzf') -require('telescope').load_extension('aerial') From 3272e4067f6f851d378fe4f3a42964529d163c6c Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 5 Oct 2022 22:30:42 +0200 Subject: [PATCH 09/11] lazy load diffview --- lua/my_plugins.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/my_plugins.lua b/lua/my_plugins.lua index 34c41cd..4c76dff 100644 --- a/lua/my_plugins.lua +++ b/lua/my_plugins.lua @@ -254,7 +254,10 @@ return require('packer').startup(function() use { 'sindrets/diffview.nvim', requires = 'nvim-lua/plenary.nvim', - config = get_setup('my_diffview') + config = get_setup('my_diffview'), + opt = true, + cmd = 'DiffviewOpen', + module = { 'diffview', 'diffview.actions' } } if packer_bootstrap then require('packer').sync() From 5b6ae547637c45adf07ecdcf07e2667ead19823d Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 5 Oct 2022 22:45:52 +0200 Subject: [PATCH 10/11] fixed aerial config --- lua/my_plugins.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/my_plugins.lua b/lua/my_plugins.lua index 4c76dff..9ecd2dd 100644 --- a/lua/my_plugins.lua +++ b/lua/my_plugins.lua @@ -206,7 +206,7 @@ return require('packer').startup(function() use { 'stevearc/aerial.nvim', requires = { - 'telescope' + 'nvim-telescope/telescope.nvim' }, config = get_setup('aerial'), opt = true, From e2460a24252fd8af5cf2aa1611f97d0b384cf352 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 5 Oct 2022 23:43:19 +0200 Subject: [PATCH 11/11] source selector for neo tree --- lua/setup/neo-tree.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/setup/neo-tree.lua b/lua/setup/neo-tree.lua index 94d38f5..bf78d31 100644 --- a/lua/setup/neo-tree.lua +++ b/lua/setup/neo-tree.lua @@ -47,5 +47,9 @@ require('neo-tree').setup({ hide_gitignored = false, }, }, + source_selector = { + winbar = true, + statusline = false + } }) vim.keymap.set('n', '\\', 'Neotree reveal')