This commit is contained in:
Oliver Hartmann
2023-01-09 08:39:37 +01:00
46 changed files with 1497 additions and 758 deletions

View File

@@ -1,13 +0,0 @@
require('Comment').setup({
mappings = false,
})
require('legendary').keymap(
{
'<c-c>',
{
n = '<Plug>(comment_toggle_linewise_current)',
v = '<Plug>(comment_toggle_linewise_visual)gv'
},
description = 'Toggle comment'
}
)

View File

@@ -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,
},
})

View File

@@ -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' },
})

View File

@@ -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 = {}
},
})

View File

@@ -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<CR>',
description = 'List snippets',
}
}
)

View File

@@ -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 = {
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c', 's' }),
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c', 's' }),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }),
['<C-e>'] = cmp.mapping(cmp.mapping.close(), { 'i', 'c', 's' }),
['<CR>'] = cmp.mapping({
i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }),
c = cmp.mapping.confirm({ select = false }),
s = cmp.mapping.confirm({ select = false }),
}),
['<Tab>'] = cmp.mapping(function(fallback)
if luasnip.expand_or_jumpable() then
vim.api.nvim_feedkeys(t('<Plug>luasnip-expand-or-jump'), '', true)
else
fallback()
end
end, {
'i',
's',
}),
['<S-Tab>'] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
vim.api.nvim_feedkeys(t('<Plug>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 = '' } }))

View File

@@ -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', '<esc>', [[<C-\><C-n>]], 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', '<F5>', dap.continue, opts)
vim.keymap.set('n', '<F6>', loadConfigs, opts)
vim.keymap.set('n', '<F7>', dap.goto_, opts)
vim.keymap.set('n', '<F8>', require('dap.ui.widgets').hover, opts)
vim.keymap.set('n', '<F9>', dap.toggle_breakpoint, opts)
vim.keymap.set('n', '<F10>', dap.step_over, opts)
vim.keymap.set('n', '<F11>', dap.step_into, opts)
vim.keymap.set('n', '<S-F11>', 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')

View File

@@ -1,3 +0,0 @@
local actions = require("diffview.actions")
require("diffview").setup({})

View File

@@ -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')

View File

@@ -1 +0,0 @@
require('leap').set_default_keymaps()

View File

@@ -1,9 +0,0 @@
local overseer = require('overseer')
overseer.setup({
templates = { "builtin", "user.cmake.cmake" },
})
vim.keymap.set({ 'n', 'x' }, '<F4>', function()
overseer.open()
overseer.run_template()
end, opts)

View File

@@ -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 = {
['<space>'] = 'toggle_node',
['<2-LeftMouse>'] = 'open',
['<cr>'] = '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', '\\', '<cmd>Neotree reveal<cr>')

View File

@@ -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(
{
{
'<leader>n',
':Neogen<CR>',
description = 'Add comment',
}
}
)

View File

@@ -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')

View File

@@ -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', '<esc>', [[<C-\><C-n>]], opts)
end
vim.api.nvim_buf_set_keymap(term.bufnr, 't', 'jk', [[<C-\><C-n>]], opts)
vim.api.nvim_buf_set_keymap(term.bufnr, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
vim.api.nvim_buf_set_keymap(term.bufnr, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
vim.api.nvim_buf_set_keymap(term.bufnr, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts)
vim.api.nvim_buf_set_keymap(term.bufnr, 't', '<C-l>', [[<C-\><C-n><C-W>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", "<cmd>close<CR>", { noremap = true, silent = true })
-- vim.api.nvim_buf_set_keymap(term.bufnr, 't', '<esc>', '<esc>', {noremap = true, silent = true})
end,
})
function _lazygit_toggle()
lazygit:toggle()
end
require('legendary').keymaps(
{
{
'<Space>g',
':lua _lazygit_toggle()<CR>',
description = 'Open lazygit',
}
}
)

View File

@@ -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 = {
["<leader>df"] = "@function.outer",
["<leader>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.

View File

@@ -1,27 +0,0 @@
require('yanky').setup()
vim.api.nvim_set_keymap('n', 'p', '<Plug>(YankyPutAfter)', {})
vim.api.nvim_set_keymap('n', 'P', '<Plug>(YankyPutBefore)', {})
vim.api.nvim_set_keymap('x', 'p', '<Plug>(YankyPutAfter)', {})
vim.api.nvim_set_keymap('x', 'P', '<Plug>(YankyPutBefore)', {})
vim.api.nvim_set_keymap('n', 'gp', '<Plug>(YankyGPutAfter)', {})
vim.api.nvim_set_keymap('n', 'gP', '<Plug>(YankyGPutBefore)', {})
vim.api.nvim_set_keymap('x', 'gp', '<Plug>(YankyGPutAfter)', {})
vim.api.nvim_set_keymap('x', 'gP', '<Plug>(YankyGPutBefore)', {})
vim.keymap.set("n", "<c-n>", "<Plug>(YankyCycleForward)", {})
vim.keymap.set("n", "<c-p>", "<Plug>(YankyCycleBackward)", {})
require("telescope").load_extension('yank_history')
require('legendary').keymaps(
{
{
'<c-n>',
'<Plug>(YankyCycleForward)',
description = 'Yanky cycle forward',
},
{
'<c-p>',
'<Plug>(YankyCycleBackward)',
description = 'Yanky cycle backward',
},
}
)