Updated config

This commit is contained in:
2024-01-22 15:04:33 +01:00
parent 4e74495124
commit 8998a54e82
12 changed files with 138 additions and 13 deletions

View File

@ -13,3 +13,23 @@ on({ "BufNewFile", "BufRead" }, {
vim.opt_local.signcolumn = "no"
end,
})
on({ "VimEnter" }, {
callback = function()
-- Switch to root directory of the project
local root_patterns = { ".git", "go.mod", "init.lua" }
local root_dir = vim.fs.dirname(vim.fs.find(root_patterns, { upward = true })[1])
if root_dir then
vim.api.nvim_set_current_dir(root_dir)
end
-- Open file explorer if we have enough space
local files = require("nvim-tree.api")
local width = vim.go.columns
if width > 120 then
files.tree.toggle({ focus = false })
end
end,
})

View File

@ -8,8 +8,6 @@ map("n", "qq", "<cmd>qa!<cr>", "Quit all")
map("n", "U", "<cmd>redo<cr>", "Redo")
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", "Clear search")
map({ "i", "n", "s", "v" }, "<C-s>", "<cmd>w<cr><esc>", "Save file")
map("n", "<C-q>", "<cmd>bd<cr>", "Delete buffer")
map("n", "<C-n>", "<cmd>enew<cr>", "New File")
map("n", "<C-l>", "^Da", "Rewrite line")
map("i", "<C-l>", "<esc>^Da", "Rewrite line")
map("n", "<C-a>", "ggVG", "Select all")
@ -18,10 +16,34 @@ map({ "n", "v" }, "<C-b>", "^", "Beginning of line")
map("i", "<C-b>", "<esc>^i", "Beginning of line")
map({ "i", "n", "v" }, "<C-e>", "<end>", "End of line")
-- Buffer management
map("n", "<C-n>", "<cmd>enew<cr>", "New file")
map("n", "<C-q>", "<cmd>bd<cr>", "Delete buffer")
-- Copy and paste
map("v", "<C-c>", "y")
map("n", "<C-v>", '"+p')
-- Indenting
map("v", "<", "<gv")
map("v", ">", ">gv")
-- Shift arrow selection
map("n", "<S-Up>", "v<Up>")
map("n", "<S-Down>", "v<Down>")
map("n", "<S-Left>", "v<Left>")
map("n", "<S-Right>", "v<Right>")
map("v", "<S-Up>", "<Up>")
map("v", "<S-Down>", "<Down>")
map("v", "<S-Left>", "<Left>")
map("v", "<S-Right>", "<Right>")
map("i", "<S-Up>", "<Esc>v<Up>")
map("i", "<S-Down>", "<Esc>v<Down>")
map("i", "<S-Left>", "<Esc>v<Left>")
map("i", "<S-Right>", "<Esc>v<Right>")
-- LSP
map("n", "gr", vim.lsp.buf.references, "References")
map("n", "gd", vim.lsp.buf.definition, "Definition")

View File

@ -11,6 +11,7 @@ local opt = vim.opt
opt.autoindent = true
opt.autowrite = false
opt.clipboard = "unnamedplus"
opt.completeopt = "menu,menuone,noinsert"
opt.conceallevel = 0
opt.cursorline = true
opt.cursorlineopt = "number"
@ -18,11 +19,12 @@ opt.expandtab = false
opt.grepformat = "%f:%l:%c:%m"
opt.grepprg = "rg --grep"
opt.ignorecase = false
opt.linespace = 0
opt.mouse = "a"
opt.ruler = false
opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" }
opt.shiftwidth = 4
opt.shortmess:append "sCFI"
opt.shortmess:append "scCFI"
opt.showmode = false
opt.showtabline = 0
opt.smartindent = true
@ -35,7 +37,9 @@ opt.termguicolors = true
opt.undofile = true
opt.undolevels = 10000
opt.updatetime = 250
opt.virtualedit = "onemore"
opt.wildmode = "longest:full,full"
opt.winblend = 10
opt.wrap = false
-- UI
@ -45,3 +49,10 @@ opt.number = true
opt.relativenumber = false
opt.signcolumn = "number"
opt.statusline = "%{repeat('─',winwidth('.'))}"
-- Neovide
if g.neovide then
g.neovide_fullscreen = true
g.neovide_transparency = 0.9
vim.o.guifont = "UbuntuMono Nerd Font:h20"
end