From af00b2ecf89180791e8a44065a864c2bb274d342 Mon Sep 17 00:00:00 2001 From: urosm Date: Thu, 23 May 2024 09:38:56 +0200 Subject: [PATCH] .config/nvim: update --- .config/nvim/after/ftplugin/css.lua | 8 +- .config/nvim/after/ftplugin/lua.lua | 8 +- .config/nvim/after/ftplugin/markdown.lua | 12 ++- .config/nvim/after/syntax/markdown.vim | 4 +- .config/nvim/colors/basic.lua | 5 +- .config/nvim/init.lua | 129 +++++++---------------- 6 files changed, 59 insertions(+), 107 deletions(-) diff --git a/.config/nvim/after/ftplugin/css.lua b/.config/nvim/after/ftplugin/css.lua index d89ac0f..71af6f1 100644 --- a/.config/nvim/after/ftplugin/css.lua +++ b/.config/nvim/after/ftplugin/css.lua @@ -1,4 +1,6 @@ +local optl = vim.opt_local + -- options -vim.opt.tabstop = 2 -vim.opt.shiftwidth = 2 -vim.opt.expandtab = true +optl.tabstop = 2 +optl.shiftwidth = 2 +optl.expandtab = true diff --git a/.config/nvim/after/ftplugin/lua.lua b/.config/nvim/after/ftplugin/lua.lua index 2279bfa..a640189 100644 --- a/.config/nvim/after/ftplugin/lua.lua +++ b/.config/nvim/after/ftplugin/lua.lua @@ -1,7 +1,9 @@ +local optl = vim.opt_local + -- options -vim.opt.tabstop = 2 -vim.opt.shiftwidth = 2 -vim.opt.expandtab = true +optl.tabstop = 2 +optl.shiftwidth = 2 +optl.expandtab = true -- treesitter vim.treesitter.start() diff --git a/.config/nvim/after/ftplugin/markdown.lua b/.config/nvim/after/ftplugin/markdown.lua index 265f6a0..22e5309 100644 --- a/.config/nvim/after/ftplugin/markdown.lua +++ b/.config/nvim/after/ftplugin/markdown.lua @@ -1,9 +1,11 @@ +local optl = vim.opt_local + -- options -vim.bo.tabstop = 2 -vim.bo.shiftwidth = 2 -vim.bo.expandtab = true +optl.tabstop = 2 +optl.shiftwidth = 2 +optl.expandtab = true -- keymaps local keymap_set = vim.keymap.set -keymap_set("n", "]h", "/\\_^#.*\\ze\\n\\{2}", {}) -keymap_set("n", "[h", "?\\_^#.*\\ze\\n\\{2}", {}) +keymap_set("n", "]h", "/\\_^#.*\\ze\\n\\{2}") +keymap_set("n", "[h", "?\\_^#.*\\ze\\n\\{2}") diff --git a/.config/nvim/after/syntax/markdown.vim b/.config/nvim/after/syntax/markdown.vim index 9b9dd29..1f2e771 100644 --- a/.config/nvim/after/syntax/markdown.vim +++ b/.config/nvim/after/syntax/markdown.vim @@ -7,7 +7,7 @@ syntax clear markdownYamlHead syntax region markdownYamlHead start="^-\{3}\n\S" end="\S\n\%(-\|\.\)\{3}$" keepend contains=@markdownYamlTop,@Spell " citation -syntax match markdownPCite "\^\@~/]*\_.\{-}\]" contains=@markdownInline,markdownCiteKey +syntax match markdownPCite "\^\@~/]*\_.\{-}\]" contains=@markdownInline,markdownCiteKey syn match markdownICite "@[[:alnum:]_][[:digit:][:lower:][:upper:]_:.#$%&\-+?<>~/]*\s\[.\{-1,}\]" contains=markdownCiteKey,@Spell display syn match markdownCiteKey /\(-\=@[[:alnum:]_][[:digit:][:lower:][:upper:]_:.#$%&\-+?<>~/]*\)/ containedin=markdownPCite,markdownICite contains=@NoSpell display @@ -17,5 +17,3 @@ hi def link markdownCiteKey markdownLabel hi def link markdownLabel Label let b:current_syntax = "markdown" - -" vim:set sw=2: diff --git a/.config/nvim/colors/basic.lua b/.config/nvim/colors/basic.lua index 7201e92..8a63ed3 100644 --- a/.config/nvim/colors/basic.lua +++ b/.config/nvim/colors/basic.lua @@ -276,7 +276,7 @@ local syntax_statement_h = { ctermfg = C.orange.cterm, fg = C.orange.gui } local syntax_preproc_h = { ctermfg = C.magenta.cterm, fg = C.magenta.gui } local syntax_type_h = { ctermfg = C.green.cterm, fg = C.green.gui } local syntax_special_h = { ctermfg = C.orange.cterm, fg = C.orange.gui } -local syntax_underline_h = { ctermfg = C.blue.cterm, fg = C.blue.gui, underline = true } +local syntax_underline_h = { underline = true } local syntax_ignore_h = { ctermfg = C.black.cterm, fg = C.black.gui } local syntax_error_h = { ctermfg = C.black.cterm, fg = C.black.gui, ctermbg = C.red.cterm, bg = C.red.gui } local syntax_warn_h = { ctermfg = C.black.cterm, fg = C.black.gui, ctermbg = C.orange.cterm, bg = C.orange.gui } @@ -339,6 +339,9 @@ set_hl("markdownBoldDelimiter", markdown_delimiter_h) set_hl("markdownBoldItalicDelimiter", markdown_delimiter_h) set_hl("markdownStrikeDelimiter", markdown_delimiter_h) set_hl("markdownCodeDelimiter", markdown_delimiter_h) +set_hl("markdownLinkTextDelimiter", markdown_delimiter_h) +set_hl("markdownLinkDelimiter", markdown_delimiter_h) +set_hl("markdownUrl", markdown_delimiter_h) set_hl("yamlBlockMappingKey", syntax_comment_h) set_hl("yamlPlainScalar", syntax_constant_h) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 56a4f08..84929ef 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,13 +1,14 @@ local opt, api, cmd = vim.opt, vim.api, vim.cmd local fn, ui = vim.fn, vim.ui +-- colorscheme ----------------------------------------------------------------- cmd.colorscheme("basic") -- options --------------------------------------------------------------------- opt.undofile = true opt.backup = false opt.writebackup = false -opt.mouse = {} +opt.mouse = "nvi" opt.title = true opt.shortmess:append({ I = true }) @@ -19,7 +20,7 @@ opt.colorcolumn = "+1" opt.expandtab = true opt.tabstop = 4 -opt.shiftwidth = 2 +opt.shiftwidth = 4 opt.softtabstop = -1 opt.smarttab = true @@ -27,19 +28,10 @@ opt.showtabline = 2 opt.winbar = "%f%( %h%m%r%y%)" opt.laststatus = 3 -local statusline_group = api.nvim_create_augroup("Statusline", {}) -local cwd = fn.pathshorten(vim.fn.getcwd()) -api.nvim_create_autocmd({ "DirChanged" }, { - group = statusline_group, - callback = function() - cwd = fn.pathshorten(vim.fn.getcwd()) - end -}) - function _G.statusline() local wordcount = fn.wordcount() return table.concat({ - cwd, + fn.pathshorten(fn.getcwd()), " %=", " <%b> ", wordcount.visual_chars or wordcount.cursor_chars, "/", wordcount.chars, " ", @@ -53,102 +45,55 @@ opt.infercase = true opt.smartcase = true opt.smartindent = true opt.clipboard = "unnamedplus" -opt.whichwrap = { - ["b"] = true, - ["s"] = true, - ["h"] = true, - ["l"] = true, - ["<"] = true, - [">"] = true, - ["~"] = true, - ["["] = true, - ["]"] = true -} opt.wildoptions = { "fuzzy" } opt.wildignorecase = true + opt.path = ".,,**" -opt.completeopt = { - "menuone", - "preview", -} - -local terminal_group = api.nvim_create_augroup("Terminal", {}) -api.nvim_create_autocmd({ "TermOpen" }, { - group = terminal_group, - callback = function() - local opt_l = vim.opt_local - opt_l.number = false - opt_l.relativenumber = false - end -}) +opt.completeopt = { "menuone", "preview", } -- keymaps --------------------------------------------------------------------- local keymap_set = vim.keymap.set -keymap_set("n", "", function() - cmd.nohlsearch() -end, { desc = "Stop the highlighting for the 'hlsearch' option" }) +keymap_set("n", "", "nohlsearch") -keymap_set("c", "", "", { desc = "Left in c-mode" }) -keymap_set("c", "", "", { desc = "Right in c-mode" }) +keymap_set("c", "", "") +keymap_set("c", "", "") -keymap_set("n", "f", ":find ", { desc = ":find" }) -keymap_set("n", "b", ":buffer ", { desc = ":buffer" }) -keymap_set("n", "h", ":help ", { desc = ":help" }) +keymap_set("n", "f", ":find ") +keymap_set("n", "b", ":buffer ") +keymap_set("n", "h", ":help ") +keymap_set("n", "g", ":vimgrep /") -keymap_set("n", "s", function() - vim.opt_local.spell = not(vim.opt_local.spell:get()) -end, { desc = "Toggle spell" }) +keymap_set("n", "s", ":set spell!") -keymap_set("n", "m", "make", { desc = ":make" }) +keymap_set("n", "m", "make") -keymap_set("n", "d", "enewbd #", { desc = "Delete buffer" }) -keymap_set("n", "D", "bd", { desc = "Delete buffer and close window" }) +keymap_set("n", "d", "enewbdelete#") +keymap_set("n", "D", "bdelete") -keymap_set("n", "]b", "bnext", { desc = "Next buffer" }) -keymap_set("n", "[b", "bprev", { desc = "Previous buffer" }) -keymap_set("n", "]t", "tabnext", { desc = "Next tab" }) -keymap_set("n", "[t", "tabprevious", { desc = "Previous tab" }) -keymap_set("n", "]q", "cnextzz", { desc = "Next quickfix item" }) -keymap_set("n", "[q", "cprevzz", { desc = "Previous quickfix item" }) +keymap_set("n", "]b", "bnext") +keymap_set("n", "[b", "bprev") +keymap_set("n", "]B", "blast") +keymap_set("n", "[B", "bfirst") +keymap_set("n", "]t", "tabnext") +keymap_set("n", "[t", "tabprev") +keymap_set("n", "]T", "tablast") +keymap_set("n", "[T", "tabfirst") +keymap_set("n", "]q", "cnextzz") +keymap_set("n", "[q", "cprevzz") +keymap_set("n", "]Q", "clastzz") +keymap_set("n", "[Q", "cfirstzz") -keymap_set("n", "co", "copen", { desc = "Open quickfix window" }) -keymap_set("n", "cc", "cclose", { desc = "Close quickfix window" }) +keymap_set("n", "co", "copen") +keymap_set("n", "cc", "cclose") -keymap_set("n", "g", function() - local pattern - ui.input({ prompt = ":vimgrep " }, function(input) - if not input then return end - if input:match("/.+/[gjf]*") then - pattern = input - else - pattern = ("/%s/g"):format(input) - end - end) - if not pattern then return end - local file - ui.input({ - prompt = (":vimgrep %s "):format(pattern), - default = "**/*" - }, function(input) - if not input then return end - file = input - end) - if not file then return end - cmd.vimgrep(pattern, file) -end, { desc = ":vimgrep" }) +keymap_set("i", "", "") -keymap_set("i", "", "", { desc = "File name completion" }) +keymap_set("n", "", "h") +keymap_set("n", "", "j") +keymap_set("n", "", "k") +keymap_set("n", "", "l") --- netrw ----------------------------------------------------------------------- -local g = vim.g - -g.netrw_use_errorwindow = 0 -g.netrw_banner = 0 -g.netrw_bufsettings = "noma nomod nowrap ro nobl" -g.netrw_fastbrowse = 0 - -keymap_set("n", ".", "Explore .", - { desc = "Explore current working directory" }) +keymap_set("n", ".", "e.")