1
0
Fork 0

.config/nvim: update

main
urosm 2024-05-05 17:34:33 +02:00
parent 02e32ae72f
commit 76fa734d85
14 changed files with 143 additions and 160 deletions

View File

@ -1,2 +0,0 @@
-- treesitter ------------------------------------------------------------------
vim.treesitter.start()

View File

@ -1,4 +1,4 @@
-- options ---------------------------------------------------------------------
-- options
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true

View File

@ -1,2 +0,0 @@
-- treesitter ------------------------------------------------------------------
vim.treesitter.start()

View File

@ -1,4 +0,0 @@
-- options ---------------------------------------------------------------------
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
-- vim.opt.expandtab = true

View File

@ -1,4 +0,0 @@
-- options ---------------------------------------------------------------------
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true

View File

@ -1,7 +1,7 @@
-- options ---------------------------------------------------------------------
-- options
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
-- treesitter ------------------------------------------------------------------
-- treesitter
vim.treesitter.start()

View File

@ -1,9 +1,9 @@
-- options ---------------------------------------------------------------------
-- options
vim.bo.tabstop = 2
vim.bo.shiftwidth = 2
vim.bo.expandtab = true
-- keymaps ---------------------------------------------------------------------
-- keymaps
local keymap_set = vim.keymap.set
keymap_set("n", "]h", "/\\_^#.*\\ze\\n\\{2}<esc>", {})
keymap_set("n", "[h", "?\\_^#.*\\ze\\n\\{2}<esc>", {})

View File

@ -1,4 +0,0 @@
-- options ---------------------------------------------------------------------
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true

View File

@ -1,4 +0,0 @@
-- options ---------------------------------------------------------------------
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true

View File

@ -1,4 +0,0 @@
-- options ---------------------------------------------------------------------
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true

View File

@ -1,2 +1,2 @@
-- treesitter ------------------------------------------------------------------
-- treesitter
vim.treesitter.start()

View File

@ -6,7 +6,6 @@ endif
syntax clear markdownYamlHead
syntax region markdownYamlHead start="^-\{3}\n\S" end="\S\n\%(-\|\.\)\{3}$" keepend contains=@markdownYamlTop,@Spell
" citation
syntax match markdownPCite "\^\@<!\[[^\[\]]\{-}-\{0,1}@[[:alnum:]_][[:digit:][:lower:][:upper:]_:.#$%&\-+?<>~/]*\_.\{-}\]" contains=@markdownInline,markdownCiteKey
syn match markdownICite "@[[:alnum:]_][[:digit:][:lower:][:upper:]_:.#$%&\-+?<>~/]*\s\[.\{-1,}\]" contains=markdownCiteKey,@Spell display

View File

@ -5,32 +5,40 @@
-- colors ----------------------------------------------------------------------
local C = {
{ 0, "#000000" }, -- black
{ 1, "#fa3500" }, -- red
{ 2, "#009843" }, -- green
{ 3, "#d06600" }, -- orange
{ 4, "#856cff" }, -- blue
{ 5, "#ff1170" }, -- magenta
{ 6, "#008cca" }, -- cyan
{ 7, "#e2e2e2" }, -- white
{ 8, "#848484" }, -- black
{ 9, "#ff888e" }, -- red
{ 10, "#00c55b" }, -- green
{ 11, "#ff8d48" }, -- orange
{ 12, "#ac9fff" }, -- blue
{ 13, "#ffb1c0" }, -- magenta
{ 14, "#92ccff" }, -- cyan
{ 15, "#ffffff" }, -- white
black = { cterm = 0, gui = "#000000" },
red = { cterm = 1, gui = "#fa3500" },
green = { cterm = 2, gui = "#009843" },
orange = { cterm = 3, gui = "#d06600" },
blue = { cterm = 4, gui = "#856cff" },
magenta = { cterm = 5, gui = "#ff1170" },
cyan = { cterm = 6, gui = "#008cca" },
white = { cterm = 7, gui = "#e2e2e2" },
bright_black = { cterm = 8, gui = "#848484" },
bright_red = { cterm = 9, gui = "#ff888e" },
bright_green = { cterm = 10, gui = "#00c55b" },
bright_orange = { cterm = 11, gui = "#ff8d48" },
bright_blue = { cterm = 12, gui = "#ac9fff" },
bright_magenta = { cterm = 13, gui = "#ffb1c0" },
bright_cyan = { cterm = 14, gui = "#92ccff" },
bright_white = { cterm = 15, gui = "#ffffff" },
}
local black_c = C[1]
local red_c = C[2]
local green_c = C[3]
local orange_c = C[4]
local blue_c = C[5]
local magenta_c = C[6]
local cyan_c = C[7]
local white_c = C[8]
vim.g.terminal_color_0 = "#000000"
vim.g.terminal_color_1 = "#fa3500"
vim.g.terminal_color_2 = "#009843"
vim.g.terminal_color_3 = "#d06600"
vim.g.terminal_color_4 = "#856cff"
vim.g.terminal_color_5 = "#ff1170"
vim.g.terminal_color_6 = "#008cca"
vim.g.terminal_color_7 = "#e2e2e2"
vim.g.terminal_color_8 = "#848484"
vim.g.terminal_color_9 = "#ff888e"
vim.g.terminal_color_10 = "#00c55b"
vim.g.terminal_color_11 = "#ff8d48"
vim.g.terminal_color_12 = "#ac9fff"
vim.g.terminal_color_13 = "#ffb1c0"
vim.g.terminal_color_14 = "#92ccff"
vim.g.terminal_color_15 = "#ffffff"
-- init ------------------------------------------------------------------------
vim.cmd.highlight("clear")
@ -50,42 +58,11 @@ else
vim.opt.termguicolors = true
end
for _, v in ipairs(C) do
local key = ("terminal_color_%i"):format(v[1])
vim.g[key] = v[2]
end
-- highlights ------------------------------------------------------------------
local H = {}
function H:new(o)
o = o or {}
setmetatable(o, self)
self.__index = self
return o
end
function H:fg(c)
self.ctermfg = c[1]
self.fg = c[2]
return self
end
function H:bg(c)
self.ctermbg = c[1]
self.bg = c[2]
return self
end
function H:attr(a)
self[a] = true
return self
end
local fg_c = white_c
local bg_c = black_c
local accent_c = magenta_c
local dimmed_c = blue_c
local fg = C.white
local bg = C.black
local accent = C.magenta
local dimmed = C.blue
local nvim_set_hl = vim.api.nvim_set_hl
local function set_hl(group, def) nvim_set_hl(0, group, def) end
@ -98,8 +75,8 @@ set_hl("NormalNC", normal_h)
-- tui -------------------------------------------------------------------------
local tui_normal_h = {}
local tui_accent_h = H:new():fg(accent_c)
local tui_dimmed_h = H:new():fg(dimmed_c)
local tui_accent_h = { ctermfg = accent.cterm, fg = accent.gui }
local tui_dimmed_h = { ctermfg = dimmed.cterm, fg = dimmed.gui }
set_hl("StatusLine", tui_dimmed_h)
set_hl("StatusLineNC", tui_dimmed_h)
@ -117,17 +94,34 @@ set_hl("FoldColumn", tui_dimmed_h)
set_hl("WildMenu", tui_accent_h)
-- float -----------------------------------------------------------------------
local float_normal_h = H:new():fg(bg_c):bg(fg_c)
local float_accent_h = H:new():fg(accent_c):bg(fg_c)
local float_normal_h = { ctermfg = bg.cterm,
fg = bg.gui,
ctermbg = fg.cterm,
bg = fg.gui }
local float_dimmed_h = { ctermfg = dimmed.cterm,
fg = dimmed.gui,
ctermbg = fg.cterm,
bg = fg.gui }
local float_accent_h = { ctermfg = accent.cterm,
fg = accent.gui,
ctermbg = fg.cterm,
bg = fg.gui }
set_hl("NormalFloat", float_normal_h)
set_hl("FloatBorder", float_normal_h)
set_hl("FloatBorder", float_dimmed_h)
set_hl("FloatTitle", float_accent_h)
-- menu ------------------------------------------------------------------------
local menu_normal_h = H:new():fg(bg_c):bg(fg_c)
local menu_accent_h = H:new():fg(accent_c):bg(fg_c)
local menu_accent_r_h = H:new():fg(accent_c):bg(fg_c):attr("reverse")
local menu_normal_h = { ctermfg = accent.cterm,
fg = accent.gui,
ctermbg = fg.cterm,
bg = fg.gui }
local menu_accent_h = { ctermfg = accent.cterm,
fg = accent.gui,
ctermbg = fg.cterm,
bg = fg.gui,
reverse = true }
local test = { ctermfg, fg = 1, 2 }
set_hl("Pmenu", menu_normal_h)
set_hl("PmenuSel", menu_accent_h)
@ -135,14 +129,14 @@ set_hl("PmenuKind", menu_normal_h)
set_hl("PmenuKindSel", menu_accent_h)
set_hl("PmenuExtra", menu_normal_h)
set_hl("PmenuExtraSel", menu_accent_h)
set_hl("PmenuSbar", menu_accent_h)
set_hl("PmenuThumb", menu_accent_r_h)
set_hl("PmenuSbar", menu_normal_h)
set_hl("PmenuThumb", menu_accent_h)
-- messages --------------------------------------------------------------------
local message_normal_h = {}
local message_accent_h = H:new():fg(accent_c)
local message_error_h = H:new():fg(red_c)
local message_warn_h = H:new():fg(orange_c)
local message_accent_h = { ctermfg = accent.cterm, fg = accent.gui }
local message_error_h = { ctermfg = C.red.cterm, fg = C.red.gui }
local message_warn_h = { ctermfg = C.orange.cterm, fg = C.orange.gui }
set_hl("MsgArea", message_normal_h)
set_hl("MsgSeparator", message_normal_h)
@ -154,9 +148,9 @@ set_hl("Question", message_accent_h)
set_hl("Title", message_accent_h)
-- buffer ----------------------------------------------------------------------
local buffer_normal_h = H:new():fg(dimmed_c)
local buffer_normal_bg_h = H:new():bg(dimmed_c)
local buffer_accent_h = H:new():fg(accent_c)
local buffer_normal_h = { ctermfg = dimmed.cterm, fg = dimmed.gui }
local buffer_normal_bg_h = { ctermbg = dimmed.cterm, bg = dimmed.gui }
local buffer_accent_h = { ctermfg = accent.cterm, fg = accent.gui }
set_hl("Conceal", buffer_normal_h)
set_hl("NonText", buffer_normal_h)
@ -167,7 +161,7 @@ set_hl("SpecialKey", buffer_accent_h)
set_hl("ColorColumn", buffer_normal_bg_h)
-- cursor ----------------------------------------------------------------------
local cursor_normal_h = H:new():attr("reverse")
local cursor_normal_h = { reverse = true }
set_hl("CursorLine", cursor_normal_h)
set_hl("CursorLineNr", cursor_normal_h)
@ -182,27 +176,39 @@ set_hl("TermCursor", cursor_normal_h)
set_hl("TermCursorNC", cursor_normal_h)
-- match -----------------------------------------------------------------------
local match_normal_h = H:new():fg(black_c):bg(orange_c)
local match_current_h = H:new():fg(black_c):bg(magenta_c)
local match_paren_h = H:new():fg(magenta_c):bg(orange_c)
local match_normal_h = { ctermfg = C.black.cterm,
fg = C.black.gui,
ctermbg = C.orange.cterm,
bg = C.orange.gui }
local match_accent_h = { ctermfg = C.black.cterm,
fg = C.black.gui,
ctermbg = C.magenta.cterm,
bg = C.magenta.gui }
local match_dimmed_h = { ctermfg = C.magenta.cterm,
fg = C.magenta.gui,
ctermbg = C.white.cterm,
bg = C.white.gui }
set_hl("Search", match_normal_h)
set_hl("Substitute", match_normal_h)
set_hl("IncSearch", match_current_h)
set_hl("CurSearch", match_current_h)
set_hl("MatchParen", match_paren_h)
set_hl("IncSearch", match_accent_h)
set_hl("CurSearch", match_accent_h)
set_hl("MatchParen", match_dimmed_h)
-- selection -------------------------------------------------------------------
local selection_normal_h = H:new():fg(black_c):bg(white_c)
local selection_normal_h = { ctermfg = C.black.cterm,
fg = C.black.gui,
ctermbg = C.blue.cterm,
bg = C.blue.gui }
set_hl("visual", selection_normal_h)
set_hl("visualnos", selection_normal_h)
set_hl("Visual", selection_normal_h)
set_hl("Visualnos", selection_normal_h)
-- diff ------------------------------------------------------------------------
local diff_add_h = H:new():fg(green_c)
local diff_change_h = H:new():fg(orange_c)
local diff_delete_h = H:new():fg(red_c)
local diff_text_h = H:new():fg(orange_c):attr("underline")
local diff_add_h = { ctermfg = C.green.cterm, fg = C.green.gui }
local diff_change_h = { ctermfg = C.orange.cterm, fg = C.orange.gui }
local diff_delete_h = { ctermfg = C.red.cterm, fg = C.red.gui }
local diff_text_h = { ctermfg = C.orange.cterm, fg = C.orange.gui, underline = true }
set_hl("DiffAdd", diff_add_h)
set_hl("DiffChange", diff_change_h)
@ -210,8 +216,8 @@ set_hl("DiffDelete", diff_delete_h)
set_hl("DiffText", diff_text_h)
-- spell -----------------------------------------------------------------------
local spell_error_h = H:new():fg(red_c):attr("underline")
local spell_warn_h = H:new():fg(orange_c):attr("underline")
local spell_error_h = { ctermfg = C.red.cterm, fg = C.red.gui, underline = true }
local spell_warn_h = { ctermfg = C.orange.cterm, fg = C.orange.gui, underline = true }
set_hl("SpellBad", spell_error_h)
set_hl("SpellCap", spell_warn_h)
@ -219,16 +225,16 @@ set_hl("SpellLocal", spell_warn_h)
set_hl("SpellRare", spell_warn_h)
-- diagnostic ------------------------------------------------------------------
local diagnostic_error_h = H:new():fg(red_c)
local diagnostic_warn_h = H:new():fg(orange_c)
local diagnostic_info_h = H:new():fg(blue_c)
local diagnostic_hint_h = H:new():fg(white_c)
local diagnostic_ok_h = H:new():fg(green_c)
local diagnostic_error_u_h = H:new():fg(red_c):attr("underline")
local diagnostic_warn_u_h = H:new():fg(orange_c):attr("underline")
local diagnostic_info_u_h = H:new():fg(blue_c):attr("underline")
local diagnostic_hint_u_h = H:new():fg(white_c):attr("underline")
local diagnostic_ok_u_h = H:new():fg(green_c):attr("underline")
local diagnostic_error_h = { ctermfg = C.red.cterm, fg = C.red.gui }
local diagnostic_warn_h = { ctermfg = C.orange.cterm, fg = C.orange.gui }
local diagnostic_info_h = { ctermfg = C.blue.cterm, fg = C.blue.gui }
local diagnostic_hint_h = { ctermfg = C.white.cterm, fg = C.white.gui }
local diagnostic_ok_h = { ctermfg = C.green.cterm, fg = C.green.gui }
local diagnostic_error_u_h = { ctermfg = C.red.cterm, fg = C.red.gui, underline = true }
local diagnostic_warn_u_h = { ctermfg = C.orange.cterm, fg = C.orange.gui, underline = true }
local diagnostic_info_u_h = { ctermfg = C.blue.cterm, fg = C.blue.gui, underline = true }
local diagnostic_hint_u_h = { ctermfg = C.white.cterm, fg = C.white.gui, underline = true }
local diagnostic_ok_u_h = { ctermfg = C.green.cterm, fg = C.green.gui, underline = true }
set_hl("DiagnosticError", diagnostic_error_h)
set_hl("DiagnosticWarn", diagnostic_warn_h)
@ -259,26 +265,26 @@ set_hl("DiagnosticDeprecated", diagnostic_hint_u_h)
set_hl("DiagnosticUnnecessary", diagnostic_hint_u_h)
-- misc ------------------------------------------------------------------------
set_hl("Directory", H:new():fg(blue_c))
set_hl("Directory", { ctermfg = C.blue.cterm, fg = C.blue.gui })
-- syntax ----------------------------------------------------------------------
local syntax_normal_h = {}
local syntax_comment_h = H:new():fg(blue_c)
local syntax_constant_h = H:new():fg(red_c)
local syntax_identifier_h = H:new()
local syntax_statement_h = H:new():fg(orange_c)
local syntax_preproc_h = H:new():fg(magenta_c)
local syntax_type_h = H:new():fg(green_c)
local syntax_special_h = H:new():fg(orange_c)
local syntax_underline_h = H:new():fg(blue_c):attr("underline")
local syntax_ignore_h = H:new():fg(black_c)
local syntax_error_h = H:new():fg(black_c):bg(red_c)
local syntax_warn_h = H:new():fg(black_c):bg(orange_c)
local syntax_comment_h = { ctermfg = C.blue.cterm, fg = C.blue.gui }
local syntax_constant_h = { ctermfg = C.red.cterm, fg = C.red.gui }
local syntax_identifier_h = {}
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_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 }
local syntax_italic_h = H:new():attr("italic")
local syntax_bold_h = H:new():attr("bold")
local syntax_bolditalic_h = H:new():attr("bold"):attr("italic")
local syntax_strike_h = H:new():attr("strikethrough")
local syntax_italic_h = { italic = true }
local syntax_bold_h = { bold = true }
local syntax_bolditalic_h = { bold = true, italic = true }
local syntax_strike_h = { strikethrough = true }
set_hl("Comment", syntax_comment_h)
set_hl("Constant", syntax_constant_h)
@ -322,9 +328,9 @@ set_hl("BoldItalic", syntax_bolditalic_h)
set_hl("Strike", syntax_strike_h)
-- markdown --------------------------------------------------------------------
local markdown_label_h = H:new():fg(magenta_c)
local markdown_delimiter_h = H:new():fg(blue_c)
local markdown_underline_h = H:new():fg(blue_c):attr("underline")
local markdown_label_h = { ctermfg = C.magenta.cterm, fg = C.magenta.gui }
local markdown_delimiter_h = { ctermfg = C.blue.cterm, fg = C.blue.gui }
local markdown_underline_h = { ctermfg = C.blue.cterm, fg = C.blue.gui, underline = true }
set_hl("markdownLabel", markdown_label_h)
set_hl("markdownHeadingDelimiter", markdown_delimiter_h)

View File

@ -17,18 +17,17 @@ opt.signcolumn = "number"
opt.textwidth = 80
opt.colorcolumn = "+1"
opt.expandtab = true
opt.tabstop = 4
opt.shiftwidth = 2
opt.softtabstop = -1
opt.smarttab = true
opt.showtabline = 2
opt.winbar = "%f%( %h%m%r%y%)"
opt.laststatus = 3
local statusline_group = api.nvim_create_augroup("Statusline", {})
local wordcount = fn.wordcount()
api.nvim_create_autocmd({ "TextChanged", "WinEnter", "BufEnter" }, {
group = statusline_group,
callback = function()
wordcount = fn.wordcount()
end
})
local cwd = fn.pathshorten(vim.fn.getcwd())
api.nvim_create_autocmd({ "DirChanged" }, {
group = statusline_group,
@ -38,6 +37,7 @@ api.nvim_create_autocmd({ "DirChanged" }, {
})
function _G.statusline()
local wordcount = fn.wordcount()
return table.concat({
cwd,
" %=",
@ -87,7 +87,7 @@ api.nvim_create_autocmd({ "TermOpen" }, {
-- keymaps ---------------------------------------------------------------------
local keymap_set = vim.keymap.set
keymap_set( "n", "<esc>", function()
keymap_set("n", "<esc>", function()
cmd.nohlsearch()
end, { desc = "Stop the highlighting for the 'hlsearch' option" })
@ -138,7 +138,9 @@ keymap_set("n", "<leader>g", function()
end)
if not file then return end
cmd.vimgrep(pattern, file)
end)
end, { desc = ":vimgrep" })
keymap_set("i", "<c-f>", "<c-x><c-f>", { desc = "File name completion" })
-- netrw -----------------------------------------------------------------------
local g = vim.g