From 1d436a3df782f340fa5a1698079f03997511c6b3 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 10 Dec 2022 19:28:33 +0100 Subject: [PATCH 01/38] lazy load yanky --- lua/my_plugins.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/my_plugins.lua b/lua/my_plugins.lua index f978465..4a1dfdc 100644 --- a/lua/my_plugins.lua +++ b/lua/my_plugins.lua @@ -180,7 +180,14 @@ return require('packer').startup(function() }) use({ 'gbprod/yanky.nvim', - config = get_setup('yanky') + config = get_setup('yanky'), + keys = { + { 'n', '' }, + { 'n', '' } + }, + requires = { + 'nvim-telescope/telescope.nvim' + } }) use { 'ldelossa/litee.nvim', From 5d7231efa2f34cd162b80eda310071715a2a655b Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 10 Dec 2022 19:28:55 +0100 Subject: [PATCH 02/38] lazy load lspconfig --- lua/my_plugins.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/my_plugins.lua b/lua/my_plugins.lua index 4a1dfdc..0534a4b 100644 --- a/lua/my_plugins.lua +++ b/lua/my_plugins.lua @@ -144,6 +144,8 @@ return require('packer').startup(function() 'p00f/clangd_extensions.nvim', }, config = get_setup('my_lspconfig'), + module_pattern = { "lspconfig.*" }, + event = { "InsertEnter", "CursorMoved" }, }) use({ 'jose-elias-alvarez/null-ls.nvim', From 1d9f94e650d1f4993a464fc430914112ebc4b72e Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 10 Dec 2022 19:29:16 +0100 Subject: [PATCH 03/38] lazy load luasnip --- 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 0534a4b..9fa6d4f 100644 --- a/lua/my_plugins.lua +++ b/lua/my_plugins.lua @@ -115,8 +115,11 @@ return require('packer').startup(function() module = 'cmp_dap' }, }, config = get_setup('my_cmp'), + use({ + 'L3MON4D3/LuaSnip', + config = get_setup('luasnip'), + module = { "luasnip", "LuaSnip" } }) - use({ 'L3MON4D3/LuaSnip', config = get_setup('luasnip') }) use({ 'rafamadriz/friendly-snippets' }) use({ 'onsails/lspkind-nvim' }) use({ From 58ae25ee12273c9175409bb1b337eefacf099fa8 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 10 Dec 2022 19:29:28 +0100 Subject: [PATCH 04/38] lazy load cmp --- lua/my_plugins.lua | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/lua/my_plugins.lua b/lua/my_plugins.lua index 9fa6d4f..9a62fc3 100644 --- a/lua/my_plugins.lua +++ b/lua/my_plugins.lua @@ -95,26 +95,26 @@ return require('packer').startup(function() use({ 'hrsh7th/nvim-cmp', requires = { - { 'hrsh7th/cmp-buffer' }, - { 'hrsh7th/cmp-nvim-lsp' }, - { 'L3MON4D3/LuaSnip' }, - { 'saadparwaiz1/cmp_luasnip' }, - { 'hrsh7th/cmp-nvim-lua' }, - { 'octaltree/cmp-look' }, - { 'hrsh7th/cmp-path' }, - { 'hrsh7th/cmp-calc' }, - { 'f3fora/cmp-spell' }, - { 'hrsh7th/cmp-emoji' }, - { 'hrsh7th/cmp-cmdline' }, - { 'dmitmel/cmp-cmdline-history' }, - { 'ray-x/cmp-treesitter' }, - { 'hrsh7th/cmp-nvim-lsp-signature-help' }, + { 'hrsh7th/cmp-buffer', after = 'nvim-cmp' }, + { 'hrsh7th/cmp-nvim-lsp', after = 'nvim-cmp' }, + { 'L3MON4D3/LuaSnip', after = 'nvim-cmp' }, + { 'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp' }, + { 'hrsh7th/cmp-nvim-lua', after = 'nvim-cmp' }, + { 'octaltree/cmp-look', after = 'nvim-cmp' }, + { 'hrsh7th/cmp-path', after = 'nvim-cmp' }, + { 'hrsh7th/cmp-calc', after = 'nvim-cmp' }, + { 'f3fora/cmp-spell', after = 'nvim-cmp' }, + { 'hrsh7th/cmp-emoji', after = 'nvim-cmp' }, + { 'hrsh7th/cmp-cmdline', after = 'nvim-cmp' }, + { 'dmitmel/cmp-cmdline-history', after = 'nvim-cmp' }, + { 'ray-x/cmp-treesitter', after = 'nvim-cmp' }, + { 'hrsh7th/cmp-nvim-lsp-signature-help', after = 'nvim-cmp' }, { 'p00f/clangd_extensions.nvim' }, - { 'rcarriga/cmp-dap', - opt = true, - module = 'cmp_dap' }, }, config = get_setup('my_cmp'), + module = { "nvim-cmp", "cmp" }, + event = "InsertEnter *", + }) use({ 'L3MON4D3/LuaSnip', config = get_setup('luasnip'), @@ -238,6 +238,10 @@ return require('packer').startup(function() 'rcarriga/nvim-dap-ui', module = 'dapui' }, + { + 'rcarriga/cmp-dap', + module = 'cmp_dap' + }, }, keys = { { 'n', '' }, From 51183ffd55a05855841f09130d3ea1babfa0dba4 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 11 Dec 2022 13:05:34 +0100 Subject: [PATCH 05/38] move project keymap to its config file --- lua/setup/project.lua | 11 +++++++++++ lua/setup/telescope.lua | 5 ----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lua/setup/project.lua b/lua/setup/project.lua index 0e735ff..bc289c5 100644 --- a/lua/setup/project.lua +++ b/lua/setup/project.lua @@ -4,3 +4,14 @@ require('project_nvim').setup({ patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json", "build_nvim", "real_path.txt" }, }) require('telescope').load_extension('projects') +require('legendary').keymaps( + { + { + 'p', + function () + require('telescope').extensions.projects.projects() + end, + description = 'Select project', + }, + } +) diff --git a/lua/setup/telescope.lua b/lua/setup/telescope.lua index 367d1c2..b23fe64 100644 --- a/lua/setup/telescope.lua +++ b/lua/setup/telescope.lua @@ -62,11 +62,6 @@ end require('legendary').keymaps( { - { - 'p', - ':Telescope projects', - description = 'Select project', - }, { 'f', ':lua require("telescope.builtin").find_files({no_ignore=true})', From 738bcabefe987f36a1110cd988dd9ddb0c2d41a8 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 24 Dec 2022 13:36:12 +0100 Subject: [PATCH 06/38] start migrating to lazy plugin manager --- lua/my_lazy.lua | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 lua/my_lazy.lua diff --git a/lua/my_lazy.lua b/lua/my_lazy.lua new file mode 100644 index 0000000..91897f4 --- /dev/null +++ b/lua/my_lazy.lua @@ -0,0 +1,51 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "--single-branch", + "https://github.com/folke/lazy.nvim.git", + lazypath, + }) +end +vim.opt.runtimepath:prepend(lazypath) + + +local plugins = { + { + 'mrjones2014/legendary.nvim', + config = function() + require('setup/my_legendary') + end + }, + { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + config = function() + require('setup/treesitter') + end + }, + { + 'nvim-telescope/telescope.nvim', + dependencies = { + { 'nvim-lua/plenary.nvim' }, + { 'kyazdani42/nvim-web-devicons' }, + }, + config = function() + require('setup/telescope') + end + }, + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-target x86_64-w64-mingw32" -G Ninja && cmake --build build --config Release && cmake --install build --prefix build', + dependencies = { + 'nvim-telescope/telescope.nvim', + }, + config = function() + require('telescope').load_extension('fzf') + end + }, +} +local opts = {} +require("lazy").setup(plugins, opts) From 8fb7e9ad0a4274594391f88a42519fb05b9d62e4 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 24 Dec 2022 14:46:00 +0100 Subject: [PATCH 07/38] added all plugins to lazy --- lua/my_lazy.lua | 202 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 194 insertions(+), 8 deletions(-) diff --git a/lua/my_lazy.lua b/lua/my_lazy.lua index 91897f4..edfc8c1 100644 --- a/lua/my_lazy.lua +++ b/lua/my_lazy.lua @@ -26,26 +26,212 @@ local plugins = { require('setup/treesitter') end }, + { + 'p00f/nvim-ts-rainbow', + dependencies = 'nvim-treesitter/nvim-treesitter', + }, { 'nvim-telescope/telescope.nvim', dependencies = { - { 'nvim-lua/plenary.nvim' }, - { 'kyazdani42/nvim-web-devicons' }, + 'nvim-lua/plenary.nvim', + 'kyazdani42/nvim-web-devicons', + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = { + 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -G Ninja', -- On windows add -DCMAKE_C_FLAGS="-target x86_64-w64-mingw32" + 'cmake --build build --config Release', + 'cmake --install build --prefix build' + }, + config = function() + require('telescope').load_extension('fzf') + end + }, }, config = function() require('setup/telescope') end }, { - 'nvim-telescope/telescope-fzf-native.nvim', - build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-target x86_64-w64-mingw32" -G Ninja && cmake --build build --config Release && cmake --install build --prefix build', - dependencies = { - 'nvim-telescope/telescope.nvim', - }, + 'eddyekofo94/gruvbox-flat.nvim', + disable = false, config = function() - require('telescope').load_extension('fzf') + require('setup/my_gruvbox_flat') end }, + { + 'lukas-reineke/indent-blankline.nvim', + dependencies = { + 'nvim-treesitter/nvim-treesitter', + }, + config = function() + require('setup/indent_blankline') + end, + }, + + { + 'lewis6991/gitsigns.nvim', + config = function() + require('setup/gitsigns') + end, + }, + { + 'numToStr/Comment.nvim', + config = function() + require('setup/comment') + end, + }, + { + 'hoob3rt/lualine.nvim', + dependencies = { 'kyazdani42/nvim-web-devicons' }, + config = function() + require('setup/lualine') + end, + }, + { + 'hrsh7th/nvim-cmp', + dependencies = { + { 'onsails/lspkind-nvim' }, + { 'hrsh7th/cmp-buffer' }, + { 'hrsh7th/cmp-nvim-lsp' }, + { + 'L3MON4D3/LuaSnip', + config = function() + require('setup/luasnip') + end, + dependencies = + { + 'rafamadriz/friendly-snippets' + } + }, + { 'saadparwaiz1/cmp_luasnip' }, + { 'hrsh7th/cmp-nvim-lua' }, + { 'octaltree/cmp-look' }, + { 'hrsh7th/cmp-path' }, + { 'hrsh7th/cmp-calc' }, + { 'f3fora/cmp-spell' }, + { 'hrsh7th/cmp-emoji' }, + { 'hrsh7th/cmp-cmdline' }, + { 'dmitmel/cmp-cmdline-history' }, + { 'ray-x/cmp-treesitter' }, + { 'hrsh7th/cmp-nvim-lsp-signature-help' }, + { 'p00f/clangd_extensions.nvim' }, + { + 'windwp/nvim-autopairs', + config = function() + require('setup/nvim-autopairs') + end + }, + }, + config = function() + require('setup/my_cmp') + end, + event = "InsertEnter", + }, + -- { + -- 'L3MON4D3/LuaSnip', + -- config = function() + -- require('setup/luasnip') + -- end, + -- dependencies = + -- { + -- 'rafamadriz/friendly-snippets' + -- } + { + 'neovim/nvim-lspconfig', + dependencies = { + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + 'p00f/clangd_extensions.nvim', + 'jose-elias-alvarez/null-ls.nvim', + 'ray-x/lsp_signature.nvim', + }, + config = function() + require('setup/my_lspconfig') + end, + event = { "InsertEnter", "CursorMoved" }, + }, + { + 'akinsho/toggleterm.nvim', + config = function() + require('setup/toggleterm') + end, + cmd = 'ToggleTerm' + }, + { + 'gbprod/yanky.nvim', + config = function() + require('setup/yanky') + end, + keys = { + { 'n', '' }, + { 'n', '' } + }, + dependencies = { + 'nvim-telescope/telescope.nvim' + } + }, + { + 'stevearc/aerial.nvim', + dependencies = { + 'nvim-telescope/telescope.nvim' + }, + config = function() + require('setup/aerial') + end, + keys = { + { 'n', 's' } + } + }, + { + 'ggandor/leap.nvim', + dependencies = { 'tpope/vim-repeat' }, + config = function() + require('setup/my_leap') + end + }, + { + 'mfussenegger/nvim-dap', + dependencies = { + 'mfussenegger/nvim-dap-python', + 'theHamsta/nvim-dap-virtual-text', + { + 'nvim-telescope/telescope-dap.nvim', + dependencies = 'telescope.nvim', + }, + 'rcarriga/nvim-dap-ui', + 'rcarriga/cmp-dap', + }, + keys = { + { '' }, + { '' }, + { '' }, + { '' }, + { '' }, + { '' }, + { '' }, + { '' } + }, + config = function() + require('setup/my_dap') + end, + }, + { + 'sindrets/diffview.nvim', + dependencies = 'nvim-lua/plenary.nvim', + config = function() + require('setup/my_diffview') + end, + cmd = 'DiffviewOpen', + }, + { + 'stevearc/overseer.nvim', + config = function() + require('setup/my_overseer') + end, + keys = { + { '' } + }, + } } local opts = {} require("lazy").setup(plugins, opts) From 6b9089ee85dd8365e97b260d0c399be9e2a782f7 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 24 Dec 2022 15:05:11 +0100 Subject: [PATCH 08/38] fixed events and keys in lazy --- lua/my_lazy.lua | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/lua/my_lazy.lua b/lua/my_lazy.lua index edfc8c1..a375471 100644 --- a/lua/my_lazy.lua +++ b/lua/my_lazy.lua @@ -125,17 +125,8 @@ local plugins = { config = function() require('setup/my_cmp') end, - event = "InsertEnter", + event = {'InsertEnter', 'CmdLineEnter'}, }, - -- { - -- 'L3MON4D3/LuaSnip', - -- config = function() - -- require('setup/luasnip') - -- end, - -- dependencies = - -- { - -- 'rafamadriz/friendly-snippets' - -- } { 'neovim/nvim-lspconfig', dependencies = { @@ -163,8 +154,8 @@ local plugins = { require('setup/yanky') end, keys = { - { 'n', '' }, - { 'n', '' } + { '' }, + { '' } }, dependencies = { 'nvim-telescope/telescope.nvim' @@ -178,8 +169,9 @@ local plugins = { config = function() require('setup/aerial') end, + cmd = 'AerialToggle', keys = { - { 'n', 's' } + { 's' } } }, { From a62b9ca215c8cdc5e735f7fed33b6878f0b3a54c Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 24 Dec 2022 15:05:48 +0100 Subject: [PATCH 09/38] don't load the fzf extension in the telescope setup --- lua/setup/telescope.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/lua/setup/telescope.lua b/lua/setup/telescope.lua index b23fe64..fe82bea 100644 --- a/lua/setup/telescope.lua +++ b/lua/setup/telescope.lua @@ -52,8 +52,6 @@ require('telescope').setup({ }, }) -require('telescope').load_extension('fzf') - Project_files = function() local opts = {} -- define here if you want to define something local ok = pcall(require "telescope.builtin".git_files, opts) From e1e32cf52c6200a1e37f026ff3e5b124519a72b2 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 24 Dec 2022 15:05:56 +0100 Subject: [PATCH 10/38] use lazy --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 496a039..2bf6d5a 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,6 @@ vim.g.mapleader = ',' if not vim.g.vscode then - require('my_plugins') + require('my_lazy') require('my_keymappings') require('my_options') require('my_autocommands') From c52f6304d41b41160b9b88a5a3ca490a580a53f3 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 24 Dec 2022 22:36:32 +0100 Subject: [PATCH 11/38] added project.nvim --- lua/my_lazy.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/my_lazy.lua b/lua/my_lazy.lua index a375471..894146c 100644 --- a/lua/my_lazy.lua +++ b/lua/my_lazy.lua @@ -51,6 +51,12 @@ local plugins = { require('setup/telescope') end }, + { + 'ahmedkhalf/project.nvim', + config = function() + require('setup/project') + end, + }, { 'eddyekofo94/gruvbox-flat.nvim', disable = false, From fa41d32ae14e3f1a7c73f57794598f66bf668346 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 24 Dec 2022 22:36:47 +0100 Subject: [PATCH 12/38] fixed lazygit keybinding --- lua/my_lazy.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/my_lazy.lua b/lua/my_lazy.lua index 894146c..6564de4 100644 --- a/lua/my_lazy.lua +++ b/lua/my_lazy.lua @@ -152,7 +152,8 @@ local plugins = { config = function() require('setup/toggleterm') end, - cmd = 'ToggleTerm' + cmd = 'ToggleTerm', + keys = 'g' }, { 'gbprod/yanky.nvim', From 62734cac5c52a0dfcd11d17b11808f18cea6b408 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 24 Dec 2022 22:38:53 +0100 Subject: [PATCH 13/38] keybinding for lazy and fixed legendary --- lua/my_lazy.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lua/my_lazy.lua b/lua/my_lazy.lua index 6564de4..1249476 100644 --- a/lua/my_lazy.lua +++ b/lua/my_lazy.lua @@ -17,7 +17,23 @@ local plugins = { 'mrjones2014/legendary.nvim', config = function() require('setup/my_legendary') - end + require('legendary').keymaps( + { + { + 'i', + function() + require("lazy").home() + end, + description = 'Start lazy home' + } + } + ) + end, + dependencies = { + 'stevearc/dressing.nvim', + 'nvim-telescope/telescope.nvim', + }, + keys = { 'p', 'i' } }, { 'nvim-treesitter/nvim-treesitter', From b7167a3a47dc6f2ecc9e869dd083191d8ff909ff Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 24 Dec 2022 22:39:05 +0100 Subject: [PATCH 14/38] format --- lua/my_lazy.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/my_lazy.lua b/lua/my_lazy.lua index 1249476..e5ca3f4 100644 --- a/lua/my_lazy.lua +++ b/lua/my_lazy.lua @@ -89,7 +89,6 @@ local plugins = { require('setup/indent_blankline') end, }, - { 'lewis6991/gitsigns.nvim', config = function() @@ -147,7 +146,7 @@ local plugins = { config = function() require('setup/my_cmp') end, - event = {'InsertEnter', 'CmdLineEnter'}, + event = { 'InsertEnter', 'CmdLineEnter' }, }, { 'neovim/nvim-lspconfig', From 1adb3c8ff2b53291c034ae82826a17afd4afe366 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 24 Dec 2022 22:55:37 +0100 Subject: [PATCH 15/38] don't autoinstall lsp server --- 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 6b2b379..b16a0c0 100644 --- a/lua/setup/my_lspconfig.lua +++ b/lua/setup/my_lspconfig.lua @@ -1,6 +1,6 @@ require('mason').setup() require('mason-lspconfig').setup({ - automatic_installation = true, + automatic_installation = false, }) local capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) From c136b87b7b6bf215e6a3e4cac8931307490c2e23 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 24 Dec 2022 23:07:24 +0100 Subject: [PATCH 16/38] fixed overseer keybinding --- lua/setup/my_overseer.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lua/setup/my_overseer.lua b/lua/setup/my_overseer.lua index 9954872..82b9060 100644 --- a/lua/setup/my_overseer.lua +++ b/lua/setup/my_overseer.lua @@ -3,7 +3,16 @@ overseer.setup({ templates = { "builtin", "user.cmake.cmake" }, }) -vim.keymap.set({ 'n', 'x' }, '', function() - overseer.open() - overseer.run_template() -end, opts) +require('legendary').keymaps( + { + { + '', + function() + overseer.open() + overseer.run_template() + end, + mode = { 'n', 'x' }, + description = 'Start task (overseer)', + }, + } +) From 17b3f53e11af9749b3992ec0b85146109a841fef Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 24 Dec 2022 23:25:17 +0100 Subject: [PATCH 17/38] add telescope ui select --- lua/my_lazy.lua | 1 + lua/setup/telescope.lua | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lua/my_lazy.lua b/lua/my_lazy.lua index e5ca3f4..b9f8dd2 100644 --- a/lua/my_lazy.lua +++ b/lua/my_lazy.lua @@ -53,6 +53,7 @@ local plugins = { 'kyazdani42/nvim-web-devicons', { 'nvim-telescope/telescope-fzf-native.nvim', + 'nvim-telescope/telescope-ui-select.nvim', build = { 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -G Ninja', -- On windows add -DCMAKE_C_FLAGS="-target x86_64-w64-mingw32" 'cmake --build build --config Release', diff --git a/lua/setup/telescope.lua b/lua/setup/telescope.lua index fe82bea..818a82e 100644 --- a/lua/setup/telescope.lua +++ b/lua/setup/telescope.lua @@ -50,8 +50,16 @@ require('telescope').setup({ }, lsp_dynamic_workspace_symbols = {}, }, + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown { + } + } + } }) +require("telescope").load_extension("ui-select") + Project_files = function() local opts = {} -- define here if you want to define something local ok = pcall(require "telescope.builtin".git_files, opts) From e562f3b996725182b6faf91491694739aa826c2a Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 27 Dec 2022 14:33:28 +0100 Subject: [PATCH 18/38] added lazy lock file --- lazy-lock.json | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 lazy-lock.json diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..dcfc50d --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,55 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "45dc21a71ad1450606f5e98261badb28db59d74c" }, + "LuaSnip": { "branch": "master", "commit": "5570fd797eae0790affb54ea669a150cad76db5d" }, + "aerial.nvim": { "branch": "master", "commit": "7e2fef6ec501a3fe8bc6c4051b3a1014dc098a06" }, + "clangd_extensions.nvim": { "branch": "main", "commit": "9bd6073dd1230e667f97760b5a73f81547a19528" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-calc": { "branch": "main", "commit": "50792f34a628ea6eb31d2c90e8df174671e4e7a0" }, + "cmp-cmdline": { "branch": "main", "commit": "23c51b2a3c00f6abc4e922dbd7c3b9aca6992063" }, + "cmp-cmdline-history": { "branch": "master", "commit": "003573b72d4635ce636234a826fa8c4ba2895ffe" }, + "cmp-dap": { "branch": "master", "commit": "d16f14a210cd28988b97ca8339d504533b7e09a4" }, + "cmp-emoji": { "branch": "main", "commit": "19075c36d5820253d32e2478b6aaf3734aeaafa0" }, + "cmp-look": { "branch": "master", "commit": "b39c50bcdf6199dddda56adc466c2bd9c951a960" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "59224771f91b86d1de12570b4070fe4ad7cd1eeb" }, + "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "d2768cb1b83de649d57d967085fe73c5e01f8fd7" }, + "cmp-nvim-lua": { "branch": "main", "commit": "d276254e7198ab7d00f117e88e223b4bd8c02d21" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp-spell": { "branch": "master", "commit": "60584cb75e5e8bba5a0c9e4c3ab0791e0698bffa" }, + "cmp-treesitter": { "branch": "master", "commit": "b40178b780d547bcf131c684bc5fd41af17d05f2" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "diffview.nvim": { "branch": "main", "commit": "3812e296d3977a24db62f7c18025755b40968d3a" }, + "dressing.nvim": { "branch": "master", "commit": "4436d6f41e2f6b8ada57588acd1a9f8b3d21453c" }, + "friendly-snippets": { "branch": "main", "commit": "1a6a02350568d6830bcfa167c72f9b6e75e454ae" }, + "gitsigns.nvim": { "branch": "main", "commit": "2ab3bdf0a40bab53033048c6be75bda86316b55d" }, + "gruvbox-flat.nvim": { "branch": "master", "commit": "172269867994c0da7adcf02e89a068cda85eb805" }, + "indent-blankline.nvim": { "branch": "master", "commit": "c4c203c3e8a595bc333abaf168fcb10c13ed5fb7" }, + "lazy.nvim": { "branch": "main", "commit": "5a5487b015743c69d6a275156a90af35c2905c47" }, + "leap.nvim": { "branch": "main", "commit": "a5c9504290832e6bdbbb6265fd1ff02fc6485d20" }, + "legendary.nvim": { "branch": "master", "commit": "f53ef425b1b6cb9dc907a054755138345fd2fd57" }, + "lsp_signature.nvim": { "branch": "master", "commit": "1979f1118e2b38084e7c148f279eed6e9300a342" }, + "lspkind-nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" }, + "lualine.nvim": { "branch": "master", "commit": "fffbcb829288c3ca366f17cdb8d46aefb5c1d6f3" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "31d8ed0dd3daf6cc64e35d710a190b64080bdc86" }, + "mason.nvim": { "branch": "main", "commit": "5f82a4e5618ebb0f3197141e9f14a07b56d5390f" }, + "null-ls.nvim": { "branch": "main", "commit": "b26851b3e7ac1c0c85666f8a74e36aef2acb89c6" }, + "nvim-autopairs": { "branch": "master", "commit": "03580d758231956d33c8dd91e2be195106a79fa4" }, + "nvim-cmp": { "branch": "main", "commit": "e55033fce468c9c578b946948807f2ac48a6ee08" }, + "nvim-dap": { "branch": "master", "commit": "6f2ea9e33b48a51849ec93c6c38148a5372018e4" }, + "nvim-dap-python": { "branch": "master", "commit": "d4400d075c21ed8fb8e8ac6a5ff56f58f6e93531" }, + "nvim-dap-ui": { "branch": "master", "commit": "54365d2eb4cb9cfab0371306c6a76c913c5a67e3" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "2971ce3e89b1711cc26e27f73d3f854b559a77d4" }, + "nvim-lspconfig": { "branch": "master", "commit": "42ca8ce0f2252be795da4789fadfa91f6c3f7464" }, + "nvim-treesitter": { "branch": "master", "commit": "0cb637ca9f4389172933e5aba36387ab8430b6fb" }, + "nvim-ts-rainbow": { "branch": "master", "commit": "064fd6c0a15fae7f876c2c6dd4524ca3fad96750" }, + "nvim-web-devicons": { "branch": "master", "commit": "05e1072f63f6c194ac6e867b567e6b437d3d4622" }, + "overseer.nvim": { "branch": "master", "commit": "82ed207195b58a73b9f7d013d6eb3c7d78674ac9" }, + "plenary.nvim": { "branch": "master", "commit": "4b7e52044bbb84242158d977a50c4cbcd85070c7" }, + "project.nvim": { "branch": "main", "commit": "685bc8e3890d2feb07ccf919522c97f7d33b94e4" }, + "telescope-dap.nvim": { "branch": "master", "commit": "313d2ea12ae59a1ca51b62bf01fc941a983d9c9c" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "fab3e2212e206f4f8b3bbaa656e129443c9b802e" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "62ea5e58c7bbe191297b983a9e7e89420f581369" }, + "telescope.nvim": { "branch": "master", "commit": "e960efa60e97df58e089b00270f09d60f27202c8" }, + "toggleterm.nvim": { "branch": "main", "commit": "b02a1674bd0010d7982b056fd3df4f717ff8a57a" }, + "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, + "yanky.nvim": { "branch": "main", "commit": "2bb05abe20b5d7af917a48785acfacb602248e36" } +} \ No newline at end of file From 4f0bab54b5467275021cc348523468ef37c08682 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 27 Dec 2022 14:33:46 +0100 Subject: [PATCH 19/38] lazy load comment nvim --- lua/my_lazy.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/my_lazy.lua b/lua/my_lazy.lua index b9f8dd2..a4de69f 100644 --- a/lua/my_lazy.lua +++ b/lua/my_lazy.lua @@ -101,6 +101,7 @@ local plugins = { config = function() require('setup/comment') end, + keys = '' }, { 'hoob3rt/lualine.nvim', From 9361934d8a6848d0cf740cfeaf54eef070382c32 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 27 Dec 2022 14:55:11 +0100 Subject: [PATCH 20/38] use some very lazy things --- lua/my_lazy.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/my_lazy.lua b/lua/my_lazy.lua index a4de69f..fba444b 100644 --- a/lua/my_lazy.lua +++ b/lua/my_lazy.lua @@ -45,6 +45,7 @@ local plugins = { { 'p00f/nvim-ts-rainbow', dependencies = 'nvim-treesitter/nvim-treesitter', + event = 'VeryLazy' }, { 'nvim-telescope/telescope.nvim', @@ -73,6 +74,7 @@ local plugins = { config = function() require('setup/project') end, + event = 'VeryLazy' }, { 'eddyekofo94/gruvbox-flat.nvim', @@ -162,7 +164,7 @@ local plugins = { config = function() require('setup/my_lspconfig') end, - event = { "InsertEnter", "CursorMoved" }, + event = 'VeryLazy' }, { 'akinsho/toggleterm.nvim', @@ -203,7 +205,8 @@ local plugins = { dependencies = { 'tpope/vim-repeat' }, config = function() require('setup/my_leap') - end + end, + event = 'VeryLazy' }, { 'mfussenegger/nvim-dap', From 5dd99d7085c396a6619129e5219235299c3741a7 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 27 Dec 2022 14:57:08 +0100 Subject: [PATCH 21/38] remove esc to quit for telescope --- lua/setup/telescope.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/setup/telescope.lua b/lua/setup/telescope.lua index 818a82e..29bcf65 100644 --- a/lua/setup/telescope.lua +++ b/lua/setup/telescope.lua @@ -11,7 +11,6 @@ require('telescope').setup({ defaults = { mappings = { i = { - [''] = actions.close, [''] = actions.select_default + actions.center, [''] = actions.send_selected_to_loclist, [''] = actions.smart_send_to_qflist, From fd16ef223a829449802c7b00755f01502d383f9c Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 28 Dec 2022 13:52:17 +0100 Subject: [PATCH 22/38] start restructering of lazy --- init.lua | 4 +- lua/config/lazy.lua | 14 + lua/{my_options.lua => config/options.lua} | 124 ++++----- lua/my_plugins.lua | 282 --------------------- lua/{my_lazy.lua => plugins/init.lua} | 47 +--- lua/plugins/neotree.lua | 62 +++++ lua/plugins/telescope.lua | 161 ++++++++++++ lua/plugins/treesitter.lua | 50 ++++ lua/setup/neo-tree.lua | 56 ---- lua/setup/telescope.lua | 135 ---------- lua/setup/treesitter.lua | 48 ---- 11 files changed, 352 insertions(+), 631 deletions(-) create mode 100644 lua/config/lazy.lua rename lua/{my_options.lua => config/options.lua} (97%) delete mode 100644 lua/my_plugins.lua rename lua/{my_lazy.lua => plugins/init.lua} (75%) create mode 100644 lua/plugins/neotree.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/treesitter.lua delete mode 100644 lua/setup/neo-tree.lua delete mode 100644 lua/setup/telescope.lua delete mode 100644 lua/setup/treesitter.lua diff --git a/init.lua b/init.lua index 2bf6d5a..93e408b 100644 --- a/init.lua +++ b/init.lua @@ -1,7 +1,7 @@ vim.g.mapleader = ',' if not vim.g.vscode then - require('my_lazy') + require('config.lazy') require('my_keymappings') - require('my_options') require('my_autocommands') + require('config.options') end diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..0d36981 --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,14 @@ +local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + 'git', + 'clone', + '--filter=blob:none', + '--single-branch', + 'https://github.com/folke/lazy.nvim.git', + lazypath, + }) +end +vim.opt.runtimepath:prepend(lazypath) + +require('lazy').setup('plugins', {}) diff --git a/lua/my_options.lua b/lua/config/options.lua similarity index 97% rename from lua/my_options.lua rename to lua/config/options.lua index dc33c6b..ec3c295 100644 --- a/lua/my_options.lua +++ b/lua/config/options.lua @@ -1,62 +1,62 @@ -vim.cmd('filetype plugin indent on') -vim.cmd('language en_US.utf-8') - -local opt = vim.opt -local indent = 2 -opt.termguicolors = true -- Enable colors in terminal -opt.hlsearch = true --Set highlight on search -opt.number = true --Make line numbers default -opt.relativenumber = false --Make relative number default -opt.mouse = 'a' --Enable mouse mode -opt.breakindent = true --Enable break indent -opt.undofile = true --Save undo history -opt.ignorecase = true --Case insensitive searching unless /C or capital in search -opt.smartcase = true -- Smart case -opt.updatetime = 300 --Decrease update time -opt.signcolumn = 'yes' -- Always show sign column -opt.clipboard = 'unnamed,unnamedplus' -- Access system clipboard -opt.timeoutlen = 300 -- Time in milliseconds to wait for a mapped sequence to complete. -opt.ttimeoutlen = 10 -opt.showmode = false -- Do not need to show the mode. We use the statusline instead. -opt.scrolloff = 999 -- Lines of context -opt.joinspaces = false -- No double spaces with join after a dot -opt.showmatch = true -- Show matching braces -opt.wrap = true -- When on, lines longer than the width of the window will wrap and displaying continues on the next line -opt.list = true -opt.hidden= true -opt.scrolloff= 4 -opt.shiftround= true -opt.relativenumber= false -opt.splitbelow= true -opt.splitright= true -opt.wildmode= 'longest:full,full' -opt.splitbelow= true -opt.splitright= true -opt.shiftwidth = indent -opt.tabstop = indent -if vim.loop.os_uname().sysname == 'Linux' then - opt.guifont= 'JetBrainsMono Nerd Font Mono:h7' -else - opt.guifont= 'JetBrainsMonoNL NF:h9' -- https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/JetBrainsMono/NoLigatures/Regular/complete/JetBrains%20Mono%20NL%20Regular%20Nerd%20Font%20Complete%20Mono%20Windows%20Compatible.ttf -end -opt.swapfile= false -opt.backup= false -opt.spelllang= 'en,de' -opt.completeopt= 'menu,menuone,noselect' -opt.expandtab= true -opt.smartindent= true -opt.title = true -opt.titlestring = '%{getcwd()} - %t' - --- go to previous/next line with h,l,left arrow and right arrow --- when cursor reaches end/beginning of line --- opt.whichwrap:append('<>[]hl') - --- disable nvim intro -opt.shortmess:append('sI') - --- Treesitter based folding -opt.foldlevel = 20 -opt.foldmethod = 'expr' -opt.foldexpr = 'nvim_treesitter#foldexpr()' - + +vim.cmd('filetype plugin indent on') +vim.cmd('language en_US.utf-8') + +local opt = vim.opt +local indent = 2 +opt.termguicolors = true -- Enable colors in terminal +opt.hlsearch = true --Set highlight on search +opt.number = true --Make line numbers default +opt.relativenumber = false --Make relative number default +opt.mouse = 'a' --Enable mouse mode +opt.breakindent = true --Enable break indent +opt.undofile = true --Save undo history +opt.ignorecase = true --Case insensitive searching unless /C or capital in search +opt.smartcase = true -- Smart case +opt.updatetime = 300 --Decrease update time +opt.signcolumn = 'yes' -- Always show sign column +opt.clipboard = 'unnamed,unnamedplus' -- Access system clipboard +opt.timeoutlen = 300 -- Time in milliseconds to wait for a mapped sequence to complete. +opt.ttimeoutlen = 10 +opt.showmode = false -- Do not need to show the mode. We use the statusline instead. +opt.scrolloff = 999 -- Lines of context +opt.joinspaces = false -- No double spaces with join after a dot +opt.showmatch = true -- Show matching braces +opt.wrap = true -- When on, lines longer than the width of the window will wrap and displaying continues on the next line +opt.list = true +opt.hidden= true +opt.scrolloff= 4 +opt.shiftround= true +opt.relativenumber= false +opt.splitbelow= true +opt.splitright= true +opt.wildmode= 'longest:full,full' +opt.splitbelow= true +opt.splitright= true +opt.shiftwidth = indent +opt.tabstop = indent +if vim.loop.os_uname().sysname == 'Linux' then + opt.guifont= 'JetBrainsMono Nerd Font Mono:h7' +else + opt.guifont= 'JetBrainsMonoNL NF:h9' -- https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/JetBrainsMono/NoLigatures/Regular/complete/JetBrains%20Mono%20NL%20Regular%20Nerd%20Font%20Complete%20Mono%20Windows%20Compatible.ttf +end +opt.swapfile= false +opt.backup= false +opt.spelllang= 'en,de' +opt.completeopt= 'menu,menuone,noselect' +opt.expandtab= true +opt.smartindent= true +opt.title = true +opt.titlestring = '%{getcwd()} - %t' + +-- go to previous/next line with h,l,left arrow and right arrow +-- when cursor reaches end/beginning of line +-- opt.whichwrap:append('<>[]hl') + +-- disable nvim intro +opt.shortmess:append('sI') + +-- Treesitter based folding +opt.foldlevel = 20 +opt.foldmethod = 'expr' +opt.foldexpr = 'nvim_treesitter#foldexpr()' diff --git a/lua/my_plugins.lua b/lua/my_plugins.lua deleted file mode 100644 index 9a62fc3..0000000 --- a/lua/my_plugins.lua +++ /dev/null @@ -1,282 +0,0 @@ -vim.cmd([[ - augroup packer_user_config - autocmd! - autocmd BufWritePost my_plugins.lua source | PackerCompile - augroup end -]]) - -local fn = vim.fn -local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' -if fn.empty(fn.glob(install_path)) > 0 then - packer_bootstrap = fn.system({ - 'git', - 'clone', - '--depth', - '1', - 'https://github.com/wbthomason/packer.nvim', - install_path, - }) -end -vim.api.nvim_command('packadd packer.nvim') - -local function get_setup(name) - return string.format('require("setup/%s")', name) -end - -local packerUtil = require('packer.util') -require('packer').init({ - snapshot_path = packerUtil.join_paths(vim.fn.stdpath('config'), 'snapshots'), - display = { - open_fn = require('packer.util').float, - }, -}) - -return require('packer').startup(function() - -- Packer can manage itself as an optional plugin - use({ 'wbthomason/packer.nvim' }) - use({ - 'nvim-treesitter/nvim-treesitter', - run = ':TSUpdate', - config = get_setup('treesitter'), - }) - use({ - 'nvim-telescope/telescope.nvim', - requires = { - { 'nvim-lua/popup.nvim' }, - { 'nvim-lua/plenary.nvim' }, - { 'kyazdani42/nvim-web-devicons' }, - { 'nvim-telescope/telescope-fzf-native.nvim', - run = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -G Ninja && cmake --build build --config Release && cmake --install build --prefix build' }, - }, - config = get_setup('telescope'), - }) - use({ - 'sainnhe/gruvbox-material', - disable = true, - config = get_setup('my_gruvbox-material') - }) - use({ - 'luisiacc/gruvbox-baby', - disable = true, - config = get_setup('my_gruvbox-baby') - }) - use({ - 'ellisonleao/gruvbox.nvim', - disable = true, - config = get_setup('gruvbox'), - }) - use({ - 'eddyekofo94/gruvbox-flat.nvim', - disable = false, - config = get_setup('my_gruvbox_flat') - }) - use({ - 'lukas-reineke/indent-blankline.nvim', - requires = { - 'nvim-treesitter/nvim-treesitter', - }, - config = get_setup('indent_blankline'), - }) - use({ 'nvim-lua/plenary.nvim' }) - use({ - 'lewis6991/gitsigns.nvim', - config = get_setup('gitsigns'), - }) - use({ - 'kyazdani42/nvim-tree.lua', - requires = 'kyazdani42/nvim-web-devicons', - config = get_setup('nvim-tree'), - disable = true, - }) - use({ - 'numToStr/Comment.nvim', - config = get_setup('comment'), - }) - use({ - 'hrsh7th/nvim-cmp', - requires = { - { 'hrsh7th/cmp-buffer', after = 'nvim-cmp' }, - { 'hrsh7th/cmp-nvim-lsp', after = 'nvim-cmp' }, - { 'L3MON4D3/LuaSnip', after = 'nvim-cmp' }, - { 'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp' }, - { 'hrsh7th/cmp-nvim-lua', after = 'nvim-cmp' }, - { 'octaltree/cmp-look', after = 'nvim-cmp' }, - { 'hrsh7th/cmp-path', after = 'nvim-cmp' }, - { 'hrsh7th/cmp-calc', after = 'nvim-cmp' }, - { 'f3fora/cmp-spell', after = 'nvim-cmp' }, - { 'hrsh7th/cmp-emoji', after = 'nvim-cmp' }, - { 'hrsh7th/cmp-cmdline', after = 'nvim-cmp' }, - { 'dmitmel/cmp-cmdline-history', after = 'nvim-cmp' }, - { 'ray-x/cmp-treesitter', after = 'nvim-cmp' }, - { 'hrsh7th/cmp-nvim-lsp-signature-help', after = 'nvim-cmp' }, - { 'p00f/clangd_extensions.nvim' }, - }, - config = get_setup('my_cmp'), - module = { "nvim-cmp", "cmp" }, - event = "InsertEnter *", - }) - use({ - 'L3MON4D3/LuaSnip', - config = get_setup('luasnip'), - module = { "luasnip", "LuaSnip" } - }) - use({ 'rafamadriz/friendly-snippets' }) - use({ 'onsails/lspkind-nvim' }) - use({ - 'hoob3rt/lualine.nvim', - requires = { 'kyazdani42/nvim-web-devicons', opt = true }, - config = get_setup('lualine'), - }) - use({ - 'ahmedkhalf/project.nvim', - config = get_setup('project'), - }) - use({ 'p00f/nvim-ts-rainbow', - requires = 'nvim-treesitter/nvim-treesitter', - }) - use({ - 'windwp/nvim-autopairs', - config = get_setup('nvim-autopairs'), - }) - use({ 'ray-x/lsp_signature.nvim' }) - use({ - 'neovim/nvim-lspconfig', - requires = { - 'williamboman/mason.nvim', - 'williamboman/mason-lspconfig.nvim', - 'p00f/clangd_extensions.nvim', - }, - config = get_setup('my_lspconfig'), - module_pattern = { "lspconfig.*" }, - event = { "InsertEnter", "CursorMoved" }, - }) - use({ - 'jose-elias-alvarez/null-ls.nvim', - requires = { 'nvim-lua/plenary.nvim' }, - }) - use({ - 'danymat/neogen', - requires = 'nvim-treesitter/nvim-treesitter', - config = get_setup('neogen'), - opt = true, - module = 'neogen' - }) - use({ 'stevearc/dressing.nvim' }) - use({ - 'nvim-neo-tree/neo-tree.nvim', - requires = { - 'nvim-lua/plenary.nvim', - 'kyazdani42/nvim-web-devicons', - { 'MunifTanjim/nui.nvim', module = 'nui' }, - }, - config = get_setup('neo-tree'), - opt = true, - keys = { - { 'n', '\\' } - } - }) - use({ - 'akinsho/toggleterm.nvim', - config = get_setup('toggleterm'), - }) - use({ - 'mrjones2014/legendary.nvim', - config = get_setup('my_legendary') - }) - use({ - 'gbprod/yanky.nvim', - config = get_setup('yanky'), - keys = { - { 'n', '' }, - { 'n', '' } - }, - requires = { - 'nvim-telescope/telescope.nvim' - } - }) - use { - 'ldelossa/litee.nvim', - disable = true, - requires = { - 'ldelossa/litee-calltree.nvim', - 'ldelossa/litee-symboltree.nvim', - 'ldelossa/gh.nvim' - }, - config = get_setup('my_litee') - } - use { - 'stevearc/aerial.nvim', - requires = { - 'nvim-telescope/telescope.nvim' - }, - config = get_setup('aerial'), - opt = true, - module = 'aerial', - keys = { - { 'n', 's' } - } - } - use { - 'ggandor/leap.nvim', - requires = { 'tpope/vim-repeat' }, - config = get_setup('my_leap') - } - use { - 'mfussenegger/nvim-dap', - requires = { - 'mfussenegger/nvim-dap-python', - { - 'theHamsta/nvim-dap-virtual-text', - module = 'nvim-dap-virtual-text' - }, - { - 'nvim-telescope/telescope-dap.nvim', - module = 'telescope._extensions.dap', - requires = 'telescope.nvim', - }, - { - 'rcarriga/nvim-dap-ui', - module = 'dapui' - }, - { - 'rcarriga/cmp-dap', - module = 'cmp_dap' - }, - }, - keys = { - { 'n', '' }, - { 'n', '' }, - { 'n', '' }, - { 'n', '' }, - { 'n', '' }, - { 'n', '' }, - { 'n', '' }, - { 'n', '' } - }, - -- module = 'dap', - config = function() - require('setup/my_dap') - end, - opt = true, - } - use { - 'sindrets/diffview.nvim', - requires = 'nvim-lua/plenary.nvim', - config = get_setup('my_diffview'), - opt = true, - cmd = 'DiffviewOpen', - module = { 'diffview', 'diffview.actions' } - } - use { - 'stevearc/overseer.nvim', - config = get_setup('my_overseer'), - opt = true, - keys = { - { 'n', '' } - }, - module = 'overseer' - } - if packer_bootstrap then - require('packer').sync() - end -end) diff --git a/lua/my_lazy.lua b/lua/plugins/init.lua similarity index 75% rename from lua/my_lazy.lua rename to lua/plugins/init.lua index fba444b..10e92d4 100644 --- a/lua/my_lazy.lua +++ b/lua/plugins/init.lua @@ -1,18 +1,4 @@ -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "--single-branch", - "https://github.com/folke/lazy.nvim.git", - lazypath, - }) -end -vim.opt.runtimepath:prepend(lazypath) - - -local plugins = { +return { { 'mrjones2014/legendary.nvim', config = function() @@ -35,40 +21,11 @@ local plugins = { }, keys = { 'p', 'i' } }, - { - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - config = function() - require('setup/treesitter') - end - }, { 'p00f/nvim-ts-rainbow', dependencies = 'nvim-treesitter/nvim-treesitter', event = 'VeryLazy' }, - { - 'nvim-telescope/telescope.nvim', - dependencies = { - 'nvim-lua/plenary.nvim', - 'kyazdani42/nvim-web-devicons', - { - 'nvim-telescope/telescope-fzf-native.nvim', - 'nvim-telescope/telescope-ui-select.nvim', - build = { - 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -G Ninja', -- On windows add -DCMAKE_C_FLAGS="-target x86_64-w64-mingw32" - 'cmake --build build --config Release', - 'cmake --install build --prefix build' - }, - config = function() - require('telescope').load_extension('fzf') - end - }, - }, - config = function() - require('setup/telescope') - end - }, { 'ahmedkhalf/project.nvim', config = function() @@ -252,5 +209,3 @@ local plugins = { }, } } -local opts = {} -require("lazy").setup(plugins, opts) diff --git a/lua/plugins/neotree.lua b/lua/plugins/neotree.lua new file mode 100644 index 0000000..d0580c8 --- /dev/null +++ b/lua/plugins/neotree.lua @@ -0,0 +1,62 @@ +return { + 'nvim-neo-tree/neo-tree.nvim', + cmd = 'Neotree', + keys = { + { '\\', 'Neotree reveal', desc = 'NeoTree' }, + }, + dependencies = { + 'nvim-lua/plenary.nvim', + -- 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended + 'kyazdani42/nvim-web-devicons', + 'MunifTanjim/nui.nvim', + }, + config = { + window = { -- see https://github.com/MunifTanjim/nui.nvim/tree/main/lua/nui/popup for + -- possible options. These can also be functions that return these options. + position = 'float', -- left, right, float, current + width = 40, -- applies to left and right positions + popup = { -- settings that apply to float position only + size = { + height = '80%', + width = '50%', + }, + position = '50%', -- 50% means center it + -- you can also specify border here, if you want a different setting from + -- the global popup_border_style. + }, + enable_git_status = false, + -- Mappings for tree window. See `:h nep-tree-mappings` for a list of built-in commands. + -- You can also create your own commands by providing a function instead of a string. + mappings = { + [''] = 'toggle_node', + ['<2-LeftMouse>'] = 'open', + [''] = 'open', + ['s'] = 'open_split', + ['v'] = 'open_vsplit', + ['C'] = 'close_node', + ['z'] = 'close_all_nodes', + ['R'] = 'refresh', + ['a'] = 'add', + ['A'] = 'add_directory', + ['d'] = 'delete', + ['r'] = 'rename', + ['y'] = 'copy_to_clipboard', + ['x'] = 'cut_to_clipboard', + ['p'] = 'paste_from_clipboard', + ['c'] = 'copy', -- takes text input for destination + ['m'] = 'move', -- takes text input for destination + ['q'] = 'close_window', + }, + }, + filesystem = { + filtered_items = { + hide_dotfiles = false, + hide_gitignored = false, + }, + }, + source_selector = { + winbar = true, + statusline = false + } + } +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..4f40d42 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,161 @@ +return { + 'nvim-telescope/telescope.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + 'kyazdani42/nvim-web-devicons', + { + 'nvim-telescope/telescope-fzf-native.nvim', + 'nvim-telescope/telescope-ui-select.nvim', + build = { + 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -G Ninja', -- On windows add -DCMAKE_C_FLAGS="-target x86_64-w64-mingw32" + 'cmake --build build --config Release', + 'cmake --install build --prefix build' + }, + config = function() + end + }, + }, + cmd = { "Telescope" }, + keys = { + { + 'f', + function() + require("telescope.builtin").find_files({ no_ignore = true }) + end, + desc = 'Find file', + }, + { + 'g', + function() + Project_files() + end, + desc = 'Find git files', + }, + { + 'o', + function() + require("telescope.builtin").oldfiles() + end, + desc = 'Find old files', + }, + { + 'h', + function() + require("telescope.builtin").command_history() + end, + desc = 'Open command history', + }, + { + 'b', + function() + require("telescope.builtin").buffers() + end, + desc = 'Select buffer', + }, + { + 'q', + function() + require("telescope.builtin").quickfix() + end, + desc = 'Quickfix list with telescope', + }, + { + 'l', + function() + require("telescope.builtin").live_grep() + end, + desc = 'Search in project', + }, + { + 'j', + function() + require("telescope.builtin").jumplist() + end, + desc = 'Open jumplist', + }, + { + '', + function() + require("telescope.builtin").current_buffer_fuzzy_find() + end, + desc = 'Find in buffer', + }, + { + 'd', + function() + require("telescope.builtin").grep_string() + end, + desc = 'Find in workspace', + } + }, + config = function() + local actions = require('telescope.actions') + + local mappingTab = { + i = { + [''] = actions.select_tab, + [''] = actions.select_default, + }, + } + + require('telescope').setup({ + defaults = { + mappings = { + i = { + [''] = actions.select_default + actions.center, + [''] = actions.send_selected_to_loclist, + [''] = actions.smart_send_to_qflist, + }, + }, + }, + pickers = { + -- Your special builtin config goes in here + buffers = { + sort_lastused = true, + theme = 'ivy', + mappings = { + i = { + [''] = actions.delete_buffer, + [''] = actions.select_default, + }, + n = { + [''] = actions.delete_buffer, + }, + }, + }, + find_files = { + theme = 'ivy', + previewer = false, + }, + oldfiles = { + theme = 'ivy', + }, + git_files = { + theme = 'ivy', + previewer = false, + }, + lsp_references = { + show_line = false; + include_declaration = false, + }, + lsp_dynamic_workspace_symbols = {}, + }, + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown { + } + } + } + }) + + require("telescope").load_extension("ui-select") + + Project_files = function() + local opts = {} -- define here if you want to define something + local ok = pcall(require "telescope.builtin".git_files, opts) + if not ok then require "telescope.builtin".find_files(opts) end + end + + require('telescope').load_extension('fzf') + end +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..3b916e4 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,50 @@ +return { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + config = function() + require('nvim-treesitter.configs').setup({ + ensure_installed = 'all', + highlight = { + enable = true + }, + rainbow = { + enable = true, + extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean + max_file_lines = nil, -- Do not enable for files with more than n lines, int + -- colors = {}, -- table of hex strings + -- termcolors = {} -- table of colour name strings + }, + indent = { + enable = false -- maybe buggy + }, + textobjects = { + select = { + enable = true, + + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + }, + }, + lsp_interop = { + enable = true, + border = 'none', + peek_definition_code = { + ["df"] = "@function.outer", + ["dF"] = "@class.outer", + }, + }, + }, + }) + local parser = require('nvim-treesitter.parsers').filetype_to_parsername + parser.groovy = 'java' -- the someft filetype will use the python parser and queries. + require("nvim-treesitter.install").prefer_git = true + end +} + diff --git a/lua/setup/neo-tree.lua b/lua/setup/neo-tree.lua deleted file mode 100644 index 309ed03..0000000 --- a/lua/setup/neo-tree.lua +++ /dev/null @@ -1,56 +0,0 @@ --- If you want icons for diagnostic errors, you'll need to define them somewhere: -vim.fn.sign_define('DiagnosticSignError', { text = ' ', texthl = 'DiagnosticSignError' }) -vim.fn.sign_define('DiagnosticSignWarn', { text = ' ', texthl = 'DiagnosticSignWarn' }) -vim.fn.sign_define('DiagnosticSignInfo', { text = ' ', texthl = 'DiagnosticSignInfo' }) -vim.fn.sign_define('DiagnosticSignHint', { text = '', texthl = 'DiagnosticSignHint' }) - -require('neo-tree').setup({ - window = { -- see https://github.com/MunifTanjim/nui.nvim/tree/main/lua/nui/popup for - -- possible options. These can also be functions that return these options. - position = 'float', -- left, right, float, current - width = 40, -- applies to left and right positions - popup = { -- settings that apply to float position only - size = { - height = '80%', - width = '50%', - }, - position = '50%', -- 50% means center it - -- you can also specify border here, if you want a different setting from - -- the global popup_border_style. - }, - enable_git_status = false, - -- Mappings for tree window. See `:h nep-tree-mappings` for a list of built-in commands. - -- You can also create your own commands by providing a function instead of a string. - mappings = { - [''] = 'toggle_node', - ['<2-LeftMouse>'] = 'open', - [''] = 'open', - ['s'] = 'open_split', - ['v'] = 'open_vsplit', - ['C'] = 'close_node', - ['z'] = 'close_all_nodes', - ['R'] = 'refresh', - ['a'] = 'add', - ['A'] = 'add_directory', - ['d'] = 'delete', - ['r'] = 'rename', - ['y'] = 'copy_to_clipboard', - ['x'] = 'cut_to_clipboard', - ['p'] = 'paste_from_clipboard', - ['c'] = 'copy', -- takes text input for destination - ['m'] = 'move', -- takes text input for destination - ['q'] = 'close_window', - }, - }, - filesystem = { - filtered_items = { - hide_dotfiles = false, - hide_gitignored = false, - }, - }, - source_selector = { - winbar = true, - statusline = false - } -}) -vim.keymap.set('n', '\\', 'Neotree reveal') diff --git a/lua/setup/telescope.lua b/lua/setup/telescope.lua deleted file mode 100644 index 29bcf65..0000000 --- a/lua/setup/telescope.lua +++ /dev/null @@ -1,135 +0,0 @@ -local actions = require('telescope.actions') - -local mappingTab = { - i = { - [''] = actions.select_tab, - [''] = actions.select_default, - }, -} - -require('telescope').setup({ - defaults = { - mappings = { - i = { - [''] = actions.select_default + actions.center, - [''] = actions.send_selected_to_loclist, - [''] = actions.smart_send_to_qflist, - }, - }, - }, - pickers = { - -- Your special builtin config goes in here - buffers = { - sort_lastused = true, - theme = 'ivy', - mappings = { - i = { - [''] = actions.delete_buffer, - [''] = actions.select_default, - }, - n = { - [''] = actions.delete_buffer, - }, - }, - }, - find_files = { - theme = 'ivy', - previewer = false, - }, - oldfiles = { - theme = 'ivy', - }, - git_files = { - theme = 'ivy', - previewer = false, - }, - lsp_references = { - show_line = false; - include_declaration = false, - }, - lsp_dynamic_workspace_symbols = {}, - }, - extensions = { - ["ui-select"] = { - require("telescope.themes").get_dropdown { - } - } - } -}) - -require("telescope").load_extension("ui-select") - -Project_files = function() - local opts = {} -- define here if you want to define something - local ok = pcall(require "telescope.builtin".git_files, opts) - if not ok then require "telescope.builtin".find_files(opts) end -end - -require('legendary').keymaps( - { - { - 'f', - ':lua require("telescope.builtin").find_files({no_ignore=true})', - description = 'Find file', - }, - { - 'g', - ':lua Project_files()', - description = 'Find git files', - }, - { - 'o', - ':Telescope oldfiles', - description = 'Find old files', - }, - { - 'h', - ':Telescope command_history', - description = 'Open command history', - }, - { - 'b', - ':Telescope buffers', - description = 'Select buffer', - }, - { - 'q', - ':Telescope quickfix', - description = 'Quickfix list with telescope', - }, - { - 'l', - ':Telescope live_grep', - description = 'Search in project', - }, - { - '', - ':Telescope neoclip', - description = 'Open clipboard history', - }, - { - 'j', - ':Telescope jumplist', - description = 'Open jumplist', - }, - { - '', - ':Telescope current_buffer_fuzzy_find', - description = 'Find in buffer', - }, - { - 'd', - ':Telescope grep_string', - description = 'Find in workspace', - } - } -) - -require('legendary').func( - { - function() - require('telescope.builtin').live_grep({ prompt_title = 'find string in open buffers...', grep_open_files = true }) - end, - description = 'Search in open files', - } -) diff --git a/lua/setup/treesitter.lua b/lua/setup/treesitter.lua deleted file mode 100644 index 771d4ea..0000000 --- a/lua/setup/treesitter.lua +++ /dev/null @@ -1,48 +0,0 @@ -local parser = require('nvim-treesitter.parsers').filetype_to_parsername -parser.groovy = 'java' -- the someft filetype will use the python parser and queries. - -require('nvim-treesitter.configs').setup({ - ensure_installed = all, - highlight = { - enable = true - }, - rainbow = { - enable = true, - extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean - max_file_lines = nil, -- Do not enable for files with more than n lines, int - -- colors = {}, -- table of hex strings - -- termcolors = {} -- table of colour name strings - }, - indent = { - enable = false -- maybe buggy - }, - textobjects = { - select = { - enable = true, - - -- Automatically jump forward to textobj, similar to targets.vim - lookahead = true, - - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - }, - }, - lsp_interop = { - enable = true, - border = 'none', - peek_definition_code = { - ["df"] = "@function.outer", - ["dF"] = "@class.outer", - }, - }, - }, -}) - -require("nvim-treesitter.install").prefer_git = true - --- local groovy_parser = require('nvim-treesitter.parsers').groovy --- groovy_parser.groovy = 'java' -- the someft filetype will use the python parser and queries. From ce61facff9cbedf10ad8d441cdd39d295ce48bf7 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 28 Dec 2022 14:29:23 +0100 Subject: [PATCH 23/38] more restructure --- lua/config/options.lua | 1 + lua/plugins/cmp.lua | 180 ++++++++++++++++++++++++ lua/plugins/comment.lua | 22 +++ lua/plugins/gitsigns.lua | 12 ++ lua/plugins/indent_blankline.lua | 20 +++ lua/plugins/init.lua | 96 +------------ lua/plugins/lspconfig.lua | 231 +++++++++++++++++++++++++++++++ lua/plugins/lualine.lua | 32 +++++ lua/plugins/nvim-ts-rainbow.lua | 5 + lua/plugins/project.lua | 12 ++ lua/plugins/telescope.lua | 28 ++-- lua/setup/comment.lua | 13 -- lua/setup/gitsigns.lua | 9 -- lua/setup/indent_blankline.lua | 12 -- lua/setup/lualine.lua | 29 ---- lua/setup/my_cmp.lua | 141 ------------------- lua/setup/my_lspconfig.lua | 218 ----------------------------- lua/setup/project.lua | 17 --- 18 files changed, 533 insertions(+), 545 deletions(-) create mode 100644 lua/plugins/cmp.lua create mode 100644 lua/plugins/comment.lua create mode 100644 lua/plugins/gitsigns.lua create mode 100644 lua/plugins/indent_blankline.lua create mode 100644 lua/plugins/lspconfig.lua create mode 100644 lua/plugins/lualine.lua create mode 100644 lua/plugins/nvim-ts-rainbow.lua create mode 100644 lua/plugins/project.lua delete mode 100644 lua/setup/comment.lua delete mode 100644 lua/setup/gitsigns.lua delete mode 100644 lua/setup/indent_blankline.lua delete mode 100644 lua/setup/lualine.lua delete mode 100644 lua/setup/my_cmp.lua delete mode 100644 lua/setup/my_lspconfig.lua delete mode 100644 lua/setup/project.lua diff --git a/lua/config/options.lua b/lua/config/options.lua index ec3c295..e2aa99f 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -48,6 +48,7 @@ opt.expandtab= true opt.smartindent= true opt.title = true opt.titlestring = '%{getcwd()} - %t' +opt.laststatus = 3 -- for lualine -- go to previous/next line with h,l,left arrow and right arrow -- when cursor reaches end/beginning of line diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..1994d04 --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,180 @@ +return { + 'hrsh7th/nvim-cmp', + dependencies = { + { 'onsails/lspkind-nvim' }, + { 'hrsh7th/cmp-buffer' }, + { 'hrsh7th/cmp-nvim-lsp' }, + { + 'L3MON4D3/LuaSnip', + config = function() + require('setup/luasnip') + end, + dependencies = + { + 'rafamadriz/friendly-snippets' + } + }, + { 'saadparwaiz1/cmp_luasnip' }, + { 'hrsh7th/cmp-nvim-lua' }, + { 'octaltree/cmp-look' }, + { 'hrsh7th/cmp-path' }, + { 'hrsh7th/cmp-calc' }, + { 'f3fora/cmp-spell' }, + { 'hrsh7th/cmp-emoji' }, + { 'hrsh7th/cmp-cmdline' }, + { 'dmitmel/cmp-cmdline-history' }, + { 'ray-x/cmp-treesitter' }, + { 'hrsh7th/cmp-nvim-lsp-signature-help' }, + { 'p00f/clangd_extensions.nvim' }, + { + 'windwp/nvim-autopairs', + config = function() + require('setup/nvim-autopairs') + end + }, + }, + config = function() + local cmp = require('cmp') + local luasnip = require('luasnip') + + local t = function(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) + end + + local check_back_space = function() + local col = vim.fn.col('.') - 1 + return col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') ~= nil + end + + cmp.setup({ + formatting = { + format = require('lspkind').cmp_format({ + mode = 'symbol_text', -- show only symbol annotations + maxwidth = 80, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) + }) + }, + mapping = { + [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c', 's' }), + [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c', 's' }), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }), + [''] = cmp.mapping(cmp.mapping.close(), { 'i', 'c', 's' }), + [''] = cmp.mapping({ + i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }), + c = cmp.mapping.confirm({ select = false }), + s = cmp.mapping.confirm({ select = false }), + }), + [''] = cmp.mapping(function(fallback) + if luasnip.expand_or_jumpable() then + vim.api.nvim_feedkeys(t('luasnip-expand-or-jump'), '', true) + else + fallback() + end + end, { + 'i', + 's', + }), + [''] = cmp.mapping(function(fallback) + if luasnip.jumpable(-1) then + vim.api.nvim_feedkeys(t('luasnip-jump-prev'), '', true) + else + fallback() + end + end, { + 'i', + 's', + }), + }, + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + sources = { + { name = 'luasnip', priority = 8 }, + { name = 'nvim_lsp', priority = 7 }, + { name = 'nvim_lsp_signature_help', priority = 7 }, + { name = 'treesitter', priority = 6 }, + { name = 'buffer', priority = 5, + option = { + get_bufnrs = function() + local bufs = {} + for _, win in ipairs(vim.api.nvim_list_wins()) do + bufs[vim.api.nvim_win_get_buf(win)] = true + end + return vim.tbl_keys(bufs) + end + } + }, + -- { name = 'nvim_lua' }, + -- { name = 'look' }, + -- { name = 'path' }, + -- { name = 'cmp_tabnine' }, + -- { name = 'calc' }, + -- { name = 'spell' }, + -- { name = 'emoji' }, + }, + enabled = function() + return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt" + or vim.api.nvim_buf_get_option(0, 'filetype') == 'dap-repl' + or vim.api.nvim_buf_get_option(0, 'filetype') == 'dapui_watches' + or vim.api.nvim_buf_get_option(0, 'filetype') == 'dapui_hover' + end, + completion = { completeopt = 'menu,menuone,noinsert, noselect' }, + window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + sorting = { + comparators = { + require('clangd_extensions.cmp_scores'), + cmp.config.compare.locality, + -- cmp.config.compare.recently_used, + -- -- cmp.config.compare.offset, + -- cmp.config.compare.exact, + -- cmp.config.compare.recently_used, + -- cmp.config.compare.kind, + -- cmp.config.compare.sort_text, + -- cmp.config.compare.length, + -- cmp.config.compare.order, + }, + }, + -- experimental = { native_menu = true } + }) + + -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline('/', { + sources = { + { name = 'buffer' }, + }, + }) + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(':', { + sources = { + { name = 'cmdline' }, + { name = 'cmdline_history' }, + { name = 'path' }, + { name = 'buffer' }, + }, + }) + + require('cmp').setup.filetype({ 'dap-repl', 'dapui_watches', 'dapui_hover' }, { + sources = { + { name = 'dap' }, + }, + }) + + -- Autopairs + --require("nvim-autopairs.completion.cmp").setup({ + -- map_cr = true, + -- map_complete = true, + -- auto_select = true + --}) + local cmp_autopairs = require('nvim-autopairs.completion.cmp') + cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) + end, + event = { 'InsertEnter', 'CmdLineEnter' }, +} diff --git a/lua/plugins/comment.lua b/lua/plugins/comment.lua new file mode 100644 index 0000000..c1eedc9 --- /dev/null +++ b/lua/plugins/comment.lua @@ -0,0 +1,22 @@ +return { + 'numToStr/Comment.nvim', + config = function() + require('Comment').setup({ + mappings = false, + }) + end, + keys = { + { + '', + '(comment_toggle_linewise_current)', + desc= 'Toggle comment' + }, + + { + '', + '(comment_toggle_linewise_visual)gv', + mode = 'v', + desc= 'Toggle comment' + } + } +} diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..27f6339 --- /dev/null +++ b/lua/plugins/gitsigns.lua @@ -0,0 +1,12 @@ +return { + 'lewis6991/gitsigns.nvim', + config = { + current_line_blame = false, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + }, + } +} diff --git a/lua/plugins/indent_blankline.lua b/lua/plugins/indent_blankline.lua new file mode 100644 index 0000000..c7c41d0 --- /dev/null +++ b/lua/plugins/indent_blankline.lua @@ -0,0 +1,20 @@ +return { + 'lukas-reineke/indent-blankline.nvim', + dependencies = { + 'nvim-treesitter/nvim-treesitter', + }, + config = function() + local opt = vim.opt -- to set options + opt.listchars:append('eol:↴') + -- opt.listchars:append("space: ") + opt.listchars:append('trail: ') + opt.listchars:append('tab:→ ') + + require('indent_blankline').setup({ + show_end_of_line = true, + use_treesitter = true, + show_current_context = true, + context_patterns = { 'class', 'function', 'method', 'block', '^if', '^for', '^while' }, + }) + end, +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 10e92d4..c039499 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -21,108 +21,14 @@ return { }, keys = { 'p', 'i' } }, - { - 'p00f/nvim-ts-rainbow', - dependencies = 'nvim-treesitter/nvim-treesitter', - event = 'VeryLazy' - }, - { - 'ahmedkhalf/project.nvim', - config = function() - require('setup/project') - end, - event = 'VeryLazy' - }, { 'eddyekofo94/gruvbox-flat.nvim', disable = false, + priority = 1000, config = function() require('setup/my_gruvbox_flat') end }, - { - 'lukas-reineke/indent-blankline.nvim', - dependencies = { - 'nvim-treesitter/nvim-treesitter', - }, - config = function() - require('setup/indent_blankline') - end, - }, - { - 'lewis6991/gitsigns.nvim', - config = function() - require('setup/gitsigns') - end, - }, - { - 'numToStr/Comment.nvim', - config = function() - require('setup/comment') - end, - keys = '' - }, - { - 'hoob3rt/lualine.nvim', - dependencies = { 'kyazdani42/nvim-web-devicons' }, - config = function() - require('setup/lualine') - end, - }, - { - 'hrsh7th/nvim-cmp', - dependencies = { - { 'onsails/lspkind-nvim' }, - { 'hrsh7th/cmp-buffer' }, - { 'hrsh7th/cmp-nvim-lsp' }, - { - 'L3MON4D3/LuaSnip', - config = function() - require('setup/luasnip') - end, - dependencies = - { - 'rafamadriz/friendly-snippets' - } - }, - { 'saadparwaiz1/cmp_luasnip' }, - { 'hrsh7th/cmp-nvim-lua' }, - { 'octaltree/cmp-look' }, - { 'hrsh7th/cmp-path' }, - { 'hrsh7th/cmp-calc' }, - { 'f3fora/cmp-spell' }, - { 'hrsh7th/cmp-emoji' }, - { 'hrsh7th/cmp-cmdline' }, - { 'dmitmel/cmp-cmdline-history' }, - { 'ray-x/cmp-treesitter' }, - { 'hrsh7th/cmp-nvim-lsp-signature-help' }, - { 'p00f/clangd_extensions.nvim' }, - { - 'windwp/nvim-autopairs', - config = function() - require('setup/nvim-autopairs') - end - }, - }, - config = function() - require('setup/my_cmp') - end, - event = { 'InsertEnter', 'CmdLineEnter' }, - }, - { - 'neovim/nvim-lspconfig', - dependencies = { - 'williamboman/mason.nvim', - 'williamboman/mason-lspconfig.nvim', - 'p00f/clangd_extensions.nvim', - 'jose-elias-alvarez/null-ls.nvim', - 'ray-x/lsp_signature.nvim', - }, - config = function() - require('setup/my_lspconfig') - end, - event = 'VeryLazy' - }, { 'akinsho/toggleterm.nvim', config = function() diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua new file mode 100644 index 0000000..51f3dde --- /dev/null +++ b/lua/plugins/lspconfig.lua @@ -0,0 +1,231 @@ +return { + 'neovim/nvim-lspconfig', + dependencies = { + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + 'p00f/clangd_extensions.nvim', + 'jose-elias-alvarez/null-ls.nvim', + 'ray-x/lsp_signature.nvim', + }, + config = function() + require('mason').setup() + require('mason-lspconfig').setup({ + automatic_installation = false, + }) + + local capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) + + OpenDiagFloat = function() + for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do + if vim.api.nvim_win_get_config(winid).zindex then + return + end + end + vim.diagnostic.open_float({ focusable = false, width = 80 }) + end + + local on_attach = function(client, bufnr) + local function buf_set_option(...) + vim.api.nvim_buf_set_option(bufnr, ...) + end + + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + vim.api.nvim_buf_set_option(0, 'formatexpr', 'v:lua.vim.lsp.formatexpr()') + + -- Mappings. + local opts = { noremap = true, silent = false, buffer = bufnr } + vim.keymap.set('n', ',', vim.diagnostic.goto_prev, opts) + vim.keymap.set('n', ';', vim.diagnostic.goto_next, opts) + vim.keymap.set('n', 'a', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'e', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'h', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'c', vim.lsp.buf.outgoing_calls, opts) + vim.keymap.set('n', 'C', vim.lsp.buf.incoming_calls, opts) + vim.keymap.set('n', 'm', vim.lsp.buf.rename, opts) + local tele_builtins = require('telescope.builtin') + vim.keymap.set('n', '', tele_builtins.lsp_dynamic_workspace_symbols, opts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', 'r', tele_builtins.lsp_references, opts) + vim.keymap.set('n', '', 'Telescope aerial', opts) + vim.keymap.set('n', 'v', function() tele_builtins.diagnostics({ bufnr = 0 }) end, opts) + vim.keymap.set('n', '', 'ClangdSwitchSourceHeader', opts) + + vim.cmd([[autocmd CursorHold lua OpenDiagFloat()]]) + + -- Set some keybinds conditional on server capabilities + if client.server_capabilities.documentFormattingProvider then + vim.keymap.set('n', 'f', vim.lsp.buf.format, opts) + end + if client.server_capabilities.documentRangeFormattingProvider then + vim.keymap.set('x', 'f', vim.lsp.buf.format, opts) + end + + -- Set autocommands conditional on server_capabilities + if client.server_capabilities.documentHighlightProvider then + vim.api.nvim_set_hl( + 0, + "LspReferenceText", + { bold = true, + ctermbg = 'red', + bg = "#5a524c" } + ) + vim.api.nvim_set_hl( + 0, + "LspReferenceRead", + { bold = true, + ctermbg = 'red', + bg = 'DarkGreen' } + ) + vim.api.nvim_set_hl( + 0, + "LspReferenceWrite", + { bold = true, + ctermbg = 'red', + bg = 'DarkRed' } + ) + vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true }) + vim.api.nvim_clear_autocmds { buffer = bufnr, group = "lsp_document_highlight" } + vim.api.nvim_create_autocmd("CursorHold", { + callback = vim.lsp.buf.document_highlight, + buffer = bufnr, + group = "lsp_document_highlight", + desc = "Document Highlight", + }) + vim.api.nvim_create_autocmd("CursorMoved", { + callback = vim.lsp.buf.clear_references, + buffer = bufnr, + group = "lsp_document_highlight", + desc = "Clear All the References", + }) + end + + require('lsp_signature').on_attach({ + bind = true, -- This is mandatory, otherwise border config won't get registered. + handler_opts = { + border = 'single', + }, + hi_parameter = 'IncSearch', + }, bufnr) + end + + require('lspconfig')['pyright'].setup { + capabilities = capabilities, + on_attach = on_attach, + } + + require('lspconfig')['groovyls'].setup { + capabilities = capabilities, + on_attach = on_attach, + } + + require('lspconfig')['cmake'].setup { + capabilities = capabilities, + on_attach = on_attach, + } + + local clangd_capabilities = capabilities + clangd_capabilities.textDocument.semanticHighlighting = true + clangd_capabilities.offsetEncoding = { "utf-16" } + require("clangd_extensions").setup { + server = { + capabilities = clangd_capabilities, + on_attach = on_attach, + cmd = { 'clangd', '--compile-commands-dir=build_nvim' }, + root_dir = require('lspconfig').util.root_pattern( + '.clangd', + '.clang-tidy', + '.clang-format', + 'compile_commands.json', + 'compile_flags.txt', + 'configure.ac', + '.git', + 'build_nvim' + ) + }, + extensions = + { + inlay_hints = { + -- Only show inlay hints for the current line + only_current_line = true, + } + } + + } + -- require('clangd_extensions').setup({ + -- server = { + -- on_attach = on_attach, + -- capabilities = capabilities, + -- cmd = { 'clangd', '--compile-commands-dir=build_nvim' }, + -- }, + -- }) + + require('lspconfig')['jsonls'].setup { + capabilities = capabilities, + on_attach = on_attach, + } + + local lua_rtp = vim.split(package.path, ';') + table.insert(lua_rtp, 'lua/?.lua') + table.insert(lua_rtp, 'lua/?/init.lua') + require('lspconfig').sumneko_lua.setup { + capabilities = capabilities, + on_attach = on_attach, + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Setup your lua path + path = lua_rtp, + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { 'vim', 'use' }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file('', true), + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false, + }, + }, + } + } + + require('lspconfig')['dockerls'].setup { + capabilities = capabilities, + on_attach = on_attach, + } + + require('lspconfig')['yamlls'].setup { + capabilities = capabilities, + on_attach = on_attach, + settings = { + yaml = { + validate = true + } + } + } + + local null_ls = require('null-ls') + null_ls.setup({ + sources = { + null_ls.builtins.code_actions.gitsigns, + null_ls.builtins.formatting.autopep8, + null_ls.builtins.formatting.prettier, + null_ls.builtins.diagnostics.flake8, + null_ls.builtins.formatting.isort, + null_ls.builtins.formatting.cmake_format, + }, + on_attach = on_attach, + capabilities = capabilities, + }) + + vim.diagnostic.config({ virtual_text = false }) + end, + event = 'VeryLazy' +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..00731c2 --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,32 @@ +return { + 'hoob3rt/lualine.nvim', + dependencies = { 'kyazdani42/nvim-web-devicons' }, + config = { + options = { + theme = 'gruvbox-flat', + disabled_filetypes = { + statusline = {}, + winbar = { 'dap-repl', 'dapui_console' }, + }, + }, + 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/plugins/nvim-ts-rainbow.lua b/lua/plugins/nvim-ts-rainbow.lua new file mode 100644 index 0000000..2c27644 --- /dev/null +++ b/lua/plugins/nvim-ts-rainbow.lua @@ -0,0 +1,5 @@ +return { + 'p00f/nvim-ts-rainbow', + dependencies = 'nvim-treesitter/nvim-treesitter', + event = 'VeryLazy' +} diff --git a/lua/plugins/project.lua b/lua/plugins/project.lua new file mode 100644 index 0000000..5330c8b --- /dev/null +++ b/lua/plugins/project.lua @@ -0,0 +1,12 @@ +return { + 'ahmedkhalf/project.nvim', + config = function() + require("project_nvim").setup( + { + silent_chdir = true, + ignore_lsp = { 'null-ls', 'cmake' }, + patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json", "build_nvim", "real_path.txt" }, + }) + end, + -- event = 'BufReadPre' +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 4f40d42..b9e78a0 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -5,15 +5,14 @@ return { 'kyazdani42/nvim-web-devicons', { 'nvim-telescope/telescope-fzf-native.nvim', - 'nvim-telescope/telescope-ui-select.nvim', build = { 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -G Ninja', -- On windows add -DCMAKE_C_FLAGS="-target x86_64-w64-mingw32" 'cmake --build build --config Release', 'cmake --install build --prefix build' }, - config = function() - end }, + 'nvim-telescope/telescope-ui-select.nvim', + 'ahmedkhalf/project.nvim', }, cmd = { "Telescope" }, keys = { @@ -86,7 +85,14 @@ return { require("telescope.builtin").grep_string() end, desc = 'Find in workspace', - } + }, + { + 'p', + function() + require('telescope').extensions.projects.projects() + end, + desc = 'Select project', + }, }, config = function() local actions = require('telescope.actions') @@ -98,6 +104,12 @@ return { }, } + Project_files = function() + local opts = {} -- define here if you want to define something + local ok = pcall(require "telescope.builtin".git_files, opts) + if not ok then require "telescope.builtin".find_files(opts) end + end + require('telescope').setup({ defaults = { mappings = { @@ -149,13 +161,7 @@ return { }) require("telescope").load_extension("ui-select") - - Project_files = function() - local opts = {} -- define here if you want to define something - local ok = pcall(require "telescope.builtin".git_files, opts) - if not ok then require "telescope.builtin".find_files(opts) end - end - require('telescope').load_extension('fzf') + -- require('telescope').load_extension('projects') end } diff --git a/lua/setup/comment.lua b/lua/setup/comment.lua deleted file mode 100644 index 09302fb..0000000 --- a/lua/setup/comment.lua +++ /dev/null @@ -1,13 +0,0 @@ -require('Comment').setup({ - mappings = false, -}) -require('legendary').keymap( - { - '', - { - n = '(comment_toggle_linewise_current)', - v = '(comment_toggle_linewise_visual)gv' - }, - description = 'Toggle comment' - } -) diff --git a/lua/setup/gitsigns.lua b/lua/setup/gitsigns.lua deleted file mode 100644 index e4fb000..0000000 --- a/lua/setup/gitsigns.lua +++ /dev/null @@ -1,9 +0,0 @@ -require('gitsigns').setup({ - current_line_blame = false, - current_line_blame_opts = { - virt_text = true, - virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' - delay = 1000, - ignore_whitespace = false, - }, -}) diff --git a/lua/setup/indent_blankline.lua b/lua/setup/indent_blankline.lua deleted file mode 100644 index fa14302..0000000 --- a/lua/setup/indent_blankline.lua +++ /dev/null @@ -1,12 +0,0 @@ -local opt = vim.opt -- to set options -opt.listchars:append('eol:↴') --- opt.listchars:append("space: ") -opt.listchars:append('trail: ') -opt.listchars:append('tab:→ ') - -require('indent_blankline').setup({ - show_end_of_line = true, - use_treesitter = true, - show_current_context = true, - context_patterns = { 'class', 'function', 'method', 'block', '^if', '^for', '^while' }, -}) diff --git a/lua/setup/lualine.lua b/lua/setup/lualine.lua deleted file mode 100644 index a05db60..0000000 --- a/lua/setup/lualine.lua +++ /dev/null @@ -1,29 +0,0 @@ -vim.opt.laststatus = 3 -require('lualine').setup({ - options = { - theme = 'gruvbox-flat', - disabled_filetypes = { - statusline = {}, - winbar = { 'dap-repl', 'dapui_console' }, - }, - }, - 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_cmp.lua b/lua/setup/my_cmp.lua deleted file mode 100644 index 6abbac6..0000000 --- a/lua/setup/my_cmp.lua +++ /dev/null @@ -1,141 +0,0 @@ -local cmp = require('cmp') -local luasnip = require('luasnip') - -local t = function(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) -end - -local check_back_space = function() - local col = vim.fn.col('.') - 1 - return col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') ~= nil -end - -cmp.setup({ - formatting = { - format = require('lspkind').cmp_format({ - mode = 'symbol_text', -- show only symbol annotations - maxwidth = 80, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) - ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) - }) - }, - mapping = { - [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c', 's' }), - [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c', 's' }), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }), - [''] = cmp.mapping(cmp.mapping.close(), { 'i', 'c', 's' }), - [''] = cmp.mapping({ - i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }), - c = cmp.mapping.confirm({ select = false }), - s = cmp.mapping.confirm({ select = false }), - }), - [''] = cmp.mapping(function(fallback) - if luasnip.expand_or_jumpable() then - vim.api.nvim_feedkeys(t('luasnip-expand-or-jump'), '', true) - else - fallback() - end - end, { - 'i', - 's', - }), - [''] = cmp.mapping(function(fallback) - if luasnip.jumpable(-1) then - vim.api.nvim_feedkeys(t('luasnip-jump-prev'), '', true) - else - fallback() - end - end, { - 'i', - 's', - }), - }, - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) - end, - }, - sources = { - { name = 'luasnip', priority = 8 }, - { name = 'nvim_lsp', priority = 7 }, - { name = 'nvim_lsp_signature_help', priority = 7 }, - { name = 'treesitter', priority = 6 }, - { name = 'buffer', priority = 5, - option = { - get_bufnrs = function() - local bufs = {} - for _, win in ipairs(vim.api.nvim_list_wins()) do - bufs[vim.api.nvim_win_get_buf(win)] = true - end - return vim.tbl_keys(bufs) - end - } - }, - -- { name = 'nvim_lua' }, - -- { name = 'look' }, - -- { name = 'path' }, - -- { name = 'cmp_tabnine' }, - -- { name = 'calc' }, - -- { name = 'spell' }, - -- { name = 'emoji' }, - }, - enabled = function() - return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt" - or vim.api.nvim_buf_get_option(0, 'filetype') == 'dap-repl' - or vim.api.nvim_buf_get_option(0, 'filetype') == 'dapui_watches' - or vim.api.nvim_buf_get_option(0, 'filetype') == 'dapui_hover' - end, - completion = { completeopt = 'menu,menuone,noinsert, noselect' }, - window = { - -- completion = cmp.config.window.bordered(), - -- documentation = cmp.config.window.bordered(), - }, - sorting = { - comparators = { - require('clangd_extensions.cmp_scores'), - cmp.config.compare.locality, - -- cmp.config.compare.recently_used, - -- -- cmp.config.compare.offset, - -- cmp.config.compare.exact, - -- cmp.config.compare.recently_used, - -- cmp.config.compare.kind, - -- cmp.config.compare.sort_text, - -- cmp.config.compare.length, - -- cmp.config.compare.order, - }, - }, - -- experimental = { native_menu = true } -}) - --- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline('/', { - sources = { - { name = 'buffer' }, - }, -}) - --- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline(':', { - sources = { - { name = 'cmdline' }, - { name = 'cmdline_history' }, - { name = 'path' }, - { name = 'buffer' }, - }, -}) - -require('cmp').setup.filetype({ 'dap-repl', 'dapui_watches', 'dapui_hover' }, { - sources = { - { name = 'dap' }, - }, -}) - --- Autopairs ---require("nvim-autopairs.completion.cmp").setup({ --- map_cr = true, --- map_complete = true, --- auto_select = true ---}) -local cmp_autopairs = require('nvim-autopairs.completion.cmp') -cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) diff --git a/lua/setup/my_lspconfig.lua b/lua/setup/my_lspconfig.lua deleted file mode 100644 index b16a0c0..0000000 --- a/lua/setup/my_lspconfig.lua +++ /dev/null @@ -1,218 +0,0 @@ -require('mason').setup() -require('mason-lspconfig').setup({ - automatic_installation = false, -}) - -local capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) - -OpenDiagFloat = function() - for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do - if vim.api.nvim_win_get_config(winid).zindex then - return - end - end - vim.diagnostic.open_float({ focusable = false, width=80 }) -end - -local on_attach = function(client, bufnr) - local function buf_set_option(...) - vim.api.nvim_buf_set_option(bufnr, ...) - end - - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') - vim.api.nvim_buf_set_option(0, 'formatexpr', 'v:lua.vim.lsp.formatexpr()') - - -- Mappings. - local opts = { noremap = true, silent = false, buffer = bufnr } - vim.keymap.set('n', ',', vim.diagnostic.goto_prev, opts) - vim.keymap.set('n', ';', vim.diagnostic.goto_next, opts) - vim.keymap.set('n', 'a', vim.lsp.buf.code_action, opts) - vim.keymap.set('n', 'd', vim.lsp.buf.definition, opts) - vim.keymap.set('n', 'e', vim.lsp.buf.declaration, opts) - vim.keymap.set('n', 'h', vim.lsp.buf.hover, opts) - vim.keymap.set('n', 'c', vim.lsp.buf.outgoing_calls, opts) - vim.keymap.set('n', 'C', vim.lsp.buf.incoming_calls, opts) - vim.keymap.set('n', 'm', vim.lsp.buf.rename, opts) - local tele_builtins = require('telescope.builtin') - vim.keymap.set('n', '', tele_builtins.lsp_dynamic_workspace_symbols, opts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) - vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) - vim.keymap.set('n', 'r', tele_builtins.lsp_references, opts) - vim.keymap.set('n', '', 'Telescope aerial', opts) - vim.keymap.set('n', 'v', function() tele_builtins.diagnostics({ bufnr = 0 }) end, opts) - vim.keymap.set('n', '', 'ClangdSwitchSourceHeader', opts) - - vim.cmd([[autocmd CursorHold lua OpenDiagFloat()]]) - - -- Set some keybinds conditional on server capabilities - if client.server_capabilities.documentFormattingProvider then - vim.keymap.set('n', 'f', vim.lsp.buf.format, opts) - end - if client.server_capabilities.documentRangeFormattingProvider then - vim.keymap.set('x', 'f', vim.lsp.buf.format, opts) - end - - -- Set autocommands conditional on server_capabilities - if client.server_capabilities.documentHighlightProvider then - vim.api.nvim_set_hl( - 0, - "LspReferenceText", - { bold = true, - ctermbg = 'red', - bg = "#5a524c"} - ) - vim.api.nvim_set_hl( - 0, - "LspReferenceRead", - { bold = true, - ctermbg = 'red', - bg = 'DarkGreen' } - ) - vim.api.nvim_set_hl( - 0, - "LspReferenceWrite", - { bold = true, - ctermbg = 'red', - bg = 'DarkRed' } - ) - vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true }) - vim.api.nvim_clear_autocmds { buffer = bufnr, group = "lsp_document_highlight" } - vim.api.nvim_create_autocmd("CursorHold", { - callback = vim.lsp.buf.document_highlight, - buffer = bufnr, - group = "lsp_document_highlight", - desc = "Document Highlight", - }) - vim.api.nvim_create_autocmd("CursorMoved", { - callback = vim.lsp.buf.clear_references, - buffer = bufnr, - group = "lsp_document_highlight", - desc = "Clear All the References", - }) - end - - require('lsp_signature').on_attach({ - bind = true, -- This is mandatory, otherwise border config won't get registered. - handler_opts = { - border = 'single', - }, - hi_parameter = 'IncSearch', - }, bufnr) -end - -require('lspconfig')['pyright'].setup { - capabilities = capabilities, - on_attach = on_attach, -} - -require('lspconfig')['groovyls'].setup { - capabilities = capabilities, - on_attach = on_attach, -} - -require('lspconfig')['cmake'].setup { - capabilities = capabilities, - on_attach = on_attach, -} - -local clangd_capabilities = capabilities -clangd_capabilities.textDocument.semanticHighlighting = true -clangd_capabilities.offsetEncoding = { "utf-16" } -require("clangd_extensions").setup { - server = { - capabilities = clangd_capabilities, - on_attach = on_attach, - cmd = { 'clangd', '--compile-commands-dir=build_nvim' }, - root_dir = require('lspconfig').util.root_pattern( - '.clangd', - '.clang-tidy', - '.clang-format', - 'compile_commands.json', - 'compile_flags.txt', - 'configure.ac', - '.git', - 'build_nvim' - ) - }, - extensions = - { - inlay_hints = { - -- Only show inlay hints for the current line - only_current_line = true, - } - } - -} --- require('clangd_extensions').setup({ --- server = { --- on_attach = on_attach, --- capabilities = capabilities, --- cmd = { 'clangd', '--compile-commands-dir=build_nvim' }, --- }, --- }) - -require('lspconfig')['jsonls'].setup { - capabilities = capabilities, - on_attach = on_attach, -} - -local lua_rtp = vim.split(package.path, ';') -table.insert(lua_rtp, 'lua/?.lua') -table.insert(lua_rtp, 'lua/?/init.lua') -require('lspconfig').sumneko_lua.setup { - capabilities = capabilities, - on_attach = on_attach, - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT', - -- Setup your lua path - path = lua_rtp, - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { 'vim', 'use' }, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file('', true), - }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { - enable = false, - }, - }, - } -} - -require('lspconfig')['dockerls'].setup { - capabilities = capabilities, - on_attach = on_attach, -} - -require('lspconfig')['yamlls'].setup { - capabilities = capabilities, - on_attach = on_attach, - settings = { - yaml = { - validate = true - } - } -} - -local null_ls = require('null-ls') -null_ls.setup({ - sources = { - null_ls.builtins.code_actions.gitsigns, - null_ls.builtins.formatting.autopep8, - null_ls.builtins.formatting.prettier, - null_ls.builtins.diagnostics.flake8, - null_ls.builtins.formatting.isort, - null_ls.builtins.formatting.cmake_format, - }, - on_attach = on_attach, - capabilities = capabilities, -}) - -vim.diagnostic.config({ virtual_text = false }) diff --git a/lua/setup/project.lua b/lua/setup/project.lua deleted file mode 100644 index bc289c5..0000000 --- a/lua/setup/project.lua +++ /dev/null @@ -1,17 +0,0 @@ -require('project_nvim').setup({ - silent_chdir = true, - ignore_lsp = { 'null-ls', 'cmake' }, - patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json", "build_nvim", "real_path.txt" }, -}) -require('telescope').load_extension('projects') -require('legendary').keymaps( - { - { - 'p', - function () - require('telescope').extensions.projects.projects() - end, - description = 'Select project', - }, - } -) From 4916c4eca2c911d052973a72fe9638ca9154e4f0 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 28 Dec 2022 20:29:41 +0100 Subject: [PATCH 24/38] more restructering --- lua/plugins/aerial.lua | 27 ++++++++++++++++++++++ lua/plugins/init.lua | 34 --------------------------- lua/plugins/neoclip.lua | 18 +++++++++++++++ lua/plugins/toggleterm.lua | 47 ++++++++++++++++++++++++++++++++++++++ lua/setup/aerial.lua | 18 --------------- lua/setup/toggleterm.lua | 42 ---------------------------------- lua/setup/yanky.lua | 27 ---------------------- 7 files changed, 92 insertions(+), 121 deletions(-) create mode 100644 lua/plugins/aerial.lua create mode 100644 lua/plugins/neoclip.lua create mode 100644 lua/plugins/toggleterm.lua delete mode 100644 lua/setup/aerial.lua delete mode 100644 lua/setup/toggleterm.lua delete mode 100644 lua/setup/yanky.lua diff --git a/lua/plugins/aerial.lua b/lua/plugins/aerial.lua new file mode 100644 index 0000000..94f0130 --- /dev/null +++ b/lua/plugins/aerial.lua @@ -0,0 +1,27 @@ +return { + 'stevearc/aerial.nvim', + dependencies = { + 'nvim-telescope/telescope.nvim' + }, + config = function() + require('aerial').setup({ + backends = { 'lsp', 'treesitter', 'markdown' }, + layout = { + default_direction = "prefer_left" + }, + filter_kind = false, + show_guides = true, + }) + require('telescope').load_extension('aerial') + end, + cmd = 'AerialToggle', + keys = { + { + 's', + function () + require('aerial').toggle() + end, + desc = 'Symbols outline', + } + } +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index c039499..b5d6341 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -29,40 +29,6 @@ return { require('setup/my_gruvbox_flat') end }, - { - 'akinsho/toggleterm.nvim', - config = function() - require('setup/toggleterm') - end, - cmd = 'ToggleTerm', - keys = 'g' - }, - { - 'gbprod/yanky.nvim', - config = function() - require('setup/yanky') - end, - keys = { - { '' }, - { '' } - }, - dependencies = { - 'nvim-telescope/telescope.nvim' - } - }, - { - 'stevearc/aerial.nvim', - dependencies = { - 'nvim-telescope/telescope.nvim' - }, - config = function() - require('setup/aerial') - end, - cmd = 'AerialToggle', - keys = { - { 's' } - } - }, { 'ggandor/leap.nvim', dependencies = { 'tpope/vim-repeat' }, diff --git a/lua/plugins/neoclip.lua b/lua/plugins/neoclip.lua new file mode 100644 index 0000000..b38b77e --- /dev/null +++ b/lua/plugins/neoclip.lua @@ -0,0 +1,18 @@ +return { + "AckslD/nvim-neoclip.lua", + dependencies = { + { 'kkharji/sqlite.lua', module = 'sqlite' }, + -- { 'nvim-telescope/telescope.nvim' }, + }, + config = true, + keys = { + { + '[', + function () + require('telescope').extensions.neoclip.default({initial_mode='normal'}) + end, + desc = 'NeoClip' + } + }, + event = 'VeryLazy' +} diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua new file mode 100644 index 0000000..cbd372f --- /dev/null +++ b/lua/plugins/toggleterm.lua @@ -0,0 +1,47 @@ +return { + 'akinsho/toggleterm.nvim', + config = function() + function _G.set_terminal_keymaps(term) + local opts = { noremap = true } + if (term.cmd ~= 'lazygit') then + vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', [[]], opts) + end + vim.api.nvim_buf_set_keymap(term.bufnr, 't', 'jk', [[]], opts) + vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', [[h]], opts) + vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', [[j]], opts) + vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', [[k]], opts) + vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', [[l]], opts) + end + + require('toggleterm').setup({ + on_open = set_terminal_keymaps + }) + + local Terminal = require('toggleterm.terminal').Terminal + + local lazygit = Terminal:new({ + cmd = 'lazygit', + -- dir = vim.fn.getcwd(), + hidden = true, + direction = 'float', + on_open = function(term) + vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "close", { noremap = true, silent = true }) + -- vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', '', {noremap = true, silent = true}) + end, + }) + + function _lazygit_toggle() + lazygit:toggle() + end + end, + cmd = 'ToggleTerm', + keys = { + { + 'g', + function() + _lazygit_toggle() + end, + desc= 'Open lazygit', + } + } +} diff --git a/lua/setup/aerial.lua b/lua/setup/aerial.lua deleted file mode 100644 index 0978b72..0000000 --- a/lua/setup/aerial.lua +++ /dev/null @@ -1,18 +0,0 @@ -require('aerial').setup({ - backends = { 'lsp', 'treesitter', 'markdown' }, - layout = { - default_direction = "prefer_left" - }, - filter_kind = false, - show_guides = true, -}) -require('telescope').load_extension('aerial') -require('legendary').keymaps( - { - { - 's', - ':AerialToggle', - description = 'Symbols outline', - } - } -) diff --git a/lua/setup/toggleterm.lua b/lua/setup/toggleterm.lua deleted file mode 100644 index 09efcd4..0000000 --- a/lua/setup/toggleterm.lua +++ /dev/null @@ -1,42 +0,0 @@ -function _G.set_terminal_keymaps(term) - local opts = { noremap = true } - if (term.cmd ~= 'lazygit') then - vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', [[]], opts) - end - vim.api.nvim_buf_set_keymap(term.bufnr, 't', 'jk', [[]], opts) - vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', [[h]], opts) - vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', [[j]], opts) - vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', [[k]], opts) - vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', [[l]], opts) -end - -require('toggleterm').setup({ - on_open = set_terminal_keymaps -}) - -local Terminal = require('toggleterm.terminal').Terminal - -local lazygit = Terminal:new({ - cmd = 'lazygit', - -- dir = vim.fn.getcwd(), - hidden = true, - direction = 'float', - on_open = function(term) - vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "close", { noremap = true, silent = true }) - -- vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', '', {noremap = true, silent = true}) - end, -}) - -function _lazygit_toggle() - lazygit:toggle() -end - -require('legendary').keymaps( - { - { - 'g', - ':lua _lazygit_toggle()', - description = 'Open lazygit', - } - } -) diff --git a/lua/setup/yanky.lua b/lua/setup/yanky.lua deleted file mode 100644 index bfcf475..0000000 --- a/lua/setup/yanky.lua +++ /dev/null @@ -1,27 +0,0 @@ -require('yanky').setup() -vim.api.nvim_set_keymap('n', 'p', '(YankyPutAfter)', {}) -vim.api.nvim_set_keymap('n', 'P', '(YankyPutBefore)', {}) -vim.api.nvim_set_keymap('x', 'p', '(YankyPutAfter)', {}) -vim.api.nvim_set_keymap('x', 'P', '(YankyPutBefore)', {}) -vim.api.nvim_set_keymap('n', 'gp', '(YankyGPutAfter)', {}) -vim.api.nvim_set_keymap('n', 'gP', '(YankyGPutBefore)', {}) -vim.api.nvim_set_keymap('x', 'gp', '(YankyGPutAfter)', {}) -vim.api.nvim_set_keymap('x', 'gP', '(YankyGPutBefore)', {}) -vim.keymap.set("n", "", "(YankyCycleForward)", {}) -vim.keymap.set("n", "", "(YankyCycleBackward)", {}) - -require("telescope").load_extension('yank_history') -require('legendary').keymaps( - { - { - '', - '(YankyCycleForward)', - description = 'Yanky cycle forward', - }, - { - '', - '(YankyCycleBackward)', - description = 'Yanky cycle backward', - }, - } -) From 9055e4e8768e04fd5035d94d51986fa74b5c79c9 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 28 Dec 2022 20:44:18 +0100 Subject: [PATCH 25/38] dap and leap --- lua/plugins/dap.lua | 249 ++++++++++++++++++++++++++++++++++++++++++ lua/plugins/init.lua | 34 ------ lua/plugins/leap.lua | 8 ++ lua/setup/my_dap.lua | 185 ------------------------------- lua/setup/my_leap.lua | 1 - 5 files changed, 257 insertions(+), 220 deletions(-) create mode 100644 lua/plugins/dap.lua create mode 100644 lua/plugins/leap.lua delete mode 100644 lua/setup/my_dap.lua delete mode 100644 lua/setup/my_leap.lua diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua new file mode 100644 index 0000000..b62079e --- /dev/null +++ b/lua/plugins/dap.lua @@ -0,0 +1,249 @@ +return { + 'mfussenegger/nvim-dap', + dependencies = { + 'mfussenegger/nvim-dap-python', + 'theHamsta/nvim-dap-virtual-text', + { + 'nvim-telescope/telescope-dap.nvim', + dependencies = 'telescope.nvim', + }, + 'rcarriga/nvim-dap-ui', + 'rcarriga/cmp-dap', + }, + keys = { + { + '', + function() + require('dap').continue() + end, + desc = 'DAP continue' + }, + { + '', + function() + loadConfigs() + end, + desc = 'DAP configs' + }, + { + '', + function() + require('dap').goto_() + end, + desc = 'DAP goto' + }, + { + '', + function() + require('dap.ui.widgets').hover() + end, + desc = 'DAP Hover' + }, + { + '', + function() + require('dap').toggle_breakpoint() + end, + desc = 'DAP breakpoint' + }, + { + '', + function() + require('dap').step_over() + end, + desc = 'DAP step_over' + }, + { + '', + function() + require('dap').step_into() + end, + desc = 'DAP step_into' + }, + { + '', + function() + require('dap').step_out() + end, + desc = 'DAP step_out' + }, + }, + config = function() + local dap = require('dap') + + require("cmp_dap").is_dap_buffer() + + + -- make sure we can exit the terminal with esc + vim.api.nvim_create_autocmd({ "TermOpen" }, { + pattern = { '*dap-terminal*' }, + callback = function() + local opts = { noremap = true } + vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) + end + }) + + local function getVenvSuffix() + if vim.loop.os_uname().sysname == 'Linux' then + return 'bin/python' + elseif vim.loop.os_uname().sysname == 'Windows_NT' then + return 'Scripts/python.exe' + end + end + + local function getPythonEnv() + local venv = os.getenv("VIRTUAL_ENV") + if venv ~= nil then + return string.format("%s/%s", venv, getVenvSuffix()) + end + local conda = os.getenv("CONDA_PREFIX") + if conda ~= nil then + return string.format("%s/%s", conda, 'python.exe') + end + + local cwd = vim.fn.getcwd() + if vim.fn.executable(cwd .. '/venv/' .. getVenvSuffix()) == 1 then + return cwd .. '/venv/' .. getVenvSuffix() + elseif vim.fn.executable(cwd .. '/.venv/' .. getVenvSuffix()) == 1 then + return cwd .. '/.venv/' .. getVenvSuffix() + else + if vim.loop.os_uname().sysname == 'Linux' then + return '/usr/bin/python' + elseif vim.loop.os_uname().sysname == 'Windows_NT' then + return os.getenv('SCOOP') .. '/apps/python/current/python.exe' + end + end + end + + function loadConfigs() + require('dap.ext.vscode').load_launchjs() + -- Make sure we use the correct python env even for the configs from launch.json + for nr, config in pairs(dap.configurations.python) do + config.pythonPath = getPythonEnv() + config.cwd = vim.fn.getcwd() + end + require 'telescope'.extensions.dap.configurations {} + end + + local initDir = vim.api.nvim_list_runtime_paths()[1] + local masonpath = vim.fn.stdpath('data') .. '/mason' + + -- PYTHON + dap.adapters.python = { + type = 'executable'; + command = masonpath .. '/packages/debugpy/venv/' .. getVenvSuffix(); + args = { '-m', 'debugpy.adapter' }; + options = { + detached = true; + }; + } + + local dap = require("dap") + local dapui = require("dapui") + dapui.setup() + dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() + end + dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() + end + dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() + end + + dap.configurations.python = { + { + type = 'python'; + request = 'launch'; + name = "Launch file with venv"; + justMyCode = false; + program = "${file}"; + cwd = vim.fn.getcwd(); + pythonPath = getPythonEnv + }, + } + + -- require('dap-python').setup('C:\\Users\\oli\\AppData\\Local\\nvim\\venv_debugpy\\Scripts\\python') + -- table.insert(require('dap').configurations.python, { + -- -- type = 'python', + -- -- request = 'launch', + -- -- name = 'My custom launch configuration', + -- -- program = '${file}', + -- justMyCode = false + -- -- ... more options, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings + -- }) + -- require('dap-python').setup('C:/Users/oli/AppData/Local/nvim-data/mason/packages/debugpy/venv/Scripts/python.exe') + + -- CPP + dap.adapters.codelldb = { + type = 'server', + port = "${port}", + executable = { + -- CHANGE THIS to your path! + command = masonpath .. '/bin/codelldb.cmd', + args = { '--port', '${port}' }, + + -- On windows you may have to uncomment this: + detached = false, + } + } + + dap.adapters.lldb = { + type = 'executable', + command = function() + if vim.loop.os_uname().sysname == 'Linux' then + return 'lldb-vscode' + else + return os.getenv('SCOOP') .. '/apps/llvm/current/bin/lldb-vscode.exe' + end + end, + name = 'lldb' + } + + dap.configurations.cpp = { + { + name = "Launch codelldb", + type = "codelldb", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/build_nvim/', 'file') + end, + cwd = '${workspaceFolder}', + stopOnEntry = true, + }, + } + + dap.configurations.cpp = { + { + name = 'Launch lldb', + type = 'lldb', + request = 'launch', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/build_nvim', 'file') + end, + cwd = '${workspaceFolder}', + stopOnEntry = false, + args = {}, + + -- 💀 + -- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting: + -- + -- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope + -- + -- Otherwise you might get the following error: + -- + -- Error on launch: Failed to attach to the target process + -- + -- But you should be aware of the implications: + -- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html + -- runInTerminal = false, + }, + } + + -- EXTENSIONS + + require('nvim-dap-virtual-text').setup() + require('telescope').load_extension('dap') + + end, +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index b5d6341..882f71e 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -29,40 +29,6 @@ return { require('setup/my_gruvbox_flat') end }, - { - 'ggandor/leap.nvim', - dependencies = { 'tpope/vim-repeat' }, - config = function() - require('setup/my_leap') - end, - event = 'VeryLazy' - }, - { - 'mfussenegger/nvim-dap', - dependencies = { - 'mfussenegger/nvim-dap-python', - 'theHamsta/nvim-dap-virtual-text', - { - 'nvim-telescope/telescope-dap.nvim', - dependencies = 'telescope.nvim', - }, - 'rcarriga/nvim-dap-ui', - 'rcarriga/cmp-dap', - }, - keys = { - { '' }, - { '' }, - { '' }, - { '' }, - { '' }, - { '' }, - { '' }, - { '' } - }, - config = function() - require('setup/my_dap') - end, - }, { 'sindrets/diffview.nvim', dependencies = 'nvim-lua/plenary.nvim', diff --git a/lua/plugins/leap.lua b/lua/plugins/leap.lua new file mode 100644 index 0000000..830b40d --- /dev/null +++ b/lua/plugins/leap.lua @@ -0,0 +1,8 @@ +return { + 'ggandor/leap.nvim', + dependencies = { 'tpope/vim-repeat' }, + config = function() + require('leap').set_default_keymaps() + end, + event = 'VeryLazy' +} diff --git a/lua/setup/my_dap.lua b/lua/setup/my_dap.lua deleted file mode 100644 index a064311..0000000 --- a/lua/setup/my_dap.lua +++ /dev/null @@ -1,185 +0,0 @@ -dap = require('dap') - -require("cmp_dap").is_dap_buffer() - - --- make sure we can exit the terminal with esc -vim.api.nvim_create_autocmd({ "TermOpen" }, { - pattern = { '*dap-terminal*' }, - callback = function() - local opts = { noremap = true } - vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) - end -}) - -local function getVenvSuffix() - if vim.loop.os_uname().sysname == 'Linux' then - return 'bin/python' - elseif vim.loop.os_uname().sysname == 'Windows_NT' then - return 'Scripts/python.exe' - end -end - -local function getPythonEnv() - local venv = os.getenv("VIRTUAL_ENV") - if venv ~= nil then - return string.format("%s/%s", venv, getVenvSuffix()) - end - local conda = os.getenv("CONDA_PREFIX") - if conda ~= nil then - return string.format("%s/%s", conda, 'python.exe') - end - - local cwd = vim.fn.getcwd() - if vim.fn.executable(cwd .. '/venv/' .. getVenvSuffix()) == 1 then - return cwd .. '/venv/' .. getVenvSuffix() - elseif vim.fn.executable(cwd .. '/.venv/' .. getVenvSuffix()) == 1 then - return cwd .. '/.venv/' .. getVenvSuffix() - else - if vim.loop.os_uname().sysname == 'Linux' then - return '/usr/bin/python' - elseif vim.loop.os_uname().sysname == 'Windows_NT' then - return os.getenv('SCOOP') .. '/apps/python/current/python.exe' - end - end -end - -local function loadConfigs () - require('dap.ext.vscode').load_launchjs() - -- Make sure we use the correct python env even for the configs from launch.json - for nr,config in pairs(dap.configurations.python) do - config.pythonPath = getPythonEnv() - config.cwd = vim.fn.getcwd() - end - require'telescope'.extensions.dap.configurations{} -end -local opts = { noremap = true, silent = false } -vim.keymap.set('n', '', dap.continue, opts) -vim.keymap.set('n', '', loadConfigs, opts) -vim.keymap.set('n', '', dap.goto_, opts) -vim.keymap.set('n', '', require('dap.ui.widgets').hover, opts) -vim.keymap.set('n', '', dap.toggle_breakpoint, opts) -vim.keymap.set('n', '', dap.step_over, opts) -vim.keymap.set('n', '', dap.step_into, opts) -vim.keymap.set('n', '', dap.step_out, opts) - -local initDir = vim.api.nvim_list_runtime_paths()[1] -local masonpath = vim.fn.stdpath('data') .. '/mason' - --- PYTHON -dap.adapters.python = { - type = 'executable'; - command = masonpath .. '/packages/debugpy/venv/' .. getVenvSuffix(); - args = { '-m', 'debugpy.adapter' }; - options = { - detached = true; - }; -} - -local dap= require("dap") -local dapui = require("dapui") -dapui.setup() -dap.listeners.after.event_initialized["dapui_config"] = function() - dapui.open() -end -dap.listeners.before.event_terminated["dapui_config"] = function() - dapui.close() -end -dap.listeners.before.event_exited["dapui_config"] = function() - dapui.close() -end - -dap.configurations.python = { - { - type = 'python'; - request = 'launch'; - name = "Launch file with venv"; - justMyCode = false; - program = "${file}"; - cwd = vim.fn.getcwd(); - pythonPath = getPythonEnv - }, -} - --- require('dap-python').setup('C:\\Users\\oli\\AppData\\Local\\nvim\\venv_debugpy\\Scripts\\python') --- table.insert(require('dap').configurations.python, { --- -- type = 'python', --- -- request = 'launch', --- -- name = 'My custom launch configuration', --- -- program = '${file}', --- justMyCode = false --- -- ... more options, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings --- }) --- require('dap-python').setup('C:/Users/oli/AppData/Local/nvim-data/mason/packages/debugpy/venv/Scripts/python.exe') - --- CPP -dap.adapters.codelldb = { - type = 'server', - port = "${port}", - executable = { - -- CHANGE THIS to your path! - command = masonpath .. '/bin/codelldb.cmd', - args = { '--port', '${port}' }, - - -- On windows you may have to uncomment this: - detached = false, - } -} - -dap.adapters.lldb = { - type = 'executable', - command = function() - if vim.loop.os_uname().sysname == 'Linux' then - return 'lldb-vscode' - else - return os.getenv('SCOOP') .. '/apps/llvm/current/bin/lldb-vscode.exe' - end - end, - name = 'lldb' -} - -dap.configurations.cpp = { - { - name = "Launch codelldb", - type = "codelldb", - request = "launch", - program = function() - return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/build_nvim/', 'file') - end, - cwd = '${workspaceFolder}', - stopOnEntry = true, - }, -} - -dap.configurations.cpp = { - { - name = 'Launch lldb', - type = 'lldb', - request = 'launch', - program = function() - return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/build_nvim', 'file') - end, - cwd = '${workspaceFolder}', - stopOnEntry = false, - args = {}, - - -- 💀 - -- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting: - -- - -- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope - -- - -- Otherwise you might get the following error: - -- - -- Error on launch: Failed to attach to the target process - -- - -- But you should be aware of the implications: - -- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html - -- runInTerminal = false, - }, -} - --- EXTENSIONS - -require('nvim-dap-virtual-text').setup() -require('telescope').load_extension('dap') - diff --git a/lua/setup/my_leap.lua b/lua/setup/my_leap.lua deleted file mode 100644 index 08d46e0..0000000 --- a/lua/setup/my_leap.lua +++ /dev/null @@ -1 +0,0 @@ -require('leap').set_default_keymaps() From b0918760d458dda62cb7635870e6c607ab9948dd Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 28 Dec 2022 21:07:04 +0100 Subject: [PATCH 26/38] moved all plugins --- lua/plugins/cmp.lua | 11 +----- lua/plugins/dap.lua | 12 +++---- lua/plugins/diffview.lua | 8 +++++ lua/plugins/gruvbox_flat.lua | 18 ++++++++++ lua/plugins/init.lua | 47 ------------------------ lua/plugins/luasnip.lua | 66 ++++++++++++++++++++++++++++++++++ lua/plugins/neogen.lua | 34 ++++++++++++++++++ lua/plugins/overseer.lua | 19 ++++++++++ lua/setup/luasnip.lua | 67 ----------------------------------- lua/setup/my_diffview.lua | 3 -- lua/setup/my_gruvbox_flat.lua | 12 ------- lua/setup/my_overseer.lua | 18 ---------- lua/setup/neogen.lua | 29 --------------- 13 files changed, 151 insertions(+), 193 deletions(-) create mode 100644 lua/plugins/diffview.lua create mode 100644 lua/plugins/gruvbox_flat.lua create mode 100644 lua/plugins/luasnip.lua create mode 100644 lua/plugins/neogen.lua create mode 100644 lua/plugins/overseer.lua delete mode 100644 lua/setup/luasnip.lua delete mode 100644 lua/setup/my_diffview.lua delete mode 100644 lua/setup/my_gruvbox_flat.lua delete mode 100644 lua/setup/my_overseer.lua delete mode 100644 lua/setup/neogen.lua diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 1994d04..70bd50f 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -4,16 +4,7 @@ return { { 'onsails/lspkind-nvim' }, { 'hrsh7th/cmp-buffer' }, { 'hrsh7th/cmp-nvim-lsp' }, - { - 'L3MON4D3/LuaSnip', - config = function() - require('setup/luasnip') - end, - dependencies = - { - 'rafamadriz/friendly-snippets' - } - }, + { 'L3MON4D3/LuaSnip' }, { 'saadparwaiz1/cmp_luasnip' }, { 'hrsh7th/cmp-nvim-lua' }, { 'octaltree/cmp-look' }, diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index b62079e..dbf6fad 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -118,14 +118,13 @@ return { function loadConfigs() require('dap.ext.vscode').load_launchjs() -- Make sure we use the correct python env even for the configs from launch.json - for nr, config in pairs(dap.configurations.python) do + for _, config in pairs(dap.configurations.python) do config.pythonPath = getPythonEnv() config.cwd = vim.fn.getcwd() end require 'telescope'.extensions.dap.configurations {} end - local initDir = vim.api.nvim_list_runtime_paths()[1] local masonpath = vim.fn.stdpath('data') .. '/mason' -- PYTHON @@ -138,17 +137,16 @@ return { }; } - local dap = require("dap") local dapui = require("dapui") dapui.setup() dap.listeners.after.event_initialized["dapui_config"] = function() - dapui.open() + dapui.open({}) end dap.listeners.before.event_terminated["dapui_config"] = function() - dapui.close() + dapui.close({}) end dap.listeners.before.event_exited["dapui_config"] = function() - dapui.close() + dapui.close({}) end dap.configurations.python = { @@ -242,7 +240,7 @@ return { -- EXTENSIONS - require('nvim-dap-virtual-text').setup() + require('nvim-dap-virtual-text').setup({}) require('telescope').load_extension('dap') end, diff --git a/lua/plugins/diffview.lua b/lua/plugins/diffview.lua new file mode 100644 index 0000000..6fd92bf --- /dev/null +++ b/lua/plugins/diffview.lua @@ -0,0 +1,8 @@ +return { + 'sindrets/diffview.nvim', + dependencies = { + 'nvim-lua/plenary.nvim' + }, + config = true, + cmd = 'DiffviewOpen', +} diff --git a/lua/plugins/gruvbox_flat.lua b/lua/plugins/gruvbox_flat.lua new file mode 100644 index 0000000..f3603d2 --- /dev/null +++ b/lua/plugins/gruvbox_flat.lua @@ -0,0 +1,18 @@ +return { + 'eddyekofo94/gruvbox-flat.nvim', + priority = 1000, + config = function() + local colors = require('gruvbox.colors') + vim.g.gruvbox_flat_style = "dark" + vim.g.gruvbox_colors = { + bg_search = 'purple', + fg_search = 'black', + } + vim.g.gruvbox_theme = { + Pmenu = { bg = 'bg_visual' }, + NormalFloat = { bg = 'bg_visual' } + } + vim.g.gruvbox_dark_float = false + vim.cmd('colorscheme gruvbox-flat') + end +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 882f71e..058678e 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -1,49 +1,2 @@ return { - { - 'mrjones2014/legendary.nvim', - config = function() - require('setup/my_legendary') - require('legendary').keymaps( - { - { - 'i', - function() - require("lazy").home() - end, - description = 'Start lazy home' - } - } - ) - end, - dependencies = { - 'stevearc/dressing.nvim', - 'nvim-telescope/telescope.nvim', - }, - keys = { 'p', 'i' } - }, - { - 'eddyekofo94/gruvbox-flat.nvim', - disable = false, - priority = 1000, - config = function() - require('setup/my_gruvbox_flat') - end - }, - { - 'sindrets/diffview.nvim', - dependencies = 'nvim-lua/plenary.nvim', - config = function() - require('setup/my_diffview') - end, - cmd = 'DiffviewOpen', - }, - { - 'stevearc/overseer.nvim', - config = function() - require('setup/my_overseer') - end, - keys = { - { '' } - }, - } } diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua new file mode 100644 index 0000000..e11aa7f --- /dev/null +++ b/lua/plugins/luasnip.lua @@ -0,0 +1,66 @@ +return { + 'L3MON4D3/LuaSnip', + config = function() + local ls = require('luasnip') + -- some shorthands... + local s = ls.snippet + local sn = ls.snippet_node + local isn = ls.indent_snippet_node + local t = ls.text_node + local i = ls.insert_node + local f = ls.function_node + local c = ls.choice_node + local d = ls.dynamic_node + local r = ls.restore_node + local l = require('luasnip.extras').lambda + local rep = require('luasnip.extras').rep + local p = require('luasnip.extras').partial + local m = require('luasnip.extras').match + local n = require('luasnip.extras').nonempty + local dl = require('luasnip.extras').dynamic_lambda + local fmt = require('luasnip.extras.fmt').fmt + local fmta = require('luasnip.extras.fmt').fmta + local types = require('luasnip.util.types') + local conds = require('luasnip.extras.expand_conditions') + + local function getRegA(capitalize) + local clipboard = vim.fn.getreg('a') + clipboard = clipboard:gsub('^m_', '') + if capitalize then + clipboard = clipboard:gsub('^%l', string.upper) + end + return clipboard + end + + ls.snippets = { + cpp = { + s('TEST_F_getset', + { + t('TEST_F('), i(1, 'TestClass'), t(' ,test_'), p(getRegA, false), t({ '_set_get)', '{', ' ' }), + i(2, 'm_object'), t('.set'), p(getRegA, true), t('('), i(3, '32.F'), t({ ');', ' ' }), + i(4, 'EXPECT_EQ('), rep(3), t(', '), rep(2), t('.get'), p(getRegA, true), t({ '());', '' }), + t({ '', '}', '' }) + }), + s('TEST_fn_getset', + { + t('void '), p(getRegA, false), t('_'), i(1, 'get'), t('_'), i(2, 'set'), t({ '()', '{', ' ' }), + i(3, 'm_object'), t('.set'), p(getRegA, true), t('('), i(4, '32.F'), t({ ');', ' ' }), + i(5, 'EXPECT_EQ('), rep(4), t(', '), rep(3), t('.get'), p(getRegA, true), t({ '());', '' }), + t({ '', '}', '', '' }), + + t('TEST_F('), i(5), t(' ,test_'), p(getRegA, false), t({ '_set_get)', '{', ' ' }), + p(getRegA, false), t('_'), rep(1), t('_'), rep(2), t({ '();' }), + t({ '', '}' }), + }) + }, + } + + require('luasnip.loaders.from_vscode').lazy_load() + require('luasnip.loaders.from_vscode').lazy_load({ paths = { "./my-snippets" } }) + end, + dependencies = + { + 'rafamadriz/friendly-snippets' + }, + cmd = 'LuaSnipListAvailable' +} diff --git a/lua/plugins/neogen.lua b/lua/plugins/neogen.lua new file mode 100644 index 0000000..4937074 --- /dev/null +++ b/lua/plugins/neogen.lua @@ -0,0 +1,34 @@ +return { + 'danymat/neogen', + dependencies = 'nvim-treesitter/nvim-treesitter', + config = { + enabled = true, + languages = { + cpp = { + template = { + annotation_convention = 'custom', + custom = { + { nil, '/// file', { no_results = true, type = { 'file' } } }, + { nil, '/// $1', { no_results = true, type = { 'func', 'file' } } }, + { nil, '', { no_results = true, type = { 'file' } } }, + + { nil, '/// $1', { type = { 'func' } } }, + { 'tparam', '/// \\tparam %s $1' }, + { 'parameters', '/// \\param %s $1' }, + { 'return_statement', '/// \\return $1' }, + }, + }, + }, + }, + }, + keys = { + { + 'n', + function() + require('neogen').generate() + end, + desc = 'Add comment', + } + }, + cmd = 'Neogen' +} diff --git a/lua/plugins/overseer.lua b/lua/plugins/overseer.lua new file mode 100644 index 0000000..5de82ed --- /dev/null +++ b/lua/plugins/overseer.lua @@ -0,0 +1,19 @@ +return { + 'stevearc/overseer.nvim', + config = function() + require('overseer').setup({ + templates = { "builtin", "user.cmake.cmake" }, + }) + end, + keys = { + { + '', + function() + require('overseer').open() + require('overseer').run_template() + end, + mode = { 'n', 'x' }, + desc = 'Start task (overseer)', + }, + } +} diff --git a/lua/setup/luasnip.lua b/lua/setup/luasnip.lua deleted file mode 100644 index 33a5a06..0000000 --- a/lua/setup/luasnip.lua +++ /dev/null @@ -1,67 +0,0 @@ -local ls = require('luasnip') --- some shorthands... -local s = ls.snippet -local sn = ls.snippet_node -local isn = ls.indent_snippet_node -local t = ls.text_node -local i = ls.insert_node -local f = ls.function_node -local c = ls.choice_node -local d = ls.dynamic_node -local r = ls.restore_node -local l = require('luasnip.extras').lambda -local rep = require('luasnip.extras').rep -local p = require('luasnip.extras').partial -local m = require('luasnip.extras').match -local n = require('luasnip.extras').nonempty -local dl = require('luasnip.extras').dynamic_lambda -local fmt = require('luasnip.extras.fmt').fmt -local fmta = require('luasnip.extras.fmt').fmta -local types = require('luasnip.util.types') -local conds = require('luasnip.extras.expand_conditions') - -local function getRegA(capitalize) - local clipboard = vim.fn.getreg('a') - clipboard = clipboard:gsub('^m_', '') - if capitalize then - clipboard = clipboard:gsub('^%l', string.upper) - end - return clipboard -end - - -ls.snippets = { - cpp = { - s('TEST_F_getset', - { - t('TEST_F('), i(1, 'TestClass'), t(' ,test_'), p(getRegA, false), t({'_set_get)', '{', ' '}), - i(2, 'm_object'), t('.set'), p(getRegA, true), t('('), i(3, '32.F'), t({');', ' '}), - i(4, 'EXPECT_EQ('), rep(3), t(', '), rep(2), t('.get'), p(getRegA, true), t({'());', ''}), - t({'','}', ''}) - }), - s('TEST_fn_getset', - { - t('void '), p(getRegA, false), t('_'), i(1, 'get'), t('_'), i(2, 'set'), t({'()', '{', ' '}), - i(3, 'm_object'), t('.set'), p(getRegA, true), t('('), i(4, '32.F'), t({');', ' '}), - i(5, 'EXPECT_EQ('), rep(4), t(', '), rep(3), t('.get'), p(getRegA, true), t({'());', ''}), - t({'','}', '', ''}), - - t('TEST_F('), i(5), t(' ,test_'), p(getRegA, false), t({'_set_get)', '{', ' '}), - p(getRegA, false), t('_'), rep(1), t('_'), rep(2), t({'();'}), - t({'','}'}), - }) - }, -} - -require('luasnip.loaders.from_vscode').lazy_load() -require('luasnip.loaders.from_vscode').lazy_load({ paths = { "./my-snippets" } }) - - -require('legendary').commands( - { - { - ':LuaSnipListAvailable', - description = 'List snippets', - } - } -) diff --git a/lua/setup/my_diffview.lua b/lua/setup/my_diffview.lua deleted file mode 100644 index eedf472..0000000 --- a/lua/setup/my_diffview.lua +++ /dev/null @@ -1,3 +0,0 @@ -local actions = require("diffview.actions") - -require("diffview").setup({}) diff --git a/lua/setup/my_gruvbox_flat.lua b/lua/setup/my_gruvbox_flat.lua deleted file mode 100644 index 668c550..0000000 --- a/lua/setup/my_gruvbox_flat.lua +++ /dev/null @@ -1,12 +0,0 @@ -local colors = require('gruvbox.colors') -vim.g.gruvbox_flat_style = "dark" -vim.g.gruvbox_colors = { - bg_search = 'purple', - fg_search = 'black', -} -vim.g.gruvbox_theme = { - Pmenu = { bg = 'bg_visual'}, - NormalFloat = { bg = 'bg_visual'} -} -vim.g.gruvbox_dark_float = false -vim.cmd('colorscheme gruvbox-flat') diff --git a/lua/setup/my_overseer.lua b/lua/setup/my_overseer.lua deleted file mode 100644 index 82b9060..0000000 --- a/lua/setup/my_overseer.lua +++ /dev/null @@ -1,18 +0,0 @@ -local overseer = require('overseer') -overseer.setup({ - templates = { "builtin", "user.cmake.cmake" }, -}) - -require('legendary').keymaps( - { - { - '', - function() - overseer.open() - overseer.run_template() - end, - mode = { 'n', 'x' }, - description = 'Start task (overseer)', - }, - } -) diff --git a/lua/setup/neogen.lua b/lua/setup/neogen.lua deleted file mode 100644 index df16773..0000000 --- a/lua/setup/neogen.lua +++ /dev/null @@ -1,29 +0,0 @@ -require('neogen').setup({ - enabled = true, - languages = { - cpp = { - template = { - annotation_convention = 'custom', - custom = { - { nil, '/// file', { no_results = true, type = { 'file' } } }, - { nil, '/// $1', { no_results = true, type = { 'func', 'file' } } }, - { nil, '', { no_results = true, type = { 'file' } } }, - - { nil, '/// $1', { type = { 'func' } } }, - { 'tparam', '/// \\tparam %s $1' }, - { 'parameters', '/// \\param %s $1' }, - { 'return_statement', '/// \\return $1' }, - }, - }, - }, - }, -}) -require('legendary').keymaps( - { - { - 'n', - ':Neogen', - description = 'Add comment', - } - } -) From 98d3f5cac77be465a0ccccbf133e278d88617045 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 28 Dec 2022 21:40:32 +0100 Subject: [PATCH 27/38] added which-key --- lua/my_keymappings.lua | 1 - lua/plugins/lspconfig.lua | 47 +++++++++++++++++++++++++-------------- lua/plugins/which-key.lua | 4 ++++ 3 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 lua/plugins/which-key.lua diff --git a/lua/my_keymappings.lua b/lua/my_keymappings.lua index f93b93a..6ddb858 100644 --- a/lua/my_keymappings.lua +++ b/lua/my_keymappings.lua @@ -1,5 +1,4 @@ local opts = { noremap = true, silent = true } -vim.keymap.set('n', '', 'nil', opts) -- Tabs vim.keymap.set('n', '', ':tabnext', opts) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 51f3dde..ffa4c2f 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -33,24 +33,37 @@ return { vim.api.nvim_buf_set_option(0, 'formatexpr', 'v:lua.vim.lsp.formatexpr()') -- Mappings. - local opts = { noremap = true, silent = false, buffer = bufnr } - vim.keymap.set('n', ',', vim.diagnostic.goto_prev, opts) - vim.keymap.set('n', ';', vim.diagnostic.goto_next, opts) - vim.keymap.set('n', 'a', vim.lsp.buf.code_action, opts) - vim.keymap.set('n', 'd', vim.lsp.buf.definition, opts) - vim.keymap.set('n', 'e', vim.lsp.buf.declaration, opts) - vim.keymap.set('n', 'h', vim.lsp.buf.hover, opts) - vim.keymap.set('n', 'c', vim.lsp.buf.outgoing_calls, opts) - vim.keymap.set('n', 'C', vim.lsp.buf.incoming_calls, opts) - vim.keymap.set('n', 'm', vim.lsp.buf.rename, opts) + vim.keymap.set('n', ',', vim.diagnostic.goto_prev, + { noremap = true, silent = false, desc = 'Diag prev', buffer = bufnr }) + vim.keymap.set('n', ';', vim.diagnostic.goto_next, + { noremap = true, silent = false, desc = 'Diag next', buffer = bufnr }) + vim.keymap.set('n', 'a', vim.lsp.buf.code_action, + { noremap = true, silent = false, desc = 'Code action', buffer = bufnr }) + vim.keymap.set('n', 'd', vim.lsp.buf.definition, + { noremap = true, silent = false, desc = 'Definition', buffer = bufnr }) + vim.keymap.set('n', 'e', vim.lsp.buf.declaration, + { noremap = true, silent = false, desc = 'Declaration', buffer = bufnr }) + vim.keymap.set('n', 'h', vim.lsp.buf.hover, + { noremap = true, silent = false, desc = 'Hover', buffer = bufnr }) + vim.keymap.set('n', 'c', vim.lsp.buf.outgoing_calls, + { noremap = true, silent = false, desc = 'Outgoing calls', buffer = bufnr }) + vim.keymap.set('n', 'C', vim.lsp.buf.incoming_calls, + { noremap = true, silent = false, desc = 'Incoming calls', buffer = bufnr }) + vim.keymap.set('n', 'm', vim.lsp.buf.rename, + { noremap = true, silent = false, desc = 'Rename', buffer = bufnr }) local tele_builtins = require('telescope.builtin') - vim.keymap.set('n', '', tele_builtins.lsp_dynamic_workspace_symbols, opts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) - vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) - vim.keymap.set('n', 'r', tele_builtins.lsp_references, opts) - vim.keymap.set('n', '', 'Telescope aerial', opts) - vim.keymap.set('n', 'v', function() tele_builtins.diagnostics({ bufnr = 0 }) end, opts) - vim.keymap.set('n', '', 'ClangdSwitchSourceHeader', opts) + vim.keymap.set('n', '', tele_builtins.lsp_dynamic_workspace_symbols, + { noremap = true, silent = false, desc = 'Workspace symbols', buffer = bufnr }) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, + { noremap = true, silent = false, desc = 'Type definition', buffer = bufnr }) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, + { noremap = true, silent = false, desc = 'Signature help', buffer = bufnr }) + vim.keymap.set('n', 'r', tele_builtins.lsp_references, + { noremap = true, silent = false, desc = 'References', buffer = bufnr }) + vim.keymap.set('n', 'v', function() tele_builtins.diagnostics({ bufnr = 0 }) end, + { noremap = true, silent = false, desc = 'Diagnostics', buffer = bufnr }) + vim.keymap.set('n', '', 'ClangdSwitchSourceHeader', + { noremap = true, silent = false, desc = 'Switch Source/Header', buffer = bufnr }) vim.cmd([[autocmd CursorHold lua OpenDiagFloat()]]) diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua new file mode 100644 index 0000000..72c06d8 --- /dev/null +++ b/lua/plugins/which-key.lua @@ -0,0 +1,4 @@ +return { + 'folke/which-key.nvim', + config = true +} From b6e811ab23a4d67c233842fd1f8dbc6e4695fc07 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 28 Dec 2022 21:40:46 +0100 Subject: [PATCH 28/38] small neogen fix --- lua/plugins/neogen.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/neogen.lua b/lua/plugins/neogen.lua index 4937074..432abba 100644 --- a/lua/plugins/neogen.lua +++ b/lua/plugins/neogen.lua @@ -25,7 +25,7 @@ return { { 'n', function() - require('neogen').generate() + require('neogen').generate({}) end, desc = 'Add comment', } From 1e7fd727c23e663a73c9bba57ecc80a0c92cc701 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 28 Dec 2022 21:45:23 +0100 Subject: [PATCH 29/38] fixed warnings in lsp config --- lua/plugins/lspconfig.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index ffa4c2f..ecfe3b5 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -13,7 +13,7 @@ return { automatic_installation = false, }) - local capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) + local capabilities = require('cmp_nvim_lsp').default_capabilities() OpenDiagFloat = function() for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do @@ -69,10 +69,12 @@ return { -- Set some keybinds conditional on server capabilities if client.server_capabilities.documentFormattingProvider then - vim.keymap.set('n', 'f', vim.lsp.buf.format, opts) + vim.keymap.set('n', 'f', vim.lsp.buf.format, + { noremap = true, silent = false, desc = 'Format file', buffer = bufnr }) end if client.server_capabilities.documentRangeFormattingProvider then - vim.keymap.set('x', 'f', vim.lsp.buf.format, opts) + vim.keymap.set('x', 'f', vim.lsp.buf.format, + { noremap = true, silent = false, desc = 'Format visual', buffer = bufnr }) end -- Set autocommands conditional on server_capabilities From 54e87b448e81c5a6e9dbd5b098044d4f19b52b66 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 29 Dec 2022 00:51:41 +0100 Subject: [PATCH 30/38] more keybinding description --- lua/my_keymappings.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lua/my_keymappings.lua b/lua/my_keymappings.lua index 6ddb858..a37c6ce 100644 --- a/lua/my_keymappings.lua +++ b/lua/my_keymappings.lua @@ -25,13 +25,16 @@ vim.keymap.set('x', '<', '', '>gv') local function hlWord() - local current_word = vim.call('expand','') + local current_word = vim.call('expand', '') vim.fn.setreg('/', "\\<" .. current_word .. "\\>") vim.opt.hlsearch = true end + -- Highlight word under cursor -vim.keymap.set('n', "'", hlWord, { noremap = true, silent = true }) -vim.keymap.set('x', "'", 'y/\\V"N', { noremap = true, silent = true }) +vim.keymap.set('n', "'", hlWord, { noremap = true, silent = true, desc = 'Higlight word under cursor' }) +vim.keymap.set('x', "'", 'y/\\V"N', { noremap = true, silent = true, desc = 'Highlight visual' }) -- Close Buffer -vim.keymap.set('n', '', ':bd') +vim.keymap.set('n', '', ':bd', { desc = 'Close buffer' }) + +vim.keymap.set('n', 'x', 'za', { desc = 'Toggle fold' }) From 0c5f81d6d43d738e8c86f6a674c63562eaacd39a Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Mon, 2 Jan 2023 21:46:27 +0100 Subject: [PATCH 31/38] new sign for breakpoint --- lua/plugins/dap.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index dbf6fad..9ab1fc6 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -70,7 +70,7 @@ return { }, config = function() local dap = require('dap') - + vim.fn.sign_define('DapBreakpoint', {text='🛑', texthl='', linehl='', numhl=''}) require("cmp_dap").is_dap_buffer() From 2c57a134e3421b402117f77dc2edf0e7bf6b9e81 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 3 Jan 2023 01:48:40 +0100 Subject: [PATCH 32/38] fixed some keybindings overwritten by which key --- lua/plugins/which-key.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua index 72c06d8..3c4fc71 100644 --- a/lua/plugins/which-key.lua +++ b/lua/plugins/which-key.lua @@ -1,4 +1,12 @@ return { 'folke/which-key.nvim', - config = true + config = { + plugins = { + marks = false, + registers = false, + presets = { + operators = false + } + } + } } From 3a70a67737d4c64988a6a46d164ca82da9af589d Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 3 Jan 2023 01:48:51 +0100 Subject: [PATCH 33/38] added neodev --- lua/plugins/lspconfig.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index ecfe3b5..547e54e 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -6,6 +6,10 @@ return { 'p00f/clangd_extensions.nvim', 'jose-elias-alvarez/null-ls.nvim', 'ray-x/lsp_signature.nvim', + { + 'folke/neodev.nvim', + config = true, + }, }, config = function() require('mason').setup() From 4aa3048e23015d0720e32db6927ea2f131a2727f Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 3 Jan 2023 01:50:51 +0100 Subject: [PATCH 34/38] fixed annoying lua ls message --- lua/plugins/lspconfig.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 547e54e..b575fa0 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -206,6 +206,7 @@ return { workspace = { -- Make the server aware of Neovim runtime files library = vim.api.nvim_get_runtime_file('', true), + checkThirdParty = false, }, -- Do not send telemetry data containing a randomized but unique identifier telemetry = { From c8e1906f22fb2d5ec7646adbb03e5b46de1d1ddf Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 3 Jan 2023 14:30:34 +0100 Subject: [PATCH 35/38] added neotest --- lua/plugins/neotest.lua | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 lua/plugins/neotest.lua diff --git a/lua/plugins/neotest.lua b/lua/plugins/neotest.lua new file mode 100644 index 0000000..363a9eb --- /dev/null +++ b/lua/plugins/neotest.lua @@ -0,0 +1,42 @@ +return { + 'nvim-neotest/neotest', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-treesitter/nvim-treesitter', + 'antoinemadec/FixCursorHold.nvim', + 'nvim-neotest/neotest-python' + }, + config = function() + require("neotest").setup({ + adapters = { + require("neotest-python")({ + dap = { + justMyCode = false + }, + args = { "--log-level", "DEBUG" }, + runner = 'pytest', + python = '.venv/Scripts/python.exe', + -- is_test_file = function(file_path) + -- return file_path:find("^test_") ~= nil + -- end, + }) + } + }) + end, + keys = { + { + '', + function() + require("neotest").run.run() + end, + desc = 'Run nearest test' + }, + { + '', + function() + require("neotest").run.run({ strategy = "dap" }) + end, + desc = 'Run nearest test' + } + } +} From e3c8a5ddd446aacbb0631af95c28baf0fe5635de Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 3 Jan 2023 14:57:47 +0100 Subject: [PATCH 36/38] removed some debug code from neotest --- lua/plugins/neotest.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lua/plugins/neotest.lua b/lua/plugins/neotest.lua index 363a9eb..aecffc2 100644 --- a/lua/plugins/neotest.lua +++ b/lua/plugins/neotest.lua @@ -15,10 +15,6 @@ return { }, args = { "--log-level", "DEBUG" }, runner = 'pytest', - python = '.venv/Scripts/python.exe', - -- is_test_file = function(file_path) - -- return file_path:find("^test_") ~= nil - -- end, }) } }) From 78cbde972f55a44a555be0374908197131732957 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 5 Jan 2023 14:45:38 +0100 Subject: [PATCH 37/38] new keymap to run last dap config --- lua/plugins/dap.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index 9ab1fc6..8b9c987 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -16,7 +16,14 @@ return { function() require('dap').continue() end, - desc = 'DAP continue' + desc = 'DAP start or continue' + }, + { + '', + function() + require('dap').run_last() + end, + desc = 'DAP run last' }, { '', From 5a1a8e8f3efba9295de9299fd04a88428a59a1f8 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 5 Jan 2023 22:23:31 +0100 Subject: [PATCH 38/38] added xmlformat --- lua/plugins/lspconfig.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index b575fa0..750eb0c 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -237,6 +237,7 @@ return { null_ls.builtins.code_actions.gitsigns, null_ls.builtins.formatting.autopep8, null_ls.builtins.formatting.prettier, + null_ls.builtins.formatting.xmlformat, null_ls.builtins.diagnostics.flake8, null_ls.builtins.formatting.isort, null_ls.builtins.formatting.cmake_format,