From 5c7dffe3782c18e0d47f5753a8c30a0cd1b6e352 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 16 Sep 2024 18:06:11 +0200 Subject: checkpoint - made keybinds more logical with prefixes - renamed user to config - updated to-do's - added rounded borders on floating windows - added vim-eunuch - added telescope-symbols --- lua/config/autocmds.lua | 83 +++++++++++++++++++++ lua/config/lazy.lua | 188 ++++++++++++++++++++++++++++++++++++++++++++++++ lua/config/lsp.lua | 109 ++++++++++++++++++++++++++++ lua/config/map.lua | 83 +++++++++++++++++++++ lua/config/set.lua | 115 +++++++++++++++++++++++++++++ lua/user/lazy.lua | 181 ---------------------------------------------- lua/user/lsp.lua | 105 --------------------------- lua/user/map.lua | 83 --------------------- lua/user/set.lua | 102 -------------------------- 9 files changed, 578 insertions(+), 471 deletions(-) create mode 100644 lua/config/autocmds.lua create mode 100644 lua/config/lazy.lua create mode 100644 lua/config/lsp.lua create mode 100644 lua/config/map.lua create mode 100644 lua/config/set.lua delete mode 100644 lua/user/lazy.lua delete mode 100644 lua/user/lsp.lua delete mode 100644 lua/user/map.lua delete mode 100644 lua/user/set.lua (limited to 'lua') diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua new file mode 100644 index 0000000..247f152 --- /dev/null +++ b/lua/config/autocmds.lua @@ -0,0 +1,83 @@ +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", "", "", { 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", "!", "spterm", { desc = "Open terminal" }) + +-- [[ preserve last position ]] +autocmd("BufReadPost", { + pattern = "*", + command = 'silent! normal! g`"zv', +}) + +-- [[ no cursorline in insert mode ]] +local cursorGrp = augroup("CursorLine") +autocmd({ "InsertLeave", "WinEnter" }, { + pattern = "*", + command = "set cursorline", + group = cursorGrp, + desc = "show cursor line only in active window", +}) +autocmd({ "InsertEnter", "WinLeave" }, { pattern = "*", command = "set nocursorline", group = cursorGrp }) + +-- [[ spellchecker activated in txt files ]] +autocmd( + { "BufRead", "BufNewFile" }, + -- { pattern = { "*.txt", "*.md", "*.tex" }, command = [[setlocal spell setlocal spelllang=en,de]] } + { + pattern = { "*.txt" }, + callback = function() + vim.opt.spell = true + vim.opt.spelllang = "en" + end, + desc = "Enable spell checking for certain file types", + } +) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..1bdad47 --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,188 @@ +-- bootstraping +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) + +-- plugins installation and configuration +require("lazy").setup({ + -- lsp setup + { + -- LSP Support + "neovim/nvim-lspconfig", + -- lsp download manager + "williamboman/mason.nvim", + -- automatic lsp setup + "williamboman/mason-lspconfig.nvim", + -- additional formater support + "stevearc/conform.nvim", + -- additional linter support + "mfussenegger/nvim-lint", + -- mason autoinstaller for formatter's and linter's + "WhoIsSethDaniel/mason-tool-installer.nvim", + -- minimal snippet's support + "dcampos/nvim-snippy", + -- basic snippet's + "honza/vim-snippets", + -- cmp for autocompletion + { + "hrsh7th/nvim-cmp", + dependencies = { + -- cmp nvim-lsp plugin + "hrsh7th/cmp-nvim-lsp", + -- path comletion + "hrsh7th/cmp-path", + -- cmp snippy support + "dcampos/cmp-snippy", + "hrsh7th/cmp-calc", + }, + event = { "InsertEnter", "CmdlineEnter" }, + }, + -- kind icons + "onsails/lspkind.nvim", + -- Minimal neovim modules for a lot of things + "echasnovski/mini.nvim", + -- Adds git related signs to the gutter, as well as utilities for managing changes + "lewis6991/gitsigns.nvim", + -- better ntrw + "tpope/vim-vinegar", + "tpope/vim-eunuch", + -- integration with tmux keybinds + { + "christoomey/vim-tmux-navigator", + cmd = { + "TmuxNavigateLeft", + "TmuxNavigateDown", + "TmuxNavigateUp", + "TmuxNavigateRight", + "TmuxNavigatePrevious", + }, + keys = { + { "", "TmuxNavigateLeft" }, + { "", "TmuxNavigateDown" }, + { "", "TmuxNavigateUp" }, + { "", "TmuxNavigateRight" }, + { "", "TmuxNavigatePrevious" }, + }, + }, + -- auto close brackets + "m4xshen/autoclose.nvim", + }, + { + "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 + }, + + "mg979/vim-visual-multi", + "jghauser/follow-md-links.nvim", + + { + "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` + 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 }, + }, + }, + }) + vim.cmd.colorscheme("nord") + end, + }, + + -- Fuzzy Finder (files, lsp, etc) + { + "nvim-telescope/telescope.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope-ui-select.nvim", + "nvim-telescope/telescope-symbols.nvim", + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + }, + }, + }, + + { + -- Highlight, edit, and navigate code + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + }, + + { + -- harpoon your way around code + { + "ThePrimeagen/harpoon", + branch = "harpoon2", + requires = { "nvim-lua/plenary.nvim", lazy = true }, + }, + }, +}, { + + -- lazy options + performance = { + rtp = { + disabled_plugins = { + "gzip", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, + install = { + colorscheme = { "nord" }, + missing = false, + }, + change_detection = { + enabled = false, + notify = false, + }, + checker = { enabled = false }, + -- defaults = {lazy = true}, +}) diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua new file mode 100644 index 0000000..715d0f9 --- /dev/null +++ b/lua/config/lsp.lua @@ -0,0 +1,109 @@ +-- [[ Keybinds ]] +local map = vim.keymap.set +map("n", " la", vim.lsp.buf.code_action) +map("n", "gd", vim.lsp.buf.definition) +map("n", " lr", vim.lsp.buf.rename) +map("n", " li", vim.lsp.buf.implementation) +map("n", " lh", vim.lsp.buf.signature_help) +map("n", " lt", vim.lsp.buf.typehierarchy) +map("n", " lr", vim.lsp.buf.references) +map("n", " ls", vim.lsp.buf.document_symbol) +map("n", " ld", vim.lsp.buf.type_definition) +map("n", " lq", vim.diagnostic.setqflist) + +-- [[ LSP Setups ]] +local lspconfig = require("lspconfig") + +-- go +lspconfig.gopls.setup({}) + +-- lua +-- with neovim support +require("lspconfig").lua_ls.setup({ + 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 = { + -- Tell the language server which version of Lua you're using + -- (most likely LuaJIT in the case of Neovim) + version = "LuaJIT", + }, + -- Make the server aware of Neovim runtime files + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME, + -- Depending on the usage, you might want to add additional paths here. + -- "${3rd}/luv/library" + -- "${3rd}/busted/library", + }, + -- or pull in all of 'runtimepath'. NOTE: this is a lot slower + -- library = vim.api.nvim_get_runtime_file("", true) + }, + }) + end, + settings = { + Lua = {}, + }, +}) + +-- [[ nvim cmp ]] +require("cmp_nvim_lsp").default_capabilities() +local cmp = require("cmp") +local lspkind = require("lspkind") +cmp.setup({ + completion = { + autocomplete = false, + }, + snippet = { + expand = function(args) + require("snippy").expand_snippet(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping({ + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) + else + fallback() + end + end, + s = cmp.mapping.confirm({ select = true }), + c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), + }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + -- { name = "snippy" }, + }, { + { name = "buffer" }, + { name = "calc" }, + }), + formatting = { + format = lspkind.cmp_format({ + mode = "symbol_text", + menu = { + buffer = "(Buffer)", + nvim_lsp = "(LSP)", + luasnip = "(LuaSnip)", + nvim_lua = "(Lua)", + latex_symbols = "(Latex)", + }, + }), + }, +}) + +vim.api.nvim_set_hl(0, "CmpItemMenu", { italic = true }) diff --git a/lua/config/map.lua b/lua/config/map.lua new file mode 100644 index 0000000..230588f --- /dev/null +++ b/lua/config/map.lua @@ -0,0 +1,83 @@ +local map = vim.keymap.set + +-- Leader +vim.g.mapleader = " " +vim.g.maplocalleader = "," + +-- 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 '>+1gv=gv", { desc = "Move selected text up" }) +map("v", "K", ":m '<-2gv=gv", { desc = "Move selected text down" }) + +-- 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 +map("i", "", "I", { noremap = true }) +map("i", "", "A", { noremap = true }) +map("i", "", "D", { noremap = true }) + +-- buffers +map("n", "sp", "sp", { desc = "Open horizontal split" }) +map("n", "vs", "vs", { desc = "Open vertical split" }) +map("n", "gb", "buffers:buffer", { noremap = true }) +map("n", "q", "q!", { noremap = true }) +map("n", "Q", "qa!", { noremap = true }) +-- close all except focused buffer +map("n", "1", "%bd|e#", { noremap = true }) +-- next tab +map("n", "+", "tabe .", { noremap = true }) + +-- better indenting +map("v", "<", "", ">gv") + +-- allow for use of system clipboard fast +map({ "n", "v" }, "y", [["+y]]) +map("n", "Y", [["+Y]]) +map({ "n", "v" }, "P", [["+p]]) + +map({ "n", "v" }, "d", [["_d]]) + +-- templates +map("n", "rt", ":-1r " .. vim.fn.stdpath("config") .. "/templates", { noremap = true }) + +-- hide all +local s = { hidden_all = 0 } +map("n", "", function() + s.hidden_all = 1 - s.hidden_all + local opt = s.hidden_all == 0 + vim.opt.showmode = opt + vim.opt.ruler = opt + vim.opt.nu = opt + vim.opt.rnu = opt + vim.opt.showcmd = opt + vim.opt.laststatus = opt and 2 or 0 + vim.opt.signcolumn = opt and "yes" or "no" +end, { noremap = true }) + +-- write +map("n", "w", "write", { noremap = true }) +map("n", "W", "write!", { noremap = true }) +map("n", "e", "edit", { noremap = true }) +map("n", "s", function() + vim.cmd.source() + print("sourced.") +end, { noremap = true }) + +-- Lazy +map("n", "P", "Lazy", { noremap = true }) + +-- spelling +map("n", "s", "setlocal spell!", { noremap = true }) +map("n", "g", "z=1", { noremap = true }) diff --git a/lua/config/set.lua b/lua/config/set.lua new file mode 100644 index 0000000..9f328b0 --- /dev/null +++ b/lua/config/set.lua @@ -0,0 +1,115 @@ +local opt = vim.opt + +-- 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 + +-- 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 + +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 +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 + +-- Keep signcolumn on by default +print(vim.fs.find(".git", {})) +opt.signcolumn = "yes" + +-- Decrease update time +opt.updatetime = 50 +opt.timeoutlen = 300 + +-- Set completeopt to have a better completion experience +opt.completeopt = "menuone,noselect" + +-- 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.showmatch = false +-- highlight line at cursor +opt.cursorline = true + +-- status line +-- show ruler +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 = "cqrnj" + +-- Get the current working directory, replace the $HOME portion of the path with ~, +-- and extract the last three directories +local cwd = vim.fn.getcwd():gsub(os.getenv("HOME"), "~") +local last_dirs = string.match(cwd, "[^/]+/[^/]+/[^/]+/?$") +if last_dirs then + opt.titlestring = last_dirs .. " -> %t" +else + opt.titlestring = cwd .. " -> %t" +end + +opt.title = true + +-- 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 }, +}) diff --git a/lua/user/lazy.lua b/lua/user/lazy.lua deleted file mode 100644 index 31780ec..0000000 --- a/lua/user/lazy.lua +++ /dev/null @@ -1,181 +0,0 @@ --- bootstraping -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) - --- plugins installation and configuration -require("lazy").setup({ - -- lsp setup - { - -- LSP Support - "neovim/nvim-lspconfig", - -- lsp download manager - "williamboman/mason.nvim", - -- automatic lsp setup - "williamboman/mason-lspconfig.nvim", - -- additional formater support - "stevearc/conform.nvim", - -- additional linter support - "mfussenegger/nvim-lint", - -- mason autoinstaller for formatter's and linter's - "WhoIsSethDaniel/mason-tool-installer.nvim", - -- minimal snippet's support - "dcampos/nvim-snippy", - -- basic snippet's - "honza/vim-snippets", - -- cmp for autocompletion - { - "hrsh7th/nvim-cmp", - dependencies = { - -- cmp nvim-lsp plugin - "hrsh7th/cmp-nvim-lsp", - -- path comletion - "hrsh7th/cmp-path", - -- cmp snippy support - "dcampos/cmp-snippy", - "hrsh7th/cmp-calc", - }, - event = { "InsertEnter", "CmdlineEnter" }, - }, - -- kind icons - "onsails/lspkind.nvim", - -- Minimal neovim modules for a lot of things - "echasnovski/mini.nvim", - -- Adds git related signs to the gutter, as well as utilities for managing changes - "lewis6991/gitsigns.nvim", - -- better ntrw - "tpope/vim-vinegar", - -- integration with tmux keybinds - { - "christoomey/vim-tmux-navigator", - cmd = { - "TmuxNavigateLeft", - "TmuxNavigateDown", - "TmuxNavigateUp", - "TmuxNavigateRight", - "TmuxNavigatePrevious", - }, - keys = { - { "", "TmuxNavigateLeft" }, - { "", "TmuxNavigateDown" }, - { "", "TmuxNavigateUp" }, - { "", "TmuxNavigateRight" }, - { "", "TmuxNavigatePrevious" }, - }, - }, - -- auto close brackets - "m4xshen/autoclose.nvim", - }, - { - "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 - }, - - "mg979/vim-visual-multi", - "jghauser/follow-md-links.nvim", - - { - "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` - 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 }, - }, - }, - }) - vim.cmd.colorscheme("nord") - end, - }, - - -- Fuzzy Finder (files, lsp, etc) - { - "nvim-telescope/telescope.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-telescope/telescope-ui-select.nvim", - { - "nvim-telescope/telescope-fzf-native.nvim", - build = "make", - }, - }, - }, - - { - -- Highlight, edit, and navigate code - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - }, - - { - -- harpoon your way around code - { - "ThePrimeagen/harpoon", - branch = "harpoon2", - requires = { "nvim-lua/plenary.nvim", lazy = true }, - }, - }, -}, { - - -- lazy options - performance = { - rtp = { - disabled_plugins = { - "gzip", - "tarPlugin", - "tohtml", - "tutor", - "zipPlugin", - }, - }, - }, - install = { - colorscheme = { "nord" }, - }, - checker = { enabled = false }, - -- defaults = {lazy = true}, -}) diff --git a/lua/user/lsp.lua b/lua/user/lsp.lua deleted file mode 100644 index 1443887..0000000 --- a/lua/user/lsp.lua +++ /dev/null @@ -1,105 +0,0 @@ --- [[ Keybinds ]] -local map = vim.keymap.set -map("n", " a", vim.lsp.buf.code_action) -map("n", "gd", vim.lsp.buf.definition) -map("n", " r", vim.lsp.buf.rename) -map("n", " i", vim.lsp.buf.implementation) -map("n", " sh", vim.lsp.buf.signature_help) -map("n", " t", vim.lsp.buf.typehierarchy) -map("n", " r", vim.lsp.buf.references) -map("n", " sl", vim.lsp.buf.document_symbol) -map("n", " td", vim.lsp.buf.type_definition) - --- [[ LSP Setups ]] -local lspconfig = require("lspconfig") - --- go -lspconfig.gopls.setup({}) - --- lua --- with neovim support -require("lspconfig").lua_ls.setup({ - 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 = { - -- Tell the language server which version of Lua you're using - -- (most likely LuaJIT in the case of Neovim) - version = "LuaJIT", - }, - -- Make the server aware of Neovim runtime files - workspace = { - checkThirdParty = false, - library = { - vim.env.VIMRUNTIME, - -- Depending on the usage, you might want to add additional paths here. - -- "${3rd}/luv/library" - -- "${3rd}/busted/library", - }, - -- or pull in all of 'runtimepath'. NOTE: this is a lot slower - -- library = vim.api.nvim_get_runtime_file("", true) - }, - }) - end, - settings = { - Lua = {}, - }, -}) - --- [[ nvim cmp ]] -local capabilities = require("cmp_nvim_lsp").default_capabilities() -local cmp = require("cmp") -local lspkind = require("lspkind") -cmp.setup({ - snippet = { - expand = function(args) - require("snippy").expand_snippet(args.body) - end, - }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping({ - i = function(fallback) - if cmp.visible() and cmp.get_active_entry() then - cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) - else - fallback() - end - end, - s = cmp.mapping.confirm({ select = true }), - c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), - }), - }), - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - -- { name = "snippy" }, - }, { - { name = "buffer" }, - { name = "calc" }, - }), - formatting = { - format = lspkind.cmp_format({ - mode = "symbol_text", - menu = { - buffer = "(Buffer)", - nvim_lsp = "(LSP)", - luasnip = "(LuaSnip)", - nvim_lua = "(Lua)", - latex_symbols = "(Latex)", - }, - }), - }, -}) - -vim.api.nvim_set_hl(0, "CmpItemMenu", { italic = true }) diff --git a/lua/user/map.lua b/lua/user/map.lua deleted file mode 100644 index 230588f..0000000 --- a/lua/user/map.lua +++ /dev/null @@ -1,83 +0,0 @@ -local map = vim.keymap.set - --- Leader -vim.g.mapleader = " " -vim.g.maplocalleader = "," - --- 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 '>+1gv=gv", { desc = "Move selected text up" }) -map("v", "K", ":m '<-2gv=gv", { desc = "Move selected text down" }) - --- 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 -map("i", "", "I", { noremap = true }) -map("i", "", "A", { noremap = true }) -map("i", "", "D", { noremap = true }) - --- buffers -map("n", "sp", "sp", { desc = "Open horizontal split" }) -map("n", "vs", "vs", { desc = "Open vertical split" }) -map("n", "gb", "buffers:buffer", { noremap = true }) -map("n", "q", "q!", { noremap = true }) -map("n", "Q", "qa!", { noremap = true }) --- close all except focused buffer -map("n", "1", "%bd|e#", { noremap = true }) --- next tab -map("n", "+", "tabe .", { noremap = true }) - --- better indenting -map("v", "<", "", ">gv") - --- allow for use of system clipboard fast -map({ "n", "v" }, "y", [["+y]]) -map("n", "Y", [["+Y]]) -map({ "n", "v" }, "P", [["+p]]) - -map({ "n", "v" }, "d", [["_d]]) - --- templates -map("n", "rt", ":-1r " .. vim.fn.stdpath("config") .. "/templates", { noremap = true }) - --- hide all -local s = { hidden_all = 0 } -map("n", "", function() - s.hidden_all = 1 - s.hidden_all - local opt = s.hidden_all == 0 - vim.opt.showmode = opt - vim.opt.ruler = opt - vim.opt.nu = opt - vim.opt.rnu = opt - vim.opt.showcmd = opt - vim.opt.laststatus = opt and 2 or 0 - vim.opt.signcolumn = opt and "yes" or "no" -end, { noremap = true }) - --- write -map("n", "w", "write", { noremap = true }) -map("n", "W", "write!", { noremap = true }) -map("n", "e", "edit", { noremap = true }) -map("n", "s", function() - vim.cmd.source() - print("sourced.") -end, { noremap = true }) - --- Lazy -map("n", "P", "Lazy", { noremap = true }) - --- spelling -map("n", "s", "setlocal spell!", { noremap = true }) -map("n", "g", "z=1", { noremap = true }) diff --git a/lua/user/set.lua b/lua/user/set.lua deleted file mode 100644 index 6040c72..0000000 --- a/lua/user/set.lua +++ /dev/null @@ -1,102 +0,0 @@ -local opt = vim.opt - --- 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 - --- 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 - -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 -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 - --- Keep signcolumn on by default -opt.signcolumn = "yes" - --- Decrease update time -opt.updatetime = 50 -opt.timeoutlen = 300 - --- Set completeopt to have a better completion experience -opt.completeopt = "menuone,noselect" - --- 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.showmatch = false --- highlight line at cursor -opt.cursorline = true - --- status line --- show ruler -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 = "cqrnj" - --- Get the current working directory, replace the $HOME portion of the path with ~, --- and extract the last three directories -local cwd = vim.fn.getcwd():gsub(os.getenv("HOME"), "~") -local last_dirs = string.match(cwd, "[^/]+/[^/]+/[^/]+/?$") -if last_dirs then - opt.titlestring = last_dirs .. " -> %t" -else - opt.titlestring = cwd .. " -> %t" -end - -opt.title = true -- cgit v1.2.3