Integrate neovim config into home-manager, separate external configs under config/
This commit is contained in:
26
config/nvim/lua/eliaskohout-old/after/plugin/cmp.lua
Executable file
26
config/nvim/lua/eliaskohout-old/after/plugin/cmp.lua
Executable file
@@ -0,0 +1,26 @@
|
||||
-- cmp
|
||||
|
||||
local cmp = require('cmp')
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
expand = function(args)
|
||||
vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
["<C-j>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
|
||||
["<C-k>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' }, },
|
||||
{ { name = 'buffer' }, }
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
30
config/nvim/lua/eliaskohout-old/after/plugin/dap-python.lua
Executable file
30
config/nvim/lua/eliaskohout-old/after/plugin/dap-python.lua
Executable file
@@ -0,0 +1,30 @@
|
||||
local dap = require('dap')
|
||||
local dap_python = require('dap-python')
|
||||
|
||||
dap_python.setup('uv') -- or wherever your debugpy-enabled python is
|
||||
|
||||
dap.adapters.python = {
|
||||
type = 'server',
|
||||
host = '127.0.0.1',
|
||||
port = 5678,
|
||||
}
|
||||
|
||||
dap.configurations.python = {
|
||||
{
|
||||
type = 'python',
|
||||
request = 'attach',
|
||||
name = "Attach to remote",
|
||||
connect = {
|
||||
host = "127.0.0.1",
|
||||
port = 5678,
|
||||
},
|
||||
mode = "remote",
|
||||
pathMappings = {
|
||||
{
|
||||
localRoot = vim.fn.getcwd(),
|
||||
remoteRoot = "/home/mmc-user/fair-psgg"
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
26
config/nvim/lua/eliaskohout-old/after/plugin/dap.lua
Executable file
26
config/nvim/lua/eliaskohout-old/after/plugin/dap.lua
Executable file
@@ -0,0 +1,26 @@
|
||||
-- nvim-dap
|
||||
|
||||
vim.keymap.set('n', '<Leader>dc', function() require('dap').continue() end)
|
||||
vim.keymap.set('n', '<Leader>dn', function() require('dap').step_over() end)
|
||||
vim.keymap.set('n', '<Leader>di', function() require('dap').step_into() end)
|
||||
vim.keymap.set('n', '<Leader>do', function() require('dap').step_out() end)
|
||||
vim.keymap.set('n', '<Leader>db', function() require('dap').toggle_breakpoint() end)
|
||||
--vim.keymap.set('n', '<Leader>dB', function() require('dap').set_breakpoint() end)
|
||||
--vim.keymap.set('n', '<Leader>lp', function() require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) end)
|
||||
vim.keymap.set('n', '<Leader>dr', function() require('dap').repl.open() end)
|
||||
--vim.keymap.set('n', '<Leader>dl', function() require('dap').run_last() end)
|
||||
vim.keymap.set({'n', 'v'}, '<Leader>dh', function()
|
||||
require('dap.ui.widgets').hover()
|
||||
end)
|
||||
vim.keymap.set({'n', 'v'}, '<Leader>dp', function()
|
||||
require('dap.ui.widgets').preview()
|
||||
end)
|
||||
vim.keymap.set('n', '<Leader>df', function()
|
||||
local widgets = require('dap.ui.widgets')
|
||||
widgets.centered_float(widgets.frames)
|
||||
end)
|
||||
vim.keymap.set('n', '<Leader>ds', function()
|
||||
local widgets = require('dap.ui.widgets')
|
||||
widgets.centered_float(widgets.scopes)
|
||||
end)
|
||||
|
||||
15
config/nvim/lua/eliaskohout-old/after/plugin/dapui.lua
Executable file
15
config/nvim/lua/eliaskohout-old/after/plugin/dapui.lua
Executable file
@@ -0,0 +1,15 @@
|
||||
local dap = require("dap")
|
||||
local dapui = require("dapui")
|
||||
|
||||
dapui.setup() -- Use defaults, or customize below
|
||||
|
||||
-- Auto-open and close UI with debugger
|
||||
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
|
||||
3
config/nvim/lua/eliaskohout-old/after/plugin/fugitive.lua
Executable file
3
config/nvim/lua/eliaskohout-old/after/plugin/fugitive.lua
Executable file
@@ -0,0 +1,3 @@
|
||||
-- vim-fugitive
|
||||
|
||||
vim.keymap.set("n", "<leader>g", vim.cmd.Git)
|
||||
6
config/nvim/lua/eliaskohout-old/after/plugin/gruvbox.lua
Executable file
6
config/nvim/lua/eliaskohout-old/after/plugin/gruvbox.lua
Executable file
@@ -0,0 +1,6 @@
|
||||
-- gruvbox theme
|
||||
|
||||
vim.g.gruvbox_improved_strings = 1
|
||||
vim.g.gruvbox_improved_warnings = 1
|
||||
|
||||
vim.cmd("silent! colorscheme gruvbox")
|
||||
12
config/nvim/lua/eliaskohout-old/after/plugin/harpoon.lua
Executable file
12
config/nvim/lua/eliaskohout-old/after/plugin/harpoon.lua
Executable file
@@ -0,0 +1,12 @@
|
||||
-- harpoon
|
||||
|
||||
local mark = require("harpoon.mark")
|
||||
local ui = require("harpoon.ui")
|
||||
|
||||
vim.keymap.set("n", "<leader>a", mark.add_file)
|
||||
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
|
||||
|
||||
vim.keymap.set("n", "<C-j>", function() ui.nav_file(1) end)
|
||||
vim.keymap.set("n", "<C-k>", function() ui.nav_file(2) end)
|
||||
vim.keymap.set("n", "<C-l>", function() ui.nav_file(3) end)
|
||||
vim.keymap.set("n", "<C-ö>", function() ui.nav_file(4) end)
|
||||
46
config/nvim/lua/eliaskohout-old/after/plugin/lspattach.lua
Executable file
46
config/nvim/lua/eliaskohout-old/after/plugin/lspattach.lua
Executable file
@@ -0,0 +1,46 @@
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
desc = 'LSP actions',
|
||||
callback = function()
|
||||
local bufmap = function(mode, lhs, rhs)
|
||||
local opts = {buffer = true}
|
||||
vim.keymap.set(mode, lhs, rhs, opts)
|
||||
end
|
||||
|
||||
-- Displays hover information about the symbol under the cursor
|
||||
bufmap('n', 'K', vim.lsp.buf.hover)
|
||||
|
||||
-- Jump to the definition
|
||||
bufmap('n', 'gd', vim.lsp.buf.definition)
|
||||
|
||||
-- Jump to declaration
|
||||
bufmap('n', 'gD', vim.lsp.buf.declaration)
|
||||
|
||||
-- Lists all the implementations for the symbol under the cursor
|
||||
bufmap('n', 'gi', vim.lsp.buf.implementation)
|
||||
|
||||
-- Jumps to the definition of the type symbol
|
||||
bufmap('n', 'go', vim.lsp.buf.type_definition)
|
||||
|
||||
-- Lists all the references
|
||||
bufmap('n', 'gr', vim.lsp.buf.references)
|
||||
|
||||
-- Displays a function's signature information
|
||||
bufmap('n', 'gs', vim.lsp.buf.signature_help)
|
||||
|
||||
-- Renames all references to the symbol under the cursor
|
||||
bufmap('n', '<F2>', vim.lsp.buf.rename)
|
||||
|
||||
-- Selects a code action available at the current cursor position
|
||||
bufmap('n', '<F4>', vim.lsp.buf.code_action)
|
||||
|
||||
-- Show diagnostics in a floating window
|
||||
bufmap('n', 'gl', vim.diagnostic.open_float)
|
||||
|
||||
-- Move to the previous diagnostic
|
||||
bufmap('n', '[d', vim.diagnostic.goto_prev)
|
||||
|
||||
-- Move to the next diagnostic
|
||||
bufmap('n', ']d', vim.diagnostic.goto_next)
|
||||
end
|
||||
})
|
||||
46
config/nvim/lua/eliaskohout-old/after/plugin/lspconfig.lua
Executable file
46
config/nvim/lua/eliaskohout-old/after/plugin/lspconfig.lua
Executable file
@@ -0,0 +1,46 @@
|
||||
-- nvim-lspconfig
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
-- set capabilities
|
||||
local lsp_capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
-- lua --
|
||||
local on_init_lua_ls = function(client)
|
||||
local path = client.workspace_folders[1].name
|
||||
if vim.loop.fs_stat(path..'/.luarc.json') or vim.loop.fs_stat(path..'/.luarc.jsonc') then
|
||||
return
|
||||
end
|
||||
|
||||
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
|
||||
runtime = {
|
||||
version = 'LuaJIT'
|
||||
},
|
||||
-- Make the server aware of Neovim runtime files
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
library = {
|
||||
vim.env.VIMRUNTIME
|
||||
}
|
||||
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
|
||||
-- library = vim.api.nvim_get_runtime_file("", true)
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
lspconfig.lua_ls.setup({
|
||||
on_init = on_init_lua_ls,
|
||||
settings = { Lua = {} },
|
||||
capabilities = lsp_capabilities,
|
||||
})
|
||||
|
||||
-- python --
|
||||
lspconfig.pyright.setup({
|
||||
capabilities = lsp_capabilities,
|
||||
})
|
||||
lspconfig.ruff.setup({ init_options = { settings = {} } })
|
||||
|
||||
-- golang --
|
||||
lspconfig.gopls.setup({
|
||||
capabilities = lsp_capabilities,
|
||||
})
|
||||
9
config/nvim/lua/eliaskohout-old/after/plugin/telescope.lua
Executable file
9
config/nvim/lua/eliaskohout-old/after/plugin/telescope.lua
Executable file
@@ -0,0 +1,9 @@
|
||||
-- telescope.nvim
|
||||
|
||||
local builtin = require('telescope.builtin')
|
||||
|
||||
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
|
||||
vim.keymap.set('n', '<C-p>', builtin.git_files, {})
|
||||
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
|
||||
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
|
||||
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
|
||||
7
config/nvim/lua/eliaskohout-old/after/plugin/treesitter.lua
Executable file
7
config/nvim/lua/eliaskohout-old/after/plugin/treesitter.lua
Executable file
@@ -0,0 +1,7 @@
|
||||
-- nvim-treesitter.lua
|
||||
|
||||
local treesitter_configs = require('nvim-treesitter.configs')
|
||||
|
||||
treesitter_configs.setup({
|
||||
ensure_installed = { "bash", "c", "lua", "vim", "vimdoc", "markdown", "markdown_inline", "html", "python", "css" },
|
||||
})
|
||||
5
config/nvim/lua/eliaskohout-old/after/plugin/vimwiki.lua
Executable file
5
config/nvim/lua/eliaskohout-old/after/plugin/vimwiki.lua
Executable file
@@ -0,0 +1,5 @@
|
||||
-- vimwiki
|
||||
|
||||
--vim.keymap.set("n", "<leader>ww", ":e ~/Documents/notes/index.wiki<CR>")
|
||||
vim.cmd("let g:vimwiki_list = [{'path': '~/Documents/notes/', 'syntax': 'markdown', 'ext': '.md'}]")
|
||||
vim.cmd("eval g:vimwiki#vars#init()")
|
||||
2877
config/nvim/lua/eliaskohout-old/autoload/plug.vim
Executable file
2877
config/nvim/lua/eliaskohout-old/autoload/plug.vim
Executable file
File diff suppressed because it is too large
Load Diff
2867
config/nvim/lua/eliaskohout-old/autoload/plug.vim.old
Executable file
2867
config/nvim/lua/eliaskohout-old/autoload/plug.vim.old
Executable file
File diff suppressed because it is too large
Load Diff
5
config/nvim/lua/eliaskohout-old/init.lua
Executable file
5
config/nvim/lua/eliaskohout-old/init.lua
Executable file
@@ -0,0 +1,5 @@
|
||||
require("custom.run")
|
||||
|
||||
require("plug")
|
||||
require("set")
|
||||
require("remap")
|
||||
105
config/nvim/lua/eliaskohout-old/lua/custom/run.lua
Executable file
105
config/nvim/lua/eliaskohout-old/lua/custom/run.lua
Executable file
@@ -0,0 +1,105 @@
|
||||
vim.g.run__cmd = function(cmd, opts)
|
||||
-- Runs a command either locally on a server using ssh. For running on a server define the 'server' option. The
|
||||
-- 'server_cwd' option might be set as well to define the working directory on the server.
|
||||
--@param cmd table
|
||||
--@param opt table
|
||||
|
||||
opts = opts or {};
|
||||
opts.server_cwd = (opts.server_cwd or "~");
|
||||
|
||||
if opts.server ~= nil then
|
||||
local cmdstr = table.concat(cmd, " ");
|
||||
cmd = { "ssh", opts.server, "cd " .. opts.server_cwd .. " && " .. cmdstr };
|
||||
end
|
||||
|
||||
local result = vim.system(cmd, { text = true }):wait();
|
||||
if result.code ~= 0 then
|
||||
error("\n" .. result.code .. "\n" .. result.stdout .. "\n" .. result.stderr);
|
||||
end
|
||||
|
||||
vim.print(result.stdout);
|
||||
end
|
||||
|
||||
|
||||
vim.g.run__gen_path = function(identifier)
|
||||
-- Generates a path in /tmp/ based on the identifier and a hash function.
|
||||
--@param identifier string
|
||||
|
||||
local hash = vim.fn.sha256(identifier);
|
||||
return "/tmp/rsyncrun/" .. string.sub(hash, 1, 12) .. "/";
|
||||
end
|
||||
|
||||
|
||||
vim.g.run__file = function(filename, opts)
|
||||
-- Executes a file based on the vim file type and predefined commands. Options might be set that will be parsed
|
||||
-- to the vim.g.run__cmd function.
|
||||
--@param filename string
|
||||
--@param opts table
|
||||
|
||||
local cmd = {
|
||||
python = function() vim.g.run__cmd({ "python3", filename }, opts) end,
|
||||
go = function() vim.g.run__cmd({ "go", "run", filename }, opts) end,
|
||||
lua = function()
|
||||
vim.cmd("source " .. filename); vim.print("Sourced current file.");
|
||||
end,
|
||||
};
|
||||
|
||||
local ft = vim.filetype.match({ filename = filename })
|
||||
|
||||
if cmd[ft] == nil
|
||||
then
|
||||
print("No run command defined for filetype '" .. vim.bo.filetype .. "'.");
|
||||
else
|
||||
cmd[vim.bo.filetype]();
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
vim.g.run__current_file = function(opts)
|
||||
-- Executes the currently opened file based on the vim file type and predefined commands. Options might be set
|
||||
-- that will be parsed to the vim.g.run__cmd function.
|
||||
--@param opts table
|
||||
|
||||
local filename = vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf());
|
||||
if filename == "" then return; end;
|
||||
vim.cmd.write();
|
||||
vim.g.run__file(filename, opts);
|
||||
end
|
||||
|
||||
|
||||
vim.g.run__file_on_server = function(filename, opts)
|
||||
-- Runs a given file on a server after rsyncing the current directory to the server. The cmd is executed in the
|
||||
-- rsync directory on the server. Use the 'rsync_dst_host' option to define the server. The command to run is
|
||||
-- defined by the vim.g.run__file function.
|
||||
--@param filename string
|
||||
--@param opts table
|
||||
|
||||
local rsync_opts = {};
|
||||
opts = opts or {};
|
||||
rsync_opts.rsync_src_dir = (opts.rsync_src_dir or vim.loop.cwd());
|
||||
rsync_opts.rsync_dst_dir = (opts.rsync_dst_dir or vim.g.run__gen_path(rsync_opts.rsync_src_dir));
|
||||
rsync_opts.rsync_dst_host = (opts.rsync_dst_host or error("rsync_dst_host option is required"));
|
||||
|
||||
vim.print("syncing to server...");
|
||||
vim.g.run__cmd({ "mkdir", "-p", rsync_opts.rsync_dst_dir }, { server = rsync_opts.rsync_dst_host });
|
||||
vim.g.run__cmd(
|
||||
{ "rsync", "-r", rsync_opts.rsync_src_dir .. "/", rsync_opts.rsync_dst_host ..
|
||||
":" .. rsync_opts.rsync_dst_dir .. "/" }, {});
|
||||
vim.print("...done.");
|
||||
|
||||
vim.g.run__file(filename, { server = rsync_opts.rsync_dst_host, server_cwd = rsync_opts.rsync_dst_dir });
|
||||
end
|
||||
|
||||
|
||||
vim.g.run__current_file_on_server = function(opts)
|
||||
-- Runs the currently opened file on a server after rsyncing the current directory to the server. The cmd is
|
||||
-- executed in the rsync directory on the server. Use the 'rsync_dst_host' option to define the server. The
|
||||
-- command to run is defined by the vim.g.run__file function.
|
||||
--@param opts table
|
||||
|
||||
local filename = vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf());
|
||||
if filename == "" then return; end;
|
||||
vim.cmd.write();
|
||||
filename = filename:match("^.+/(.+)$") or filename
|
||||
vim.g.run__file_on_server(filename, opts);
|
||||
end
|
||||
33
config/nvim/lua/eliaskohout-old/lua/plug.lua
Executable file
33
config/nvim/lua/eliaskohout-old/lua/plug.lua
Executable file
@@ -0,0 +1,33 @@
|
||||
local vim = vim
|
||||
local Plug = vim.fn["plug#"]
|
||||
|
||||
vim.call("plug#begin")
|
||||
---------
|
||||
|
||||
Plug("morhetz/gruvbox") -- Theme
|
||||
Plug("vimwiki/vimwiki")
|
||||
Plug("tpope/vim-fugitive") -- Git support
|
||||
Plug("ThePrimeagen/harpoon")
|
||||
Plug("nvim-lua/plenary.nvim") -- required for telescope
|
||||
Plug("nvim-telescope/telescope.nvim")
|
||||
Plug("junegunn/goyo.vim")
|
||||
|
||||
Plug("nvim-treesitter/nvim-treesitter", { ["do"] = ":TSUpdate" })
|
||||
|
||||
-- LSP
|
||||
Plug("neovim/nvim-lspconfig")
|
||||
Plug("hrsh7th/cmp-nvim-lsp")
|
||||
Plug("hrsh7th/cmp-buffer")
|
||||
Plug("hrsh7th/cmp-path")
|
||||
Plug("hrsh7th/cmp-cmdline")
|
||||
Plug("hrsh7th/nvim-cmp")
|
||||
|
||||
-- Debugger
|
||||
Plug("mfussenegger/nvim-dap")
|
||||
Plug("mfussenegger/nvim-dap-python")
|
||||
|
||||
Plug("nvim-neotest/nvim-nio") -- required by dap-ui
|
||||
Plug("rcarriga/nvim-dap-ui")
|
||||
|
||||
---------
|
||||
vim.call("plug#end")
|
||||
22
config/nvim/lua/eliaskohout-old/lua/remap.lua
Executable file
22
config/nvim/lua/eliaskohout-old/lua/remap.lua
Executable file
@@ -0,0 +1,22 @@
|
||||
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
|
||||
|
||||
vim.keymap.set("n", "<C-d>", "<C-d>zz")
|
||||
vim.keymap.set("n", "<C-u>", "<C-u>zz")
|
||||
vim.keymap.set("n", "n", "nzzzv")
|
||||
vim.keymap.set("n", "N", "Nzzzv")
|
||||
|
||||
vim.keymap.set("n", "<leader>d", "\"_d")
|
||||
vim.keymap.set("v", "<leader>d", "\"_d")
|
||||
|
||||
vim.keymap.set("n", "<leader>f", vim.lsp.buf.format)
|
||||
|
||||
vim.keymap.set("n", "<leader>s", ":%s/\\<<C-r><C-w>\\>/<C-r><C-w>/gI<Left><Left><Left>")
|
||||
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })
|
||||
|
||||
-- spell checking
|
||||
vim.keymap.set("n", "<leader>o", "<cmd>setlocal spell! spelllang=de_de<CR>")
|
||||
vim.keymap.set("n", "<leader>e", "<cmd>setlocal spell! spelllang=en_en<CR>")
|
||||
vim.keymap.set("n", "<leader>O", "<cmd>setlocal nospell!<CR>")
|
||||
|
||||
-- script run command
|
||||
vim.keymap.set("n", "<leader>r", vim.g.run__current_file, { noremap = true, silent = true })
|
||||
29
config/nvim/lua/eliaskohout-old/lua/set.lua
Executable file
29
config/nvim/lua/eliaskohout-old/lua/set.lua
Executable file
@@ -0,0 +1,29 @@
|
||||
vim.opt.nu = true
|
||||
vim.opt.relativenumber = true
|
||||
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.softtabstop = 4
|
||||
vim.opt.shiftwidth = 4
|
||||
vim.opt.expandtab = true
|
||||
|
||||
vim.opt.smartindent = true
|
||||
|
||||
vim.opt.incsearch = true
|
||||
|
||||
vim.opt.scrolloff = 8
|
||||
vim.opt.signcolumn = "yes"
|
||||
vim.opt.isfname:append("@-@")
|
||||
|
||||
vim.opt.updatetime = 50
|
||||
|
||||
vim.opt.colorcolumn = "120"
|
||||
|
||||
vim.opt.clipboard = "unnamedplus"
|
||||
|
||||
vim.g.mapleader = " "
|
||||
|
||||
vim.opt.completeopt = {'menu', 'menuone', 'noselect'}
|
||||
|
||||
-- Enable filetype detection
|
||||
vim.cmd('filetype on')
|
||||
vim.cmd('filetype plugin on')
|
||||
Reference in New Issue
Block a user