diff options
Diffstat (limited to 'lua')
-rw-r--r-- | lua/config/autocmds.lua | 20 | ||||
-rw-r--r-- | lua/config/lazy.lua | 172 | ||||
-rw-r--r-- | lua/config/lsp.lua | 160 | ||||
-rw-r--r-- | lua/config/map.lua | 67 | ||||
-rw-r--r-- | lua/config/projects.lua | 2 | ||||
-rw-r--r-- | lua/config/set.lua | 80 |
6 files changed, 42 insertions, 459 deletions
diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index f6033d6..1a4970b 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -33,14 +33,6 @@ autocmd("TermOpen", { 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", { @@ -72,17 +64,5 @@ autocmd( } ) --- autocmd({ "BufNewFile", "BufRead" }, { --- pattern = "*", --- callback = function() --- local output = vim.fn.system("git rev-parse --is-inside-work-tree") --- if output == "true\n" then --- vim.opt.signcolumn = "yes" --- else --- vim.opt.signcolumn = "no" --- end --- end, --- }) - -- Automatically resize panes autocmd("VimResized", { pattern = "*", command = "wincmd =" }) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index 1bd0b8a..3fd9dc9 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -6,132 +6,16 @@ if not vim.loop.fs_stat(lazypath) then "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release + "--branch=stable", lazypath, }) end vim.opt.rtp:prepend(lazypath) --- plugins installation and configuration require("lazy").setup({ "echasnovski/mini.nvim", - "tpope/vim-fugitive", - "lewis6991/gitsigns.nvim", "tpope/vim-vinegar", - "tpope/vim-eunuch", - -- "mg979/vim-visual-multi", - { - "brenton-leighton/multiple-cursors.nvim", - version = "*", -- Use the latest tagged version - opts = { - custom_key_maps = { - { - "n", - "<S-Tab>", - function() - require("multiple-cursors").align() - end, - }, - }, - }, - keys = { - { "<C-j>", "<Cmd>MultipleCursorsAddDown<CR>", mode = { "n", "x" }, desc = "Add cursor and move down" }, - { "<C-k>", "<Cmd>MultipleCursorsAddUp<CR>", mode = { "n", "x" }, desc = "Add cursor and move up" }, - - { "<C-Up>", "<Cmd>MultipleCursorsAddUp<CR>", mode = { "n", "i", "x" }, desc = "Add cursor and move up" }, - { - "<C-Down>", - "<Cmd>MultipleCursorsAddDown<CR>", - mode = { "n", "i", "x" }, - desc = "Add cursor and move down", - }, - - { - "<Leader>m", - "<Cmd>MultipleCursorsAddVisualArea<CR>", - mode = { "x" }, - desc = "Add cursors to the lines of the visual area", - }, - - { "<Leader>a", "<Cmd>MultipleCursorsAddMatches<CR>", mode = { "n", "x" }, desc = "Add cursors to cword" }, - { - "<Leader>A", - "<Cmd>MultipleCursorsAddMatchesV<CR>", - mode = { "n", "x" }, - desc = "Add cursors to cword in previous area", - }, - - { - "<Leader>d", - "<Cmd>MultipleCursorsAddJumpNextMatch<CR>", - mode = { "n", "x" }, - desc = "Add cursor and jump to next cword", - }, - { "<Leader>D", "<Cmd>MultipleCursorsJumpNextMatch<CR>", mode = { "n", "x" }, desc = "Jump to next cword" }, - - { "<Leader>l", "<Cmd>MultipleCursorsLock<CR>", mode = { "n", "x" }, desc = "Lock virtual cursors" }, - }, - }, - "jghauser/follow-md-links.nvim", - "stevearc/conform.nvim", "norcalli/nvim-colorizer.lua", - "neovim/nvim-lspconfig", - { - "williamboman/mason.nvim", - dependencies = { - "williamboman/mason-lspconfig.nvim", - -- for formatters and linters - "WhoIsSethDaniel/mason-tool-installer.nvim", - }, - config = function() - require("mason").setup({ - ui = { - border = "rounded", - }, - }) - end, - }, - { - --snippets - "L3MON4D3/LuaSnip", - version = "v2.*", - build = "make install_jsregexp", - }, - -- "mfussenegger/nvim-lint", - -- { - -- "ray-x/lsp_signature.nvim", - -- event = "LspAttach", - -- }, - -- { - -- "hrsh7th/nvim-cmp", - -- dependencies = { - -- "hrsh7th/cmp-nvim-lsp", - -- "hrsh7th/cmp-path", - -- "hrsh7th/cmp-buffer", - -- "saadparwaiz1/cmp_luasnip", - -- "onsails/lspkind.nvim", - -- }, - -- event = { "InsertEnter", "CmdlineEnter" }, - -- }, - { - "folke/which-key.nvim", - event = "VeryLazy", - opts = { - win = { - border = "rounded", - }, - }, - keys = { - { - "<leader>?", - function() - require("which-key").show({ global = false }) - end, - desc = "Buffer Local Keymaps (which-key)", - }, - }, - }, - { "christoomey/vim-tmux-navigator", cmd = { @@ -151,49 +35,22 @@ require("lazy").setup({ }, { - "ray-x/go.nvim", - dependencies = { -- optional packages - "ray-x/guihua.lua", - "neovim/nvim-lspconfig", - "nvim-treesitter/nvim-treesitter", - }, - config = function() - require("go").setup() - end, - event = { "CmdlineEnter" }, - ft = { "go", "gomod" }, - build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries - }, - - { - "dstein64/vim-startuptime", - cmd = "StartupTime", - init = function() - vim.g.startuptime_tries = 10 - end, - }, - - { "gbprod/nord.nvim", lazy = false, priority = 1000, config = function() require("nord").setup({ transparent = false, - terminal_colors = true, -- `:terminal` + terminal_colors = true, diff = { mode = "bg" }, borders = true, - -- values : [bg|fg|none] errors = { mode = "bg" }, - -- values : [vim|vscode] search = { theme = "vim" }, styles = { - -- `:help nvim_set_hl` comments = { italic = true }, keywords = { bold = true }, functions = { bold = true }, variables = { bold = true }, - -- To customize lualine/bufferline bufferline = { current = {}, modified = { italic = true }, @@ -204,7 +61,6 @@ require("lazy").setup({ end, }, { - -- Fuzzy Finder (files, lsp, etc) "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim", @@ -220,22 +76,7 @@ require("lazy").setup({ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", }, - { - "ThePrimeagen/harpoon", - branch = "harpoon2", - requires = { "nvim-lua/plenary.nvim", lazy = true }, - }, - - -- DAP - { - { - "mfussenegger/nvim-dap", - }, - { "rcarriga/nvim-dap-ui", dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" } }, - }, }, { - - -- lazy options performance = { rtp = { disabled_plugins = { @@ -247,13 +88,4 @@ require("lazy").setup({ }, }, }, - -- install = { - -- colorscheme = { "nord" }, - -- missing = false, - -- }, - -- change_detection = { - -- enabled = true, - -- notify = true, - -- }, - -- checker = { enabled = true, notify = false }, }) diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua deleted file mode 100644 index 10235bf..0000000 --- a/lua/config/lsp.lua +++ /dev/null @@ -1,160 +0,0 @@ --- [[ Keybinds ]] -local diagnostic = vim.diagnostic -local lbuf = vim.lsp.buf -local map = vim.keymap.set -local builtin = require("telescope.builtin") - -map("n", " <cr>", lbuf.code_action, { desc = "Code actions" }) -map("n", "gd", lbuf.definition, { desc = "Definition" }) -map("i", "<C-k>", lbuf.hover) -map("n", " lr", lbuf.rename, { desc = "Rename" }) -map("n", " li", builtin.lsp_implementations, { desc = "Implementation" }) -map("n", " ls", lbuf.signature_help, { desc = "Signature help" }) -map("n", " lh", lbuf.typehierarchy, { desc = "Type hierarchy" }) -map("n", " lf", lbuf.references, { desc = "References" }) -map("n", " ll", lbuf.document_symbol, { desc = "List symbols" }) -map("n", " lt", lbuf.type_definition, { desc = "Type definition" }) --- map("n", " lls", vim.lsp.handlers["workspace/symbol"]) -map("n", " lq", diagnostic.setqflist, { desc = "Diagnostic quickfix" }) -map("n", " >>", diagnostic.goto_next, { desc = "Diagnostic next" }) -map("n", " <<", diagnostic.goto_prev, { desc = "Diagnostic prev" }) -map("n", " <,", function() - diagnostic.goto_next({ severity = diagnostic.ERROR }) -end, { desc = "Diagnostic next error" }) -map("n", " >.", function() - diagnostic.goto_prev({ severity = diagnostic.ERROR }) -end, { desc = "Diagnostic prev error" }) -map("n", " vf", diagnostic.open_float, { desc = "Diagnostics open floating window" }) --- map("n", " ") - --- vim.lsp.inlay_hint(0, false) - --- [[ LSP Setups ]] - -local lspconfig = require("lspconfig") -lspconfig.gopls.setup({}) --- lspconfig.clangd.setup({}) --- lspconfig.emmet_ls.setup({}) --- lspconfig.ts_ls.setup({}) --- lspconfig.powershell_es.setup({ --- cmd = { --- "pwsh", --- "-NoLog", --- "-NoProfile", --- "-Command", --- "/home/aluc/.local/share/nvim/mason/packages/" .. --- "powershell-editor-services/PowerShellEditorServices/Start-EditorServices.ps1", --- }, --- }) --- lspconfig.lua_ls.setup({ --- -- with neovim support --- on_init = function(client) --- local path = client.workspace_folders[1].name --- if vim.loop.fs_stat(path .. "/.luarc.json") or vim.loop.fs_stat(path .. "/.luarc.jsonc") then --- return --- end --- --- client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, { --- runtime = { --- version = "LuaJIT", --- }, --- -- Make the server aware of Neovim runtime files --- workspace = { --- checkThirdParty = false, --- library = { --- vim.env.VIMRUNTIME, --- }, --- }, --- }) --- end, --- settings = { --- Lua = {}, --- }, --- }) - --- 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 }, -}) - -local autocmd = vim.api.nvim_create_autocmd -autocmd("LspAttach", { - callback = function(args) - local client = vim.lsp.get_client_by_id(args.data.client_id) - if client == nil then - return - end - if vim.tbl_contains({ "null-ls" }, client.name) then -- blacklist lsp - return - end - end, -}) - -local ls = require("luasnip") - -local parse_snippet = ls.parser.parse_snippet - -map({ "i", "s" }, "<C-h>", function() - if ls.expand_or_locally_jumpable() then - ls.expand_or_jump() - end -end, { silent = true }) -map({ "i", "s" }, "<C-l>", function() - if ls.locally_jumpable(-1) then - ls.jump(-1) - end -end, { silent = true }) -map({ "i", "s" }, "<C-c>", function() - if ls.choice_active() then - ls.change_choice(1) - end -end, { silent = true }) - -ls.config.set_config({ - history = true, - -- Will update multiple nodes at the same time when in insert mode - update_events = { "TextChanged", "TextChangedI" }, -}) - -ls.add_snippets("go", { - parse_snippet("main", "package main\n\nfunc main() {\n\t$0\n}"), - parse_snippet("e", "if err != nil {\n\tpanic(err)$1\n}$0"), - parse_snippet("ee", "if err != nil {\n\tfmt.Fprintln(os.Stderr, err)$1\n\tos.Exit(${2:1})\n}\n$0"), - parse_snippet("eif", "if err := $1; err != nil {\n\tfmt.Println(err)$2\n}\n$0"), - parse_snippet("pf", "fmt.Printf($0)"), - parse_snippet("pl", "fmt.Println($0)"), -}) -ls.add_snippets("sh", { - parse_snippet("!", "#!/bin/sh\n$0"), - parse_snippet("if", "if ${1:condition}; then\n\t$0\nfi"), - parse_snippet("while", "while ${1:condition}; do\n\t$0\ndone"), - parse_snippet("for", "for ${1:v} in ${2:list}; do\n\t$0\ndone"), - parse_snippet("case", "case ${1:\\$var} in\n\t$0\nesac"), -}) -ls.add_snippets("c", { - parse_snippet("main", "int\nmain(int Argc, char *Args[])\n{\n\t$0\n\treturn 0;\n}"), - parse_snippet( - "uints", - [[#include <stdint.h> -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; -typedef int8_t i8; -typedef int16_t i16; -typedef int32_t i32; -typedef int64_t i64; -typedef float f32; -typedef double f64; -]] - ), -}) -ls.add_snippets("typescript", { parse_snippet("cl", "console.log($0);") }) -ls.add_snippets("html", { parse_snippet("t", [[<$1>$0</$1>]]) }) diff --git a/lua/config/map.lua b/lua/config/map.lua index 27c6bb9..80e2b6c 100644 --- a/lua/config/map.lua +++ b/lua/config/map.lua @@ -4,95 +4,70 @@ local map = vim.keymap.set vim.g.mapleader = " " vim.g.maplocalleader = "," +local function verbose_toggle(value, name) + local toggle = value == false + if toggle == true then + print("Enabled " .. name .. ".") + else + print("Disabled " .. name .. ".") + end + return toggle +end -- open config map("n", " c", function() vim.cmd("cd ~/.config/nvim") vim.cmd("e " .. "init.lua") end, { desc = "Open neovim config file" }) --- Move text easilly -map("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move selected text up" }) -map("v", "K", ":m '<-2<CR>gv=gv", { desc = "Move selected text down" }) -map("n", "<M-b>", "<cmd>make<cr>", { desc = "Make" }) - --- better find next and previous -map("n", "n", "nzzzv", { desc = "Keep cursor in middle with search" }) -map("n", "N", "Nzzzv", { desc = "Keep cursor in middle with search" }) - -map("n", "J", "mzJ`z", { desc = "Move up next line with space in between" }) - --- greatest remap ever -map("x", " p", [["_dP]], { desc = "Paste while keeping the registry" }) - --- moving +-- insert navigation map("i", "<C-a>", "<C-o>I", { noremap = true }) map("i", "<C-e>", "<C-o>A", { noremap = true }) -- buffers -map("n", " sp", "<cmd>sp<cr>", { desc = "Open horizontal split" }) -map("n", " vs", "<cmd>vs<cr>", { desc = "Open vertical split" }) map("n", " q", "<cmd>q!<cr>", { noremap = true }) map("n", " Q", "<cmd>qa!<cr>", { noremap = true }) --- close all except focused buffer -map("n", " 1", "<cmd>%bd|e#<cr>", { noremap = true }) --- next tab -map("n", "+", "<cmd>tabe .<cr>", { noremap = true }) +map("n", "!", "<cmd>sp<CR><cmd>term<CR>", { desc = "Open terminal" }) +map("n", "<M-b>", "<cmd>make<cr>", { desc = "Make" }) -- better indenting map("v", "<", "<gv") map("v", ">", ">gv") +map("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move selected text up" }) +map("v", "K", ":m '<-2<CR>gv=gv", { desc = "Move selected text down" }) +map("x", " p", [["_dP]], { desc = "Paste while keeping the registry" }) +map("n", "n", "nzzzv", { desc = "Keep cursor in middle with search" }) +map("n", "N", "Nzzzv", { desc = "Keep cursor in middle with search" }) +map("n", "J", "mzJ`z", { desc = "Move up next line with space in between" }) -- allow for use of system clipboard fast map({ "n", "v" }, " y", [["+y]]) map("n", " Y", [["+Y]]) map({ "n", "v" }, " P", [["+p]]) --- templates -map("n", "<LocalLeader>rt", ":-1r " .. vim.fn.stdpath("config") .. "/templates", { noremap = true }) - -- hide all local hidden = true -- flag vim.api.nvim_create_user_command("Hide", function() hidden = hidden == false vim.opt.showmode = hidden vim.opt.ruler = hidden - vim.opt.nu = hidden - vim.opt.rnu = hidden vim.opt.showcmd = hidden vim.opt.laststatus = hidden and 2 or 0 - vim.opt.signcolumn = hidden and "yes" or "no" end, {}) --- write map("n", " x", "!cx %", { desc = "Toggle file as executable" }) map("n", " w", "<cmd>write<cr>", { noremap = true }) -map("n", " W", "<cmd>write!<cr>", { noremap = true }) -map("n", " e", "<cmd>edit<cr>", { noremap = true }) map("n", ",s", function() vim.cmd.source() print("Sourced.") end, { noremap = true }) --- Lazy -map("n", " P", "<cmd>Lazy<cr>", { noremap = true }) - -local function verbose_toggle(value, name) - local toggle = value == false - if toggle == true then - print("Enabled " .. name .. ".") - else - print("Disabled " .. name .. ".") - end - return toggle -end - -- spelling map("n", " ts", function() vim.o.spell = verbose_toggle(vim.o.spell, "spelling") end, { noremap = true, desc = "Toggle spelling" }) -map("n", "<C-s>g", "z=1<cr><cr>", { noremap = true }) -vim.diagnostic.enable(false) +map("n", "<c-s>g", "z=1<cr><cr>", { noremap = true, desc = "Correct word" }) + map("n", " td", function() vim.diagnostic.enable(verbose_toggle(vim.diagnostic.is_enabled(), "diagnostics")) end, { desc = "Toggle diagnostics" }) @@ -112,5 +87,3 @@ vim.api.nvim_create_user_command("Scratch", function() setlocal noswapfile ]]) end, {}) - -map("n", "<M-b>", "<cmd>make<cr>", { desc = "Make" }) diff --git a/lua/config/projects.lua b/lua/config/projects.lua index 8b71cb1..e2ad00a 100644 --- a/lua/config/projects.lua +++ b/lua/config/projects.lua @@ -14,7 +14,7 @@ M.Projects = { M.InProject = false -for At, Project in pairs(M.Projects) do +for _, Project in pairs(M.Projects) do if string.find(CWD, Project.Path) then M.InProject = true Project.Options() diff --git a/lua/config/set.lua b/lua/config/set.lua index 4e4e045..467f46d 100644 --- a/lua/config/set.lua +++ b/lua/config/set.lua @@ -1,120 +1,78 @@ local opt = vim.opt +-- TODO: Check if HOME directory exists +local home = os.getenv("HOME") --- Don't highlight on search opt.hlsearch = false opt.incsearch = true opt.conceallevel = 2 - --- Enable line numbers by default --- opt.number = true --- opt.relativenumber = true opt.signcolumn = "no" - --- Tab settings opt.tabstop = 4 opt.softtabstop = 4 opt.shiftwidth = 4 opt.expandtab = true - --- Enable smart indenting opt.smartindent = true - --- Enable break indent opt.breakindent = true +opt.backspace = "indent,eol,start" -local home = os.getenv("HOME") --- History settings opt.undofile = true opt.swapfile = true opt.backup = true opt.writebackup = true opt.undodir = home .. "/.local/state/nvim" --- https://stackoverflow.com/a/1625850 --- TODO: Check if directory exists opt.backupdir = home .. "/.local/share/Trash/nvim//,." opt.directory = home .. "/.local/share/Trash/nvim//,." --- Case-insensitive searching UNLESS \C or capital in search opt.ignorecase = true opt.smartcase = true --- Decrease update time opt.updatetime = 50 opt.timeoutlen = 300 - --- Set completeopt to have a better completion experience opt.completeopt = "" - --- Enable true color support -opt.termguicolors = true - --- Enable scroll off opt.scrolloff = 8 - --- Don't show mode I'm in, already have a nice status line for that -opt.showmode = false - --- Better split options opt.splitbelow = true opt.splitright = true - --- shared clipboard opt.clipboard = "unnamed" --- do not highlight matched bracket + +opt.showmode = false opt.showmatch = false --- highlight line at cursor opt.cursorline = true opt.textwidth = 100 -- opt.colorcolumn = "102" - --- status line --- show ruler +opt.termguicolors = true opt.ruler = true --- show command opt.showcmd = true - opt.wildmenu = true - opt.mouse = "" - -opt.backspace = "indent,eol,start" - opt.laststatus = 2 opt.history = 200 + -- opt.encoding = "utf-8" -- opt.fileencoding = "utf-8" - opt.smartindent = true opt.scrolloff = 8 - -- opt.spelllang = "en_us,nl" opt.formatoptions = "tocqrnj" --- Get the current working directory, replace the $HOME portion of the path with ~, --- and extract the last three directories +opt.title = true + +-- vim.opt.fillchars = { fold = " " } +-- vim.opt.foldmethod = "indent" +vim.opt.foldenable = false +vim.opt.foldlevel = 99 +vim.g.markdown_folding = 1 + local cwd = vim.fn.getcwd():gsub(home, "~") -local last_dirs = string.match(cwd, "[^/]+/[^/]+/[^/]+/?$") -if last_dirs then - opt.titlestring = last_dirs .. " -> %t" +local IsInCWD = string.match(cwd, "[^/]+/[^/]+/[^/]+/?$") +if IsInCWD then + opt.titlestring = IsInCWD .. " -> %t" else opt.titlestring = cwd .. " -> %t" end -opt.title = true - -- Highlighting --- NOTE: -vim.fn.matchadd("matchNotes", "NOTE\\((.*)\\)\\?:") vim.api.nvim_set_hl(0, "matchNotes", { fg = require("nord.colors").palette.frost.ice }) --- TODO: FIXME: +vim.fn.matchadd("matchNotes", "NOTE\\((.*)\\)\\?:") vim.api.nvim_set_hl(0, "matchTodos", { fg = require("nord.colors").palette.aurora.yellow }) vim.fn.matchadd("matchTodos", "\\(TODO\\|FIXME\\)\\((.*)\\)\\?:") --- ERROR: BUG: vim.api.nvim_set_hl(0, "matchErrors", { fg = require("nord.colors").palette.aurora.red }) vim.fn.matchadd("matchErrors", "\\(BUG\\|ERROR\\)\\((.*)\\)\\?:") - --- vim.opt.fillchars = { fold = " " } --- vim.opt.foldmethod = "indent" -vim.opt.foldenable = false -vim.opt.foldlevel = 99 -vim.g.markdown_folding = 1 |