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

View File

@ -1,8 +1,17 @@
return {
"numToStr/Comment.nvim",
keys = {
{"<C-_>", "<cmd>lua require('Comment.api').toggle.linewise.current()<cr>", desc = "Toggle comment"},
{"<C-_>", "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", mode = "v", desc = "Toggle comment"},
{
"<C-/>",
"<cmd>lua require('Comment.api').toggle.linewise.current()<cr>",
desc = "Toggle comment",
},
{
"<C-/>",
"<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>",
mode = "v",
desc = "Toggle comment",
},
},
config = true,
opts = {

View File

@ -0,0 +1,8 @@
return {
"echasnovski/mini.completion",
event = "InsertEnter",
opts = {
set_vim_settings = false,
},
config = true,
}

View File

@ -0,0 +1,14 @@
return {
"brenton-leighton/multiple-cursors.nvim",
event = "VeryLazy",
keys = {
{"<C-Down>", "<Cmd>MultipleCursorsAddDown<CR>", mode = {"n", "i"}},
{"<C-j>", "<Cmd>MultipleCursorsAddDown<CR>"},
{"<C-Up>", "<Cmd>MultipleCursorsAddUp<CR>", mode = {"n", "i"}},
{"<C-k>", "<Cmd>MultipleCursorsAddUp<CR>"},
{"<C-LeftMouse>", "<Cmd>MultipleCursorsMouseAddDelete<CR>", mode = {"n", "i"}},
{"<Leader>a", "<Cmd>MultipleCursorsAddBySearch<CR>", mode = {"n", "x"}},
{"<Leader>A", "<Cmd>MultipleCursorsAddBySearchV<CR>", mode = {"n", "x"}},
},
config = true,
}

View File

@ -4,7 +4,7 @@ return {
priority = 1000,
opts = {
style = "dark",
transparent = true,
--transparent = true,
term_colors = true,
highlights = {
["StatusLine"] = {fg = "$bg3", bg = "Normal"},

View File

@ -12,6 +12,14 @@ return {
},
config = function()
require("telescope").setup({
defaults = {
mappings = {
i = {
["<esc>"] = require("telescope.actions").close,
},
},
winblend = 10,
},
extensions = {
project = {
base_dirs = {

View File

@ -1,3 +1,34 @@
local function on_attach(bufnr)
local api = require("nvim-tree.api")
-- default mappings
api.config.mappings.default_on_attach(bufnr)
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
-- navigation
vim.keymap.set("n", "<C-Up>", api.tree.change_root_to_parent, opts("Up"))
vim.keymap.set("n", "<C-Enter>", api.tree.change_root_to_node, opts("Enter"))
-- open folders with a single click
vim.keymap.set("n", "<LeftRelease>", function()
vim.defer_fn(function ()
local win = vim.api.nvim_get_current_win()
local view = require("nvim-tree.view")
if view.get_winnr() ~= win then return end
api.node.open.edit()
api.tree.focus()
-- local node = api.tree.get_node_under_cursor()
-- if node.nodes ~= nil then
-- api.node.open.edit()
-- end
end, 10)
end, opts("Open folder/file"))
end
return {
"nvim-tree/nvim-tree.lua",
event = "VeryLazy",
@ -14,6 +45,7 @@ return {
filters = {
dotfiles = false,
},
on_attach = on_attach,
renderer = {
root_folder_label = false,
highlight_git = true,