diff options
| author | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2023-01-22 10:18:07 +0100 |
|---|---|---|
| committer | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2023-01-22 10:18:07 +0100 |
| commit | 5455aacdedfb2829f000b2f120a6d5194d1227f8 (patch) | |
| tree | ca73cfdf3b9106aab00c5acb3d239df61e9c43d9 /lua/config | |
| parent | bf157b642c2910abae1810c985817e42502000b5 (diff) | |
| download | nvim-conf-5455aacdedfb2829f000b2f120a6d5194d1227f8.tar.gz nvim-conf-5455aacdedfb2829f000b2f120a6d5194d1227f8.zip | |
feat: big change on the structure of the plugins, move several things to config dir
Diffstat (limited to 'lua/config')
| -rw-r--r-- | lua/config/autocmds.lua | 39 | ||||
| -rw-r--r-- | lua/config/diagnostic.lua | 9 | ||||
| -rw-r--r-- | lua/config/init.lua | 14 | ||||
| -rw-r--r-- | lua/config/keymaps.lua | 48 | ||||
| -rw-r--r-- | lua/config/lazy.lua | 33 | ||||
| -rw-r--r-- | lua/config/options.lua | 43 |
6 files changed, 186 insertions, 0 deletions
diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua new file mode 100644 index 0000000..ee165ee --- /dev/null +++ b/lua/config/autocmds.lua @@ -0,0 +1,39 @@ +-- resize splits if window got resized +vim.api.nvim_create_autocmd({ "VimResized" }, { + callback = function() + vim.cmd("tabdo wincmd =") + end, +}) + +-- close some filetypes with <q> +vim.api.nvim_create_autocmd("FileType", { + pattern = { + "qf", + "help", + "man", + "notify", + "lspinfo", + "spectre_panel", + "startuptime", + "tsplayground", + "PlenaryTestPopup", + }, + callback = function(event) + vim.bo[event.buf].buflisted = false + vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true }) + end, +}) + +vim.api.nvim_create_autocmd("FileType", { + pattern = { "gitcommit", "markdown" }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, +}) + +vim.api.nvim_create_autocmd({"BufWritePre"}, { + callback = function () + vim.cmd([[%s/\s\+$//e]]) + end +}) diff --git a/lua/config/diagnostic.lua b/lua/config/diagnostic.lua new file mode 100644 index 0000000..7d56f1c --- /dev/null +++ b/lua/config/diagnostic.lua @@ -0,0 +1,9 @@ +vim.diagnostic.config({ + virtual_text = false, +}) + +local signs = { Error = "", Warn = "", Hint = "", Info = "" } +for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) +end diff --git a/lua/config/init.lua b/lua/config/init.lua new file mode 100644 index 0000000..3537ca6 --- /dev/null +++ b/lua/config/init.lua @@ -0,0 +1,14 @@ +require("config.options") +require("config.lazy") +if vim.fn.argc() == 0 then + -- autocmds and keymaps can wait to load + vim.api.nvim_create_autocmd("User", { + group = vim.api.nvim_create_augroup("LazyVim", { clear = true }), + pattern = "VeryLazy", + callback = function() + require("config.autocmds") + require("config.keymaps") + require("config.diagnostic") + end, + }) +end diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua new file mode 100644 index 0000000..95ad0d7 --- /dev/null +++ b/lua/config/keymaps.lua @@ -0,0 +1,48 @@ +local map = vim.keymap.set + +map("v", "<leader>p", '"_dp') + +map("n", "bd", ":bd!<CR>") + +-- lists navigation +map("n", "<leader>j", ":cnext<CR>zz") +map("n", "<leader>k", ":cprev<CR>zz") +map("n", "<leader>i", ":lnext<CR>zz") +map("n", "<leader>o", ":lprev<CR>zz") +map("n", "<leader>cc", ":cclose<CR>") + +-- quick split +map("n", "<leader>wsv", ":vsp<CR>") + +-- tabulation +map("v", "<", "<gv") +map("v", ">", ">gv") + +-- symbols to add undo points +local symbols = { ",", ".", "!", "?", "$", ">", "<" } +for _, symbol in pairs(symbols) do + map("i", symbol, symbol .. "<c-g>u") +end + +-- search result focus +map("n", "n", "nzzzv") +map("n", "N", "Nzzzv") + +-- join lines focus +map("n", "J", "mzJ`z") + +-- Terminal +map("t", "<Esc><Esc>", "<C-\\><C-n>") +map("t", "<C-w>h", "<C-\\><C-n><C-w>h") +map("t", "<C-w>j", "<C-\\><C-n><C-w>j") +map("t", "<C-w>k", "<C-\\><C-n><C-w>k") +map("t", "<C-w>l", "<C-\\><C-n><C-w>l") + +-- quick env file edit +map("n", "<leader>ee", ":vsp .env<CR>") + +-- quick save and exec +map("n", "<leader><leader>x", require("alpha.utils").save_and_exec) + +map("n", "<leader>vn", vim.diagnostic.goto_next, {}) +map("n", "<leader>vp", vim.diagnostic.goto_prev, {}) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..5c9351a --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,33 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ + spec = { + { import = "plugins" }, + }, + checker = { enabled = true }, + performance = { + rtp = { + disabled_plugins = { + "gzip", + "matchit", + "matchparen", + "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}) diff --git a/lua/config/options.lua b/lua/config/options.lua new file mode 100644 index 0000000..21b0c68 --- /dev/null +++ b/lua/config/options.lua @@ -0,0 +1,43 @@ +vim.g.mapleader = " " +vim.g.snippets = "luasnip" + +local opt = vim.o + +opt.mouse = false +opt.number = true +opt.relativenumber = true +opt.conceallevel = 3 +opt.hidden = true +opt.expandtab = true +opt.tabstop = 4 +opt.softtabstop = 4 +opt.shiftwidth = 4 +opt.smartindent = true +opt.errorbells = false +opt.wrap = false +opt.swapfile = false +opt.undofile = true +opt.undodir = os.getenv("HOME") .. "/.cache/nvim/undodir" +opt.hlsearch = false +opt.incsearch = true +opt.ignorecase = true +opt.smartcase = true +opt.termguicolors = true +opt.scrolloff = 4 +opt.sidescrolloff = 4 +opt.showmode = false +opt.clipboard = "unnamedplus" +opt.splitbelow = true +opt.splitright = true +opt.autowrite = true +opt.list = true +opt.listchars = "tab:\\ ,trail:-" +opt.laststatus = 3 +opt.cmdheight = 1 +opt.updatetime = 50 +opt.signcolumn = "yes" + +if vim.fn.has("nvim-0.9.0") == 1 then + opt.splitkeep = "screen" + opt.shortmess = "filnxtToOFWIcC" +end |