diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-09-16 18:06:11 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-09-16 18:06:14 +0200 |
commit | 5c7dffe3782c18e0d47f5753a8c30a0cd1b6e352 (patch) | |
tree | 014587936dad9819fdb259fc255daa10e2d80379 /lua | |
parent | 7dcd592eae886dc8edde2dc65d6e6323201a2aaf (diff) |
checkpoint
- made keybinds more logical with prefixes
- renamed user to config
- updated to-do's
- added rounded borders on floating windows
- added vim-eunuch
- added telescope-symbols
Diffstat (limited to 'lua')
-rw-r--r-- | lua/config/autocmds.lua | 83 | ||||
-rw-r--r-- | lua/config/lazy.lua (renamed from lua/user/lazy.lua) | 7 | ||||
-rw-r--r-- | lua/config/lsp.lua (renamed from lua/user/lsp.lua) | 22 | ||||
-rw-r--r-- | lua/config/map.lua (renamed from lua/user/map.lua) | 0 | ||||
-rw-r--r-- | lua/config/set.lua (renamed from lua/user/set.lua) | 13 |
5 files changed, 116 insertions, 9 deletions
diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua new file mode 100644 index 0000000..247f152 --- /dev/null +++ b/lua/config/autocmds.lua @@ -0,0 +1,83 @@ +local autocmd = vim.api.nvim_create_autocmd +local function augroup(name) + return vim.api.nvim_create_augroup("user_" .. name, { clear = true }) +end + +-- [[ Highlight on yank ]] +autocmd("TextYankPost", { + group = augroup("highlight_yank"), + callback = function() + vim.highlight.on_yank() + end, +}) + +-- [[ Auto create parent directory if it doesn't exist ]] +autocmd("BufWritePre", { + group = augroup("auto_create_dir"), + callback = function(event) + if event.match:match("^%w%w+://") then + return + end + local file = vim.loop.fs_realpath(event.match) or event.match + vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") + end, +}) + +-- Run gofmt + goimports on save +local format_sync_grp = vim.api.nvim_create_augroup("goimports", {}) +autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + require("go.format").goimports() + end, + group = format_sync_grp, +}) + +autocmd("TermOpen", { + callback = function() + local o = vim.opt_local + o.signcolumn = "no" + o.number = false + o.relativenumber = false + vim.cmd("startinsert") + vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", { noremap = true }) + end, +}) +-- -- close automatically when shell process exits +-- -- TODO: does not work +-- autocmd("TermClose", { +-- callback = function() +-- vim.cmd("bdelete") +-- end, +-- }) +vim.keymap.set("n", "!", "<cmd>sp<CR><cmd>term<CR>", { desc = "Open terminal" }) + +-- [[ preserve last position ]] +autocmd("BufReadPost", { + pattern = "*", + command = 'silent! normal! g`"zv', +}) + +-- [[ no cursorline in insert mode ]] +local cursorGrp = augroup("CursorLine") +autocmd({ "InsertLeave", "WinEnter" }, { + pattern = "*", + command = "set cursorline", + group = cursorGrp, + desc = "show cursor line only in active window", +}) +autocmd({ "InsertEnter", "WinLeave" }, { pattern = "*", command = "set nocursorline", group = cursorGrp }) + +-- [[ spellchecker activated in txt files ]] +autocmd( + { "BufRead", "BufNewFile" }, + -- { pattern = { "*.txt", "*.md", "*.tex" }, command = [[setlocal spell<cr> setlocal spelllang=en,de<cr>]] } + { + pattern = { "*.txt" }, + callback = function() + vim.opt.spell = true + vim.opt.spelllang = "en" + end, + desc = "Enable spell checking for certain file types", + } +) diff --git a/lua/user/lazy.lua b/lua/config/lazy.lua index 31780ec..1bdad47 100644 --- a/lua/user/lazy.lua +++ b/lua/config/lazy.lua @@ -54,6 +54,7 @@ require("lazy").setup({ "lewis6991/gitsigns.nvim", -- better ntrw "tpope/vim-vinegar", + "tpope/vim-eunuch", -- integration with tmux keybinds { "christoomey/vim-tmux-navigator", @@ -138,6 +139,7 @@ require("lazy").setup({ dependencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope-ui-select.nvim", + "nvim-telescope/telescope-symbols.nvim", { "nvim-telescope/telescope-fzf-native.nvim", build = "make", @@ -175,6 +177,11 @@ require("lazy").setup({ }, install = { colorscheme = { "nord" }, + missing = false, + }, + change_detection = { + enabled = false, + notify = false, }, checker = { enabled = false }, -- defaults = {lazy = true}, diff --git a/lua/user/lsp.lua b/lua/config/lsp.lua index 1443887..715d0f9 100644 --- a/lua/user/lsp.lua +++ b/lua/config/lsp.lua @@ -1,14 +1,15 @@ -- [[ Keybinds ]] local map = vim.keymap.set -map("n", " a", vim.lsp.buf.code_action) +map("n", " la", vim.lsp.buf.code_action) map("n", "gd", vim.lsp.buf.definition) -map("n", " r", vim.lsp.buf.rename) -map("n", " i", vim.lsp.buf.implementation) -map("n", " sh", vim.lsp.buf.signature_help) -map("n", " t", vim.lsp.buf.typehierarchy) -map("n", " r", vim.lsp.buf.references) -map("n", " sl", vim.lsp.buf.document_symbol) -map("n", " td", vim.lsp.buf.type_definition) +map("n", " lr", vim.lsp.buf.rename) +map("n", " li", vim.lsp.buf.implementation) +map("n", " lh", vim.lsp.buf.signature_help) +map("n", " lt", vim.lsp.buf.typehierarchy) +map("n", " lr", vim.lsp.buf.references) +map("n", " ls", vim.lsp.buf.document_symbol) +map("n", " ld", vim.lsp.buf.type_definition) +map("n", " lq", vim.diagnostic.setqflist) -- [[ LSP Setups ]] local lspconfig = require("lspconfig") @@ -51,10 +52,13 @@ require("lspconfig").lua_ls.setup({ }) -- [[ nvim cmp ]] -local capabilities = require("cmp_nvim_lsp").default_capabilities() +require("cmp_nvim_lsp").default_capabilities() local cmp = require("cmp") local lspkind = require("lspkind") cmp.setup({ + completion = { + autocomplete = false, + }, snippet = { expand = function(args) require("snippy").expand_snippet(args.body) diff --git a/lua/user/map.lua b/lua/config/map.lua index 230588f..230588f 100644 --- a/lua/user/map.lua +++ b/lua/config/map.lua diff --git a/lua/user/set.lua b/lua/config/set.lua index 6040c72..9f328b0 100644 --- a/lua/user/set.lua +++ b/lua/config/set.lua @@ -37,6 +37,7 @@ opt.ignorecase = true opt.smartcase = true -- Keep signcolumn on by default +print(vim.fs.find(".git", {})) opt.signcolumn = "yes" -- Decrease update time @@ -100,3 +101,15 @@ else end opt.title = true + +-- rounded border around floating windows +local _border = "rounded" +vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = _border, +}) +vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = _border, +}) +vim.diagnostic.config({ + float = { border = _border }, +}) |