diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-09-14 19:48:38 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-09-14 20:05:12 +0200 |
commit | 7dcd592eae886dc8edde2dc65d6e6323201a2aaf (patch) | |
tree | 8c792984bd55d710dd409bcc90d450e2e90a58ce /init.lua | |
parent | 6081f67ec9f5032fcd9d4453a2646ca033364615 (diff) |
checkpoint
- changed installation of tmux-navigator
- removed init.lua file in user/ directory
- added autocmd for terminal in insert mode
- added keybind for opening terminal
- added keybinds for lsp commands
- added lua lsp setup
- added nvim-cmp
- added keybind for editing config
- added keybinds for opening splits
- added conceallevel = 2
- commented encoding options
- plugins:
- added go.nvim
- added cmp-calc
- markdown:
- disable pairs for quotes
- added pairs in markdown
- go:
- added go lsp
- added autoformat of go files on save
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 66 |
1 files changed, 65 insertions, 1 deletions
@@ -1 +1,65 @@ -require("user") +require("user.lazy") +require("user.set") +require("user.map") +require("user.lsp") + +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', +}) |