diff --git a/init.lua b/init.lua index 496a039..93e408b 100644 --- a/init.lua +++ b/init.lua @@ -1,7 +1,7 @@ vim.g.mapleader = ',' if not vim.g.vscode then - require('my_plugins') + require('config.lazy') require('my_keymappings') - require('my_options') require('my_autocommands') + require('config.options') end 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 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 95% rename from lua/my_options.lua rename to lua/config/options.lua index dc33c6b..e2aa99f 100644 --- a/lua/my_options.lua +++ b/lua/config/options.lua @@ -1,62 +1,63 @@ -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' +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 +-- 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_keymappings.lua b/lua/my_keymappings.lua index f93b93a..a37c6ce 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) @@ -26,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' }) 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/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..70bd50f --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,171 @@ +return { + 'hrsh7th/nvim-cmp', + dependencies = { + { 'onsails/lspkind-nvim' }, + { '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' }, + { '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/dap.lua b/lua/plugins/dap.lua new file mode 100644 index 0000000..8b9c987 --- /dev/null +++ b/lua/plugins/dap.lua @@ -0,0 +1,254 @@ +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 start or continue' + }, + { + '', + function() + require('dap').run_last() + end, + desc = 'DAP run last' + }, + { + '', + 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') + vim.fn.sign_define('DapBreakpoint', {text='🛑', texthl='', linehl='', numhl=''}) + 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 _, config in pairs(dap.configurations.python) do + config.pythonPath = getPythonEnv() + config.cwd = vim.fn.getcwd() + end + require 'telescope'.extensions.dap.configurations {} + end + + 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 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/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/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/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/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 new file mode 100644 index 0000000..058678e --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1,2 @@ +return { +} 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/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua new file mode 100644 index 0000000..750eb0c --- /dev/null +++ b/lua/plugins/lspconfig.lua @@ -0,0 +1,252 @@ +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', + { + 'folke/neodev.nvim', + config = true, + }, + }, + config = function() + require('mason').setup() + require('mason-lspconfig').setup({ + automatic_installation = false, + }) + + local capabilities = require('cmp_nvim_lsp').default_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. + 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, + { 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()]]) + + -- Set some keybinds conditional on server capabilities + if client.server_capabilities.documentFormattingProvider then + 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, + { noremap = true, silent = false, desc = 'Format visual', buffer = bufnr }) + 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), + checkThirdParty = false, + }, + -- 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.formatting.xmlformat, + 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/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/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/neogen.lua b/lua/plugins/neogen.lua new file mode 100644 index 0000000..432abba --- /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/neotest.lua b/lua/plugins/neotest.lua new file mode 100644 index 0000000..aecffc2 --- /dev/null +++ b/lua/plugins/neotest.lua @@ -0,0 +1,38 @@ +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', + }) + } + }) + end, + keys = { + { + '', + function() + require("neotest").run.run() + end, + desc = 'Run nearest test' + }, + { + '', + function() + require("neotest").run.run({ strategy = "dap" }) + end, + desc = 'Run nearest test' + } + } +} 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/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/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/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 new file mode 100644 index 0000000..b9e78a0 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,167 @@ +return { + 'nvim-telescope/telescope.nvim', + dependencies = { + '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' + }, + }, + 'nvim-telescope/telescope-ui-select.nvim', + 'ahmedkhalf/project.nvim', + }, + 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', + }, + { + 'p', + function() + require('telescope').extensions.projects.projects() + end, + desc = 'Select project', + }, + }, + config = function() + local actions = require('telescope.actions') + + local mappingTab = { + i = { + [''] = actions.select_tab, + [''] = actions.select_default, + }, + } + + 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 = { + 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") + require('telescope').load_extension('fzf') + -- require('telescope').load_extension('projects') + end +} 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/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/plugins/which-key.lua b/lua/plugins/which-key.lua new file mode 100644 index 0000000..3c4fc71 --- /dev/null +++ b/lua/plugins/which-key.lua @@ -0,0 +1,12 @@ +return { + 'folke/which-key.nvim', + config = { + plugins = { + marks = false, + registers = false, + presets = { + operators = false + } + } + } +} 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/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_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_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_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_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() diff --git a/lua/setup/my_overseer.lua b/lua/setup/my_overseer.lua deleted file mode 100644 index 9954872..0000000 --- a/lua/setup/my_overseer.lua +++ /dev/null @@ -1,9 +0,0 @@ -local overseer = require('overseer') -overseer.setup({ - templates = { "builtin", "user.cmake.cmake" }, -}) - -vim.keymap.set({ 'n', 'x' }, '', function() - overseer.open() - overseer.run_template() -end, opts) 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/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', - } - } -) diff --git a/lua/setup/project.lua b/lua/setup/project.lua deleted file mode 100644 index 0e735ff..0000000 --- a/lua/setup/project.lua +++ /dev/null @@ -1,6 +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') 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/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. 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', - }, - } -)