diff options
Diffstat (limited to 'nvim')
| -rw-r--r-- | nvim/lua/config/autocmds.lua | 24 | ||||
| -rw-r--r-- | nvim/lua/config/keymaps.lua | 23 | ||||
| -rw-r--r-- | nvim/lua/config/options.lua | 2 |
3 files changed, 31 insertions, 18 deletions
diff --git a/nvim/lua/config/autocmds.lua b/nvim/lua/config/autocmds.lua index e11b231..647875d 100644 --- a/nvim/lua/config/autocmds.lua +++ b/nvim/lua/config/autocmds.lua | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | -- https://github.com/nvim-treesitter/nvim-treesitter/blob/main/doc/nvim-treesitter.txt | 1 | -- https://github.com/nvim-treesitter/nvim-treesitter/blob/main/doc/nvim-treesitter.txt |
| 2 | vim.api.nvim_create_autocmd('FileType', { | 2 | vim.api.nvim_create_autocmd("FileType", { |
| 3 | pattern = { "c", "cpp", "lua", "typescript" }, | 3 | pattern = { "c", "cpp", "lua", "typescript" }, |
| 4 | callback = function() | 4 | callback = function() |
| 5 | vim.treesitter.start() | 5 | vim.treesitter.start() |
| 6 | vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' | 6 | vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" |
| 7 | vim.wo.foldmethod = 'expr' | 7 | vim.wo.foldmethod = "expr" |
| 8 | vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" | 8 | vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" |
| 9 | end, | 9 | end, |
| 10 | }) | 10 | }) |
| @@ -18,13 +18,11 @@ vim.api.nvim_create_autocmd("VimEnter", { | |||
| 18 | -- buffer is a [No Name] | 18 | -- buffer is a [No Name] |
| 19 | local no_name = data.file == "" and vim.bo[data.buf].buftype == "" | 19 | local no_name = data.file == "" and vim.bo[data.buf].buftype == "" |
| 20 | 20 | ||
| 21 | if not real_file and not no_name then | 21 | if not real_file and not no_name then return end |
| 22 | return | ||
| 23 | end | ||
| 24 | 22 | ||
| 25 | -- open the tree, find the file but don't focus it | 23 | -- open the tree, find the file but don't focus it |
| 26 | require("nvim-tree.api").tree.toggle({ focus = false, find_file = true, }) | 24 | require("nvim-tree.api").tree.toggle({ focus = false, find_file = true }) |
| 27 | end | 25 | end, |
| 28 | }) | 26 | }) |
| 29 | 27 | ||
| 30 | -- https://github.com/nvim-tree/nvim-tree.lua/wiki/Auto-Close | 28 | -- https://github.com/nvim-tree/nvim-tree.lua/wiki/Auto-Close |
| @@ -35,16 +33,16 @@ vim.api.nvim_create_autocmd("QuitPre", { | |||
| 35 | 33 | ||
| 36 | for _, w in ipairs(wins) do | 34 | for _, w in ipairs(wins) do |
| 37 | local bufname = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w)) | 35 | local bufname = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w)) |
| 38 | if bufname:match("NvimTree_") ~= nil then | 36 | if bufname:match("NvimTree_") ~= nil then table.insert(invalid_win, w) end |
| 39 | table.insert(invalid_win, w) | ||
| 40 | end | ||
| 41 | end | 37 | end |
| 42 | 38 | ||
| 43 | if #invalid_win == #wins - 1 then | 39 | if #invalid_win == #wins - 1 then |
| 44 | -- Should quit, so we close all invalid windows. | 40 | -- Should quit, so we close all invalid windows. |
| 45 | for _, w in ipairs(invalid_win) do vim.api.nvim_win_close(w, true) end | 41 | for _, w in ipairs(invalid_win) do |
| 42 | vim.api.nvim_win_close(w, true) | ||
| 43 | end | ||
| 46 | end | 44 | end |
| 47 | end | 45 | end, |
| 48 | }) | 46 | }) |
| 49 | 47 | ||
| 50 | vim.api.nvim_create_autocmd("LspAttach", { | 48 | vim.api.nvim_create_autocmd("LspAttach", { |
diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua index a665e82..4b280ef 100644 --- a/nvim/lua/config/keymaps.lua +++ b/nvim/lua/config/keymaps.lua | |||
| @@ -22,9 +22,24 @@ function M.lsp(buffer, client) | |||
| 22 | }) | 22 | }) |
| 23 | end, opts) | 23 | end, opts) |
| 24 | 24 | ||
| 25 | if client and client.name == "clangd" then | 25 | local function set_c_bindings() |
| 26 | map("n", "<leader>hs", "<cmd>ClangdSwitchSourceHeader<cr>", opts) | 26 | if client and client.name == "clangd" then map("n", "<leader>hs", "<cmd>ClangdSwitchSourceHeader<cr>", opts) end |
| 27 | end | 27 | end |
| 28 | |||
| 29 | local function set_python_bindings() | ||
| 30 | if client and (client.name == "basedpyright" or client.name == "pyright" or client.name == "pylsp") then | ||
| 31 | local function run_pytest() | ||
| 32 | vim.cmd("botright split | terminal pytest") | ||
| 33 | end | ||
| 34 | |||
| 35 | map("n", "<F6>", run_pytest, { | ||
| 36 | desc = "Run pytest (nur Python-Projekt)", | ||
| 37 | }) | ||
| 38 | end | ||
| 39 | end | ||
| 40 | |||
| 41 | set_c_bindings() | ||
| 42 | set_python_bindings() | ||
| 28 | end | 43 | end |
| 29 | 44 | ||
| 30 | function M.telescope() | 45 | function M.telescope() |
| @@ -110,14 +125,14 @@ function M.global() | |||
| 110 | map("n", "[e", function() | 125 | map("n", "[e", function() |
| 111 | vim.diagnostic.jump_prev({ | 126 | vim.diagnostic.jump_prev({ |
| 112 | severity = vim.diagnostic.severity.ERROR, | 127 | severity = vim.diagnostic.severity.ERROR, |
| 113 | wrap = false | 128 | wrap = false, |
| 114 | }) | 129 | }) |
| 115 | end, opts) | 130 | end, opts) |
| 116 | 131 | ||
| 117 | map("n", "]e", function() | 132 | map("n", "]e", function() |
| 118 | vim.diagnostic.jump_next({ | 133 | vim.diagnostic.jump_next({ |
| 119 | severity = vim.diagnostic.severity.ERROR, | 134 | severity = vim.diagnostic.severity.ERROR, |
| 120 | wrap = false | 135 | wrap = false, |
| 121 | }) | 136 | }) |
| 122 | end, opts) | 137 | end, opts) |
| 123 | end | 138 | end |
diff --git a/nvim/lua/config/options.lua b/nvim/lua/config/options.lua index a00cc64..40ccf71 100644 --- a/nvim/lua/config/options.lua +++ b/nvim/lua/config/options.lua | |||
| @@ -15,7 +15,7 @@ opt.showcmd = false | |||
| 15 | 15 | ||
| 16 | -- Rechtschreibprüfung | 16 | -- Rechtschreibprüfung |
| 17 | opt.spelllang = { "de", "en" } | 17 | opt.spelllang = { "de", "en" } |
| 18 | opt.spell = true | 18 | opt.spell = false |
| 19 | 19 | ||
| 20 | -- Optionen für ^n-Vervollständigung | 20 | -- Optionen für ^n-Vervollständigung |
| 21 | opt.complete = { ".", "w", "b", "u", "t", "i" } | 21 | opt.complete = { ".", "w", "b", "u", "t", "i" } |
