refactor of nvim config
This commit is contained in:
parent
9914f9cc8d
commit
aa33b73377
@ -22,6 +22,7 @@ require('packer').startup(function()
|
||||
'hrsh7th/cmp-buffer', -- Completion source buffer
|
||||
'hrsh7th/cmp-nvim-lsp', -- Completion source LSP
|
||||
'hrsh7th/cmp-path', -- Completion source filepaths
|
||||
'hrsh7th/cmp-cmdline', -- Completion source for commandline
|
||||
'saadparwaiz1/cmp_luasnip', -- Completion source snippets
|
||||
'ray-x/lsp_signature.nvim' -- Signature when typing
|
||||
}
|
||||
@ -34,6 +35,7 @@ require('packer').startup(function()
|
||||
use 'tpope/vim-commentary' -- Commentary
|
||||
use 'tpope/vim-surround' -- Surrounding
|
||||
use 'tpope/vim-repeat' -- Repeat Surrounding
|
||||
use 'tpope/vim-sleuth' -- Detect Spacing
|
||||
use "tversteeg/registers.nvim" -- Preview Registers
|
||||
use 'windwp/nvim-autopairs' -- Autopairs
|
||||
use 'windwp/nvim-ts-autotag' -- HTML Autopairs
|
||||
@ -48,6 +50,9 @@ require('packer').startup(function()
|
||||
'rust-sailfish/sailfish', -- Sailfish Syntax
|
||||
rtp = 'syntax/vim'
|
||||
}
|
||||
use 'ggandor/leap.nvim' -- Jump around in file
|
||||
use 'mfussenegger/nvim-dap' -- Debugger Adapter Protocol
|
||||
use 'rcarriga/nvim-dap-ui' -- UI for DAP
|
||||
end)
|
||||
|
||||
-- General Editor Settings
|
||||
@ -66,10 +71,11 @@ opt.statusline = ' %f %r %m%=%y %{&fileencoding?&fileencoding:&encoding}[%{&file
|
||||
|
||||
opt.completeopt = 'menuone,noinsert,noselect'
|
||||
|
||||
map('n', 'ZT', '<cmd>w<cr>', { noremap = true })
|
||||
map('n', '<Space>w', '<cmd>w<cr>', { noremap = true })
|
||||
map('n', '<Space>q', '<cmd>wq<cr>', { noremap = true })
|
||||
map('n', 'ZO', '<cmd>!compiler %<cr>', { noremap = true })
|
||||
map('n', 'ZK', '<cmd>!kdeconnect-cli -d 3993d52f1018a472 --share %<cr>', { noremap = true })
|
||||
map('n', '<leader>/', '<cmd>let @/ = ""<cr>', { noremap = true })
|
||||
map('n', '<Esc><Esc>', '<cmd>let @/ = ""<cr>', { noremap = true })
|
||||
map('n', '<leader>plp', '<cmd>!feh %:s?pu?png? &<cr>', { noremap = true })
|
||||
|
||||
-- Splits
|
||||
@ -83,18 +89,6 @@ opt.splitright = true
|
||||
|
||||
-- Identation with autocmd
|
||||
augroup('programming', {})
|
||||
autocmd('FileType', {
|
||||
group = 'programming',
|
||||
desc = 'Set identation to two spaces for filetypes in {pattern}',
|
||||
pattern = { 'lua', 'html', 'css', 'scss', 'sass', 'less', 'htmldjango', 'sailfish', 'typescript', 'typescriptreact', 'javascript', 'javascriptreact', 'haskell' },
|
||||
command = 'setlocal ts=2 sw=2 sts=2 expandtab'
|
||||
})
|
||||
autocmd('FileType', {
|
||||
group = 'programming',
|
||||
desc = 'Set identation to one tab for filetypes in {pattern}',
|
||||
pattern = { 'python' },
|
||||
command = 'setlocal ts=4 sw=4 sts=4 expandtab'
|
||||
})
|
||||
autocmd({ 'BufNewFile', 'BufRead' }, {
|
||||
group = 'programming',
|
||||
desc = 'Set Filetype to sailfish for .stpl files',
|
||||
@ -103,7 +97,6 @@ augroup('programming', {})
|
||||
})
|
||||
vim.cmd("au BufRead *.yaml,*.yml if search('hosts:\\|tasks:\\|ansible.builtin', 'nw') | set ft=yaml.ansible | endif")
|
||||
|
||||
|
||||
-- Spellcheck
|
||||
_G.enable_spell = function(lang)
|
||||
vim.bo.spelllang = lang
|
||||
@ -160,89 +153,75 @@ local on_attach = function(client, bufnr)
|
||||
}, bufnr)
|
||||
end
|
||||
|
||||
local runtime_path = vim.split(package.path, ';')
|
||||
table.insert(runtime_path, "lua/?.lua")
|
||||
table.insert(runtime_path, "lua/?/init.lua")
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
local servers = { 'rust_analyzer', 'texlab', 'pyright', 'tsserver', 'ccls', 'html', 'yamlls', 'ansiblels', 'csharp_ls',
|
||||
'hls' }
|
||||
for _, server in ipairs(servers) do
|
||||
lsp[server].setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
end
|
||||
|
||||
lsp.sumneko_lua.setup {
|
||||
cmd = {"lua-language-server"},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||
version = 'LuaJIT',
|
||||
path = runtime_path,
|
||||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = { 'vim' },
|
||||
},
|
||||
workspace = {
|
||||
-- Make the server aware of Neovim runtime files
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
lsp.rust_analyzer.setup {
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
lsp.texlab.setup {
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
lsp.pyright.setup {
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
lsp.tsserver.setup{
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
lsp.ccls.setup {
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
lsp.cssls.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
lsp.html.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
lsp.yamlls.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
lsp.ansiblels.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
lsp.csharp_ls.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
lsp.hls.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
},
|
||||
}
|
||||
|
||||
-- Autopairs
|
||||
require 'nvim-ts-autotag'.setup()
|
||||
require 'nvim-autopairs'.setup {}
|
||||
|
||||
-- Snippets
|
||||
local ls = require('luasnip')
|
||||
local types = require('luasnip.util.types')
|
||||
|
||||
ls.config.set_config({
|
||||
history = true,
|
||||
updateevents = "TextChanged,TextChangedI",
|
||||
ext_opts = {
|
||||
[types.choiceNode] = {
|
||||
active = {
|
||||
virt_text = { { "●", "Function" } }
|
||||
}
|
||||
},
|
||||
[types.insertNode] = {
|
||||
active = {
|
||||
virt_text = { { "●", "Comment" } }
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/lua/snippets" })
|
||||
|
||||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
-- Completion
|
||||
local cmp = require('cmp')
|
||||
cmp.setup {
|
||||
@ -253,7 +232,34 @@ cmp.setup {
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-x>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }),
|
||||
['<C-Space>'] = cmp.mapping.confirm({behavior = cmp.ConfirmBehavior.Insert, select = true })
|
||||
['<C-Space>'] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif ls.expand_or_locally_jumpable() then
|
||||
ls.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif ls.locally_jumpable(-1) then
|
||||
ls.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
['<C-e>'] = cmp.mapping(function(fallback)
|
||||
if ls.choice_active() then
|
||||
ls.change_choice(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' })
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
@ -268,56 +274,22 @@ cmp.setup {
|
||||
}
|
||||
}
|
||||
|
||||
-- Snippets
|
||||
local ls = require('luasnip')
|
||||
local types = require('luasnip.util.types')
|
||||
|
||||
ls.config.set_config({
|
||||
history = true,
|
||||
updateevents = "TextChanged,TextChangedI",
|
||||
ext_opts = {
|
||||
[types.choiceNode] = {
|
||||
active = {
|
||||
virt_text = { { "[C]", "Comment" } },
|
||||
},
|
||||
},
|
||||
[types.insertNode] = {
|
||||
active = {
|
||||
virt_text = { { "[I]", "Comment" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- Helper Termcode wrapper
|
||||
local to_term = function(str)
|
||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||
end
|
||||
|
||||
_G.next_opt = function()
|
||||
if ls and ls.expand_or_jumpable() then
|
||||
return to_term "<Plug>luasnip-expand-or-jump"
|
||||
else
|
||||
return to_term "<Tab>"
|
||||
end
|
||||
end
|
||||
|
||||
_G.prev_opt = function()
|
||||
if ls and ls.jumpable(-1) then
|
||||
return to_term "<Plug>luasnip-jump-prev"
|
||||
else
|
||||
return to_term "<S-Tab>"
|
||||
end
|
||||
end
|
||||
|
||||
map("i", "<C-E>", "<Plug>luasnip-next-choice", {})
|
||||
map("s", "<C-E>", "<Plug>luasnip-next-choice", {})
|
||||
map("i", "<Tab>", "v:lua.next_opt()", {expr = true})
|
||||
map("s", "<Tab>", "v:lua.next_opt()", {expr = true})
|
||||
map("i", "<S-Tab>", "v:lua.prev_opt()", {expr = true})
|
||||
map("s", "<S-Tab>", "v:lua.prev_opt()", {expr = true})
|
||||
|
||||
require("luasnip.loaders.from_lua").load({paths = "~/.config/nvim/lua/snippets"})
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
|
||||
-- Treesitter
|
||||
require('nvim-treesitter.configs').setup {
|
||||
@ -428,3 +400,39 @@ require('colorizer').setup({
|
||||
css_fn = false; -- Enable all CSS *functions*: rgb_fn, hsl_fn
|
||||
mode = 'background'; -- Set the display mode.
|
||||
})
|
||||
|
||||
-- Leap
|
||||
require('leap').add_default_mappings()
|
||||
|
||||
-- Debugger Adapter Protocol
|
||||
local dap = require('dap')
|
||||
|
||||
dap.adapters.codelldb = {
|
||||
type = 'server',
|
||||
port = "${port}",
|
||||
executable = {
|
||||
command = '/usr/bin/codelldb',
|
||||
args = { "--port", "${port}" },
|
||||
}
|
||||
}
|
||||
|
||||
dap.configurations.rust = {
|
||||
{
|
||||
name = "Launch file",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = '${workspaceFolder}',
|
||||
stopOnEntry = false,
|
||||
},
|
||||
}
|
||||
|
||||
map('n', '<Leader>dc', '<cmd>lua require"dap".continue()<cr>', { noremap = true })
|
||||
map('n', '<Leader>db', '<cmd>lua require"dap".toggle_breakpoint()<cr>', { noremap = true })
|
||||
map('n', '<Leader>do', '<cmd>lua require"dap".step_over()<cr>', { noremap = true })
|
||||
map('n', '<Leader>di', '<cmd>lua require"dap".step_into()<cr>', { noremap = true })
|
||||
|
||||
require("dapui").setup()
|
||||
map('n', '<Leader>dd', '<cmd>lua require"dapui".toggle()<cr>', { noremap = true })
|
||||
|
@ -64,3 +64,4 @@
|
||||
# TODO ansible-language-server AUR
|
||||
# TODO csharp-ls dotnet tool
|
||||
# TODO vscode-langservers-extracted AUR
|
||||
# TODO codelldb-bin AUR -> C/C++/Rust Debugger
|
||||
|
@ -80,6 +80,8 @@ topicItems =
|
||||
, TI "InternalVertecApi" "~/projekte/InternalVertecAPI" (switchToLayout "Programming" *> spawn "rider ~/projekte/InternalVertecAPI/InternalVertecAPI.sln")
|
||||
, TI "Abwesenheitskalender_Frontend" "~/projekte/Abwesenheitskalender_Frontend" (switchToLayout "Programming" *> spawnShellAndExecute "npm start" *> spawnShell *> spawnEditor)
|
||||
, TI "aoc" "~/projekte/aoc" (switchToLayout "Programming" *> spawnShell *> spawnEditor)
|
||||
, TI "STracker_Frontend" "~/projekte/SchulungsTracker/Frontend" (switchToLayout "Programming" *> spawnShellAndExecute "npm start" *> spawnShell *> spawnEditor)
|
||||
, TI "STracker_Backend" "~/projekte/SchulungsTracker/Backend" (switchToLayout "Full" *> spawnShellAndExecute "rider ~/projekte/SchulungsTracker/Backend/Schulungstracker.backend.sln")
|
||||
]
|
||||
|
||||
myTopicConfig :: TopicConfig
|
||||
|
Loading…
Reference in New Issue
Block a user