nvim-config

Log | Files | Refs | Submodules | README

commit 32228f9640d6d43f32be6017a294ecdcf2fd23e5
parent 689818327c485e5cd413e94a61b1428f90e5d285
Author: Thomas Vigouroux <thomas.vigouroux@protonmail.com>
Date:   Fri, 29 Sep 2023 10:47:26 +0200

mega update

Diffstat:
Mafter/ftplugin/tex.lua | 53++++++++++++++++++++++++++++++++++++++++++-----------
Mafter/ftplugin/xml.vim | 4++--
Mafter/ftplugin/zig.lua | 2++
Mafter/plugin/mappings.vim | 13+------------
Mcolors/oakv2.lua | 8++++++--
Aftdetect/seq.vim | 2++
Minit.lua | 47++++++++++++++++++++++++++++++++++++++++++++++-
Mlua/completree-config.lua | 125++++---------------------------------------------------------------------------
Mlua/lsp_config.lua | 57+++++++++++++++++++++++++++++++++------------------------
Mlua/mappings.lua | 31++++++++++++++++++++++++++++---
Alua/nluarocks.lua | 7+++++++
Mlua/oakgen.lua | 27+++++++++++++++++++++++++--
Mlua/plugins.lua | 12++++++++----
Alua/shadautls.lua | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aplugin/matchparrents.lua | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Asyntax/seq.vim | 13+++++++++++++
16 files changed, 336 insertions(+), 181 deletions(-)

diff --git a/after/ftplugin/tex.lua b/after/ftplugin/tex.lua @@ -20,10 +20,11 @@ vim.api.nvim_buf_set_keymap(0, 'i', '<CR>', '', { callback = cr_confirm }) vim.api.nvim_buf_set_keymap(0, 'i', '<BS>', '', { callback = backspace }) local edit = require "architext.edit" -local ts_utils = require 'nvim-treesitter.ts_utils' local utls = require "mytsutils" -local p = require 'nvim-treesitter.parsers' +--- Wraps the provided function to call it with the current position as arguments +---@param func fun(buf: buffer, win: window, cursors: integer[]) +---@return function wrapped local function with_current_position(func) return function() local curbuf = vim.api.nvim_get_current_buf() @@ -34,9 +35,35 @@ local function with_current_position(func) end end +local function lazy_query(lang, content) + return setmetatable({ + _lang = lang, + _content = content, + }, { + __index = function(tbl, index) + local query = rawget(tbl, "_query") + if not query then + query = vim.treesitter.query.parse(rawget(tbl, "_lang"), rawget(tbl, "_content")) + rawset(tbl, "_query", query) + end + local qmeta = getmetatable(query) + local res = rawget(qmeta, "__index")[index] + if type(res) == "function" then + return function(_, ...) + return res(query, ...) + end + elseif not res then + return query[index] + else + return res + end + end + }) +end + do -- Replace the surrounding environment - local query = vim.treesitter.query.parse("latex", [[ + local query = lazy_query("latex", [[ (generic_environment (begin (curly_group_text text: (_) @envbegin)) (end (curly_group_text text: (_) @envend))) @_root @@ -116,7 +143,7 @@ end --- Math textobjects do - local query = vim.treesitter.query.parse("latex", [[ + local query = lazy_query("latex", [[ (displayed_equation . (_) @inner (_)? @inner.end .) @outer (inline_formula . (_) @inner (_)? @inner.end .) @outer @@ -128,7 +155,7 @@ end --- Environment textobjects do - local query = vim.treesitter.query.parse("latex", [[ + local query = lazy_query("latex", [[ (generic_environment begin: (_) . (_) @inner (_)? @inner.end . end: (_)) @outer (math_environment begin: (_) . (_) @inner (_)? @inner.end . end: (_)) @outer ]]) @@ -138,7 +165,7 @@ end --- Sections and subsections do - local query = vim.treesitter.query.parse("latex", [[ + local query = lazy_query("latex", [[ ;; No need to match the inner.end differently: the end of the section is its last node (section text: _ . (_) @inner) @outer @inner.end (subsection text: _ . (_) @inner) @outer @inner.end @@ -149,7 +176,7 @@ end --- Enumerate items do - local query = vim.treesitter.query.parse("latex", [[ + local query = lazy_query("latex", [[ (enum_item . (_) @inner) @outer @inner.end ]]) @@ -315,12 +342,12 @@ local function toggle_thing(query, left, right) end do - local inline_fml_query = vim.treesitter.query.parse("latex", [[ + local inline_fml_query = lazy_query("latex", [[ (inline_formula . (_)? @in) @_root ]]) vim.keymap.set('i', '<C-F>', with_current_position(toggle_thing(inline_fml_query, "\\(", "\\)"))) - local italics_query = vim.treesitter.query.parse("latex", [[ + local italics_query = lazy_query("latex", [[ ((generic_command command: (command_name) @_name arg: (curly_group (_)? @in)) @@ -328,7 +355,7 @@ do ]]) vim.keymap.set('i', '<C-T>', with_current_position(toggle_thing(italics_query, "\\textit{", "}"))) - local bold_query = vim.treesitter.query.parse("latex", [[ + local bold_query = lazy_query("latex", [[ ((generic_command command: (command_name) @_name arg: (curly_group (_)? @in)) @@ -339,7 +366,7 @@ end -- Delete surrounding environment / function call do - local function_query = vim.treesitter.query.parse("latex", [[ + local function_query = lazy_query("latex", [[ (generic_command command: (command_name) @_name arg: (curly_group (_) @in)) @_root @@ -375,3 +402,7 @@ do edit.edit_match(curbuf, match, function_query, { _root = current }, start_row, end_row) end), { buffer = true }) end + +--- Tiny mapping to select the node type at cursor and input it +do +end diff --git a/after/ftplugin/xml.vim b/after/ftplugin/xml.vim @@ -1,4 +1,4 @@ -" Last Change: 2020 Dec 08 +" Last Change: 2023 Sep 04 function! s:updateLastMod() " Save window and cursor location: @@ -9,4 +9,4 @@ function! s:updateLastMod() call winrestview(l:winview) endfunction -autocmd BufWritePre *.xml call s:updateLastMod() +" autocmd BufWritePre *.xml call s:updateLastMod() diff --git a/after/ftplugin/zig.lua b/after/ftplugin/zig.lua @@ -1,3 +1,5 @@ vim.opt_local.tabstop = 4 vim.opt_local.shiftwidth = 4 vim.opt_local.softtabstop = 4 + +vim.api.nvim_del_augroup_by_name("vim-zig") diff --git a/after/plugin/mappings.vim b/after/plugin/mappings.vim @@ -1,4 +1,4 @@ -" Last Change: 2023 Feb 16 +" Last Change: 2023 Aug 22 vnoremap <silent> < <gv vnoremap <silent> > >gv @@ -7,17 +7,6 @@ nnoremap <silent> Q @@ nnoremap <silent> yq :copen<CR> nnoremap <silent> yQ :cclose<CR> -inoremap <silent> <CR> <Cmd>lua cr_confirm()<CR> - -imap <silent> <Tab> <CMD>lua tab_complete()<CR> -smap <silent> <Tab> <CMD>lua tab_complete()<CR> - -imap <silent> <BS> <CMD>lua backspace()<CR> -smap <silent> <BS> <CMD>lua backspace()<CR> - -smap <silent> <C-l> <Plug>luasnip-jump-next -imap <silent> <C-l> <Plug>luasnip-jump-next - imap <expr> <S-Tab> pumvisible() ? "\<C-P>" : "\<S-TAB>" nnoremap ' ` diff --git a/colors/oakv2.lua b/colors/oakv2.lua @@ -50,6 +50,8 @@ hi(0, "LspReferenceText", { sp = "#ef855c", underline = true }) hi(0, "LspReferenceWrite", { sp = "#ef855c", underline = true }) hi(0, "Macro", { link = "Keyword" }) hi(0, "MatchParen", { bg = "#43251a", ctermbg = 236 }) +hi(0, "NeogitDiffAddHighlight", { link = "DiffAdd" }) +hi(0, "NeogitDiffDeleteHighlight", { link = "DiffDelete" }) hi(0, "NonText", { ctermfg = 236, fg = "#43251a" }) hi(0, "Normal", { bg = "#0e0200", ctermbg = 232, ctermfg = 255, fg = "#ffebe2" }) hi(0, "NormalFloat", { link = "Normal" }) @@ -70,6 +72,8 @@ hi(0, "Statement", { link = "Keyword" }) hi(0, "StatusLine", { bg = "#43251a", bold = true, ctermbg = 236, ctermfg = 255, fg = "#ffebe2" }) hi(0, "StatusLineNC", { bg = "#43251a", ctermbg = 236, ctermfg = 255, fg = "#ffebe2" }) hi(0, "String", { ctermfg = 37, fg = "#00bdbf" }) +hi(0, "TabLine", {}) +hi(0, "TabLineFill", { link = "TabLine" }) hi(0, "Title", { ctermfg = 209, fg = "#ef855c" }) hi(0, "Todo", { link = "Normal" }) hi(0, "Type", { ctermfg = 71, fg = "#69bd6b", italic = true }) @@ -81,7 +85,7 @@ hi(0, "WinSeparator", { ctermfg = 236, fg = "#43251a" }) local g = vim.g g.terminal_color_0 = "#0e0200" -g.terminal_color_1 = "#ffebe2" +g.terminal_color_1 = "#fe394f" g.terminal_color_2 = "#69bd6b" g.terminal_color_3 = "#e6c44b" g.terminal_color_4 = "#53adfa" @@ -89,7 +93,7 @@ g.terminal_color_5 = "#af96e2" g.terminal_color_6 = "#00bdbf" g.terminal_color_7 = "#ffebe2" g.terminal_color_8 = "#0e0200" -g.terminal_color_9 = "#ffebe2" +g.terminal_color_9 = "#fe394f" g.terminal_color_10 = "#69bd6b" g.terminal_color_11 = "#e6c44b" g.terminal_color_12 = "#53adfa" diff --git a/ftdetect/seq.vim b/ftdetect/seq.vim @@ -0,0 +1,2 @@ +" Last Change: 2023 Mar 16 +au BufRead,BufNewFile *.seq set filetype=seq diff --git a/init.lua b/init.lua @@ -13,7 +13,7 @@ elseif jit.os == "Darwin" then end local o = vim.opt -o.debug = "msg" +-- o.debug = "msg" o.number = true o.relativenumber = true o.hidden = true @@ -106,3 +106,48 @@ vim.cmd.colorscheme "oakv2" -- Now load plugins and such require "mappings" require "neogit-config" + +-- Set up some useful diagnostics stuff +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { remap = false, silent = true }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { remap = false, silent = true }) +vim.keymap.set('n', '<Leader>ll', require("lsp_lines").toggle, { remap = false, silent = true }) +vim.api.nvim_create_autocmd("InsertEnter", { + callback = function() + -- Force off lsp_lines on enter + vim.diagnostic.config { virtual_lines = false } + end +}) +vim.api.nvim_create_autocmd("CursorHold", { + callback = function() + if not vim.diagnostic.config().virtual_lines then + vim.diagnostic.open_float { focusable = false, scope = 'line' } + end + end +}) + +do + local filetypes = { + gitcommit = true, + gitrebase = true, + } + + local secs_in_day = 24 * 60 * 60 + + local function handle(opts) + local mark = require'shadautls'.mark_for_path(vim.fn.fnamemodify(opts.file, ":p")) + if mark and mark.time <= secs_in_day and not filetypes[opts.match] then + vim.cmd [[normal! g`"]] + end + return true + end + + vim.api.nvim_create_autocmd("BufRead", { + callback = function(opts) + vim.api.nvim_create_autocmd("FileType", { + callback = handle, + once = true, + buffer = opts.buf, + }) + end + }) +end diff --git a/lua/completree-config.lua b/lua/completree-config.lua @@ -41,20 +41,17 @@ local function md_complete(...) end end -local fuzzy_lsp = cc.pipeline(cc.optional(s.lsp_matches {}, s.luasnip_matches {}), ccomp.fzy) +local fuzzy_lsp = cc.pipeline(s.lsp_matches {}, ccomp.fzy) local lsp_completion = { default = fuzzy_lsp, string = cdef.ins_completion "C-F", - comment = cdef.luasnip, + comment = cdef.snippy, } comp.setup { default = cdef.ins_completion "C-N", vim = cdef.ins_completion "C-V", - teal = cc.pipeline(cc.optional(s.treesitter_matches {}, s.luasnip_matches {}), ccomp.fzy), - spthy = cc.pipeline(s.luasnip_matches {}, ccomp.fzy), - mail = cc.pipeline(s.luasnip_matches {}, ccomp.fzy), dockerfile = cdef.ins_completion "C-F", query = cdef.ins_completion 'C-O', c = lsp_completion, @@ -66,6 +63,8 @@ comp.setup { rust = lsp_completion, ocaml = lsp_completion, python = lsp_completion, + ql = lsp_completion, + cmake = lsp_completion, nix = { default = fuzzy_lsp, path_expression = cdef.ins_completion "C-F", path_fragment = cdef.ins_completion "C-F" }, tex = lsp_completion, haskell = lsp_completion, @@ -73,122 +72,8 @@ comp.setup { javascript = lsp_completion, typescript = lsp_completion, zig = lsp_completion, + xml = lsp_completion, -- For git commit and text only do luasnip - NeogitCommitMessage = cdef.luasnip, - gitcommit = cdef.luasnip, - text = cdef.luasnip, markdown = md_complete } - --- Luasnip config -local ls = require("luasnip") --- some shorthands... -local s = ls.snippet -local sn = ls.snippet_node -local t = ls.text_node -local i = ls.insert_node -local f = ls.function_node -local c = ls.choice_node -local d = ls.dynamic_node -local l = require("luasnip.extras").lambda -local r = require("luasnip.extras").rep -local p = require("luasnip.extras").partial -local m = require("luasnip.extras").match -local n = require("luasnip.extras").nonempty -local dl = require("luasnip.extras").dynamic_lambda -local types = require("luasnip.util.types") - -local function convcommit_snippet(type) - return { - t(type .. '('), i(1, "scope"), t '): ', - i(2, "title"), - t { "", "", "" }, -- close previous line, open blank, open next - i(0, "body") - } -end - -local function commit_line(args, parent, ty) - local gitname = (vim.fn.systemlist { "git", "config", "user.name" })[1] - local gitmail = (vim.fn.systemlist { "git", "config", "user.email" })[1] - return string.format("%s: %s <%s>", ty, gitname, gitmail) -end - -local comment_tag = (function() - local regex_escape = { - ["-"] = "%-", - ["%"] = "%%", - } - - return function(_, _, _, kind) - -- TODO(vigoux): Only works for preffix only commentstring - local cmt = api.nvim_buf_get_option(0, 'commentstring'):gsub("%%%%", "%%%%%%") - local curline = api.nvim_get_current_line() - - local preffix - local reg = string.format(cmt, ".*$"):gsub(".", regex_escape) - if curline:match(reg) then - -- Already commented - preffix = t(kind .. "(vigoux): ") - else - preffix = t(string.format(cmt, " " .. kind .. "(vigoux): ")) - end - return sn(nil, { - preffix, - i(1, "content") - }) - end -end)() - -ls.add_snippets('all', { - s("todo", { d(1, comment_tag, {}, { user_args = { "TODO" } }) }), - s("fixme", { d(1, comment_tag, {}, { user_args = { "FIXME" } }) }), -}) - -ls.add_snippets('gitcommit', { - s({ trig = "coauth", name = "Co Author", dscr = "A git co-author" }, { - t "Co-authored-by: ", i(1, "name"), t " <", i(2, "email"), t ">" - }), - s({ trig = "fix", name = "Fix message", dscr = "Fix without scope or breaking" }, convcommit_snippet "fix"), - s({ trig = "feat", name = "Feature message", dscr = "Feature without scope or breaking" }, convcommit_snippet "feat"), - s({ trig = "chore", name = "Chore change", dscr = "An update or whatever" }, convcommit_snippet "chore") -}) - -ls.filetype_set('NeogitCommitMessage', { 'gitcommit' }) - -ls.add_snippets('text', { - s({ trig = "ts", dscr = "Tree-sitter test case" }, { - t { "", "=====================", "" }, - i(1, "Title"), - t { "", "=====================", "" }, - i(2, "Body"), - t { "", "---------------" } - }) -}) - -ls.add_snippets('lua', { - s('lreq', { t 'local ', dl(2, l._1:match '[^.]+$', 1), t " = require'", i(1), t { "'", '' } }), -}) - -ls.add_snippets('mail', { - s({ trig = "ack", name = "Acked-by line" }, { - f(commit_line, {}, { user_args = { "Acked-by" } }) - }), - s({ trig = "tested", name = "Tested-by line" }, { - f(commit_line, {}, { user_args = { "Tested-by" } }) - }), -}) - -ls.add_snippets('spthy', { - s({ trig = 'rule', name = 'Protocol rule' }, { - t { "rule " }, - i(1, "RuleName"), - t { ":", " [ " }, - i(2, "Left"), - t { ' ]', ' --[' }, - i(3, "Events"), - t { ']->', ' [ ' }, - i(4, "Right"), - t { " ]", "" } - }) -}) diff --git a/lua/lsp_config.lua b/lua/lsp_config.lua @@ -34,27 +34,16 @@ local function on_attach(client, bufnr) set_keymap('<Leader>d', vim.lsp.buf.definition) set_keymap('gr', vim.lsp.buf.rename) set_keymap('<Leader>a', vim.lsp.buf.code_action) - set_keymap('[d', vim.diagnostic.goto_prev) - set_keymap(']d', vim.diagnostic.goto_next) set_keymap('<Leader>=', vim.lsp.buf.format) set_keymap('gR', require "azy.builtins".lsp.references()) set_keymap('<Leader>s', require "azy.builtins".lsp.workspace_symbols()) - vim.opt_local.tagfunc = "v:lua.vim.lsp.tagfunc" set_keymap('<Leader>e', require "azy.builtins".files(vim.tbl_filter(function(p) return #p > 0 and p ~= vim.fn.expand("$HOME") end, vim.lsp.buf.list_workspace_folders()))) - -- LSP lines setup - set_keymap('<Leader>lr', vim.lsp.codelens.run) - set_keymap('<Leader>ll', require("lsp_lines").toggle) - set_autocmd("InsertEnter", function() - -- Force off lsp_lines on enter - vim.diagnostic.config { virtual_lines = false } - end) - if client.supports_method('textDocument/documentHighlight') then set_autocmd("CursorHold", vim.lsp.buf.document_highlight) set_autocmd("CursorMoved", vim.lsp.buf.clear_references) @@ -62,17 +51,12 @@ local function on_attach(client, bufnr) if client.supports_method('textDocument/codeLens') then set_autocmd({ "BufEnter", "CursorHoldI", "InsertLeave" }, vim.lsp.codelens.refresh) + set_keymap('<Leader>lr', vim.lsp.codelens.run) end if client.supports_method 'textDocument/inlayHint' then - vim.lsp.buf.inlay_hint(bufnr, true) + vim.lsp.inlay_hint(bufnr, true) end - - set_autocmd("CursorHold", function() - if not vim.diagnostic.config().virtual_lines then - vim.diagnostic.open_float { focusable = false, scope = 'cursor' } - end - end) end -- TexLab and LTeX things @@ -160,7 +144,7 @@ local function setup_lsp(name, filetypes, command, ucommands, config) -- Setup user commands if requested for cname, func in pairs(ucommands) do vim.api.nvim_create_user_command(cpreffix .. cname, function(...) - local client = vim.lsp.get_active_clients { name = name }[1] + local client = vim.lsp.get_clients { name = name }[1] func(client, args.buf, ...) end, {}) end @@ -197,6 +181,9 @@ local default_cfg = { capabilities = capabilities, on_attach = on_attach } -- ucommands (table) Mapping from valid command names to lua functions (as in -- nvim_create_user_command, with first argument being the client) to create in the buffer where the thing is started local system_lsps = { + lemminx = { + filetypes = { 'xml' }, + }, hls = { command = { "haskell-language-server-wrapper", "--lsp" }, filetypes = { "haskell" }, @@ -210,13 +197,24 @@ local system_lsps = { capabilities = capabilities, on_attach = on_attach, settings = { - zig = { - enable_snippets = true + zls = { + enable_autofix = false, + enable_snippets = true, + enable_inlay_hints = true, + include_at_in_builtins = true, + inlay_hints_hide_redundant_param_names_last_token = true, + warn_style = true, } } } }, + cmakels = { + command = { "cmake-language-server" }, + filetypes = { "cmake" }, + root_markers = { "CMakeLists.txt", ".git" ,} + }, + tsserver = { command = { "typescript-language-server", "--stdio" }, filetypes = { "typescript", "javascript" }, @@ -256,6 +254,11 @@ local system_lsps = { command = { "rustup", "run", "nightly", "rust-analyzer" }, }, + codeql = { + command = { 'codeql', 'execute', 'language-server', '--check-errors=ON_CHANGE'}, + filetypes = { 'ql' }, + }, + ["lua-language-server"] = (function() return { filetypes = { "lua" }, @@ -377,8 +380,9 @@ local system_lsps = { forwardSearch = { executable = "zathura", args = { "-x", - -- First level of escaping is for string.format, second level for escaping is for texlab - string.format("nvim --server %s --remote-send '<cmd>edit +%%%%{line} %%%%{input}<cr>'", vim.fn.serverlist()[1]), + -- First level of escaping is for string.format, second level for escaping is for texlab + string.format("nvim --server %s --remote-send '<cmd>edit +%%%%{line} %%%%{input}<cr>'", + vim.fn.serverlist()[1]), "--synctex-forward", "%l:1:%f", "%p" } }, } @@ -421,7 +425,12 @@ require 'ltex-ls'.setup { latex = { commands = { ["\\MaxMC"] = "dummy", - ["\\todo"] = "ignore" + ["\\SSAT"] = "dummy", + ["\\SAT"] = "dummy", + ["\\todo"] = "ignore", + }, + environments = { + quote = 'ignore', } }, dictionary = (function() diff --git a/lua/mappings.lua b/lua/mappings.lua @@ -2,7 +2,8 @@ require "completree-config" local complementree = require 'complementree' local mpairs = require'mini.pairs' -local luasnip = require 'luasnip' +local snippy = require 'snippy' +-- local luasnip = require 'luasnip' local rt = function(codes) return vim.api.nvim_replace_termcodes(codes, true, true, true) end @@ -16,9 +17,12 @@ end local function sjump() vim.schedule(function() - if luasnip.jumpable(1) and luasnip.in_snippet() then - luasnip.jump(1) + if snippy.can_jump(1) and snippy.is_active() then + snippy.next() end + -- if luasnip.jumpable(1) and luasnip.in_snippet() then + -- luasnip.jump(1) + -- end end) end @@ -54,3 +58,24 @@ function backspace() end end) end + +vim.keymap.set('i', '<CR>', cr_confirm, { noremap = true }) + +vim.keymap.set({'i', 's'}, '<Tab>', tab_complete) +vim.keymap.set({'i', 's'}, '<BS>', backspace) +vim.keymap.set({'i', 's'}, '<C-l>', snippy.next) + +--- Tiny mapping to select the node at cursor and input it +do + vim.keymap.set('c', '<C-R><C-N>', function() + local node = vim.treesitter.get_node() + if not node then return end + + local types = {} ---@type string[] + repeat + types[#types + 1] = node:type() + node = node:parent() + until not node + vim.api.nvim_input(types[1]) + end) +end diff --git a/lua/nluarocks.lua b/lua/nluarocks.lua @@ -0,0 +1,7 @@ +local lrpath = vim.fn.systemlist { "luarocks", "path", "--lr-path" }[1] +local lrcpath = vim.fn.systemlist { "luarocks", "path", "--lr-cpath" }[1] + +package.path = package.path .. ";" .. lrpath +package.cpath = package.cpath .. ";" .. lrcpath + +require 'luarocks.loader' diff --git a/lua/oakgen.lua b/lua/oakgen.lua @@ -31,6 +31,11 @@ local palette = { self.groups.Normal = { fg = palette.fg, bg = palette.bg } self.groups.Identifier = { link = 'Normal' } +-- Tab line +self.groups.TabLineSel = { bold = true } +self.groups.TabLine = { bg = light } +self.groups.TabLineFill = { link = 'TabLine' } + self.groups.Search = { bg = palette.orange, fg = palette.bg } self.groups.MatchParen = { bg = palette.dark } @@ -119,11 +124,29 @@ self.groups.LspReferenceRead = { sp = palette.orange, underline = true } self.groups.LspReferenceWrite = { sp = palette.orange, underline = true } self.groups.LspInlayHint = { link = 'Comment' } +--- Plugins + +-- Neogit +self.groups.NeogitDiffAddHighlight = { link = 'DiffAdd' } +self.groups.NeogitDiffDeleteHighlight = { link = 'DiffDelete' } + -- self = self:resolve_links() self = self:compress() -- vim.print(palette) self = self:add_cterm_attributes() -self = self:add_terminal_colors() +self = self:add_terminal_colors(false) + +local function set_term_color(nr, color) + self.terminal[nr] = color + self.terminal[nr + 8] = color +end +set_term_color(1, palette.red) +set_term_color(2, palette.green) +set_term_color(3, palette.yellow) +set_term_color(4, palette.blue) +set_term_color(5, palette.kwcold) self:write { name = 'oakv2' } + -- vim.print(palette) --- self:apply() +self:apply() +vim.print(self) diff --git a/lua/plugins.lua b/lua/plugins.lua @@ -34,11 +34,13 @@ paq { -- List your packages --local complementree.nvim - 'L3MON4D3/LuaSnip', - 'nvim-treesitter/nvim-treesitter', - { 'vigoux/fzy-lua-native', run = 'make' }, + -- 'L3MON4D3/LuaSnip', + 'dcampos/nvim-snippy', + 'honza/vim-snippets', + { 'nvim-treesitter/nvim-treesitter', run = ":TSUpdate" }, --local azy.nvim + 'mfussenegger/nvim-qwahl', --local notifier -- LSP stuff @@ -55,7 +57,7 @@ paq { end }, 'vigoux/ltex-ls.nvim', - { 'mfussenegger/nvim-dap', opt = true }, -- TODO load dap-config + { 'mfussenegger/nvim-dap', opt = true }, -- TODO load dap-config --local architext.nvim 'vigoux/templar.nvim', @@ -65,9 +67,11 @@ paq { 'lewis6991/gitsigns.nvim', 'folke/neodev.nvim', + { 'github/copilot.vim', opt = true }, --local oak 'tamarin-prover/editors', + 'dubek/vim-mal', { 'echasnovski/mini.nvim', diff --git a/lua/shadautls.lua b/lua/shadautls.lua @@ -0,0 +1,66 @@ +local M = {} + +local function iter_packed(str) + local unpacker = vim.mpack.Unpacker() + local current = 1 + return function() + if current > #str then + return + end + + local res, newoff = unpacker(str, current) + current = newoff + return res + end +end + +local function get_path() + return vim.fn.stdpath "state" .. "/shada/main.shada" +end + +local function shada_iterator() + local path = get_path() + local content = io.open(path):read "*a" + local mpack_iter = iter_packed(content) + return function() + -- see |shada-format| to get the actual format of this + local type = mpack_iter() + local timestamp = mpack_iter() + -- Drop the length of the entry + mpack_iter() + local data = mpack_iter() + + if type and timestamp and data then + return type, timestamp, data + else + return nil, nil, nil + end + end +end + +function M.read() + local path = get_path() + local content = io.open(path):read "*a" + local acc = {} + for thing in iter_packed(content) do + acc[#acc + 1] = thing + end + return acc +end + +function M.mark_for_path(path, mname) + local timenow = vim.fn.localtime() + mname = vim.fn.char2nr(mname or '"') + + for type, timestamp, data in shada_iterator() do + if type == 10 and data.f == path and (data.n or 34) == mname then + return { + time = timenow - timestamp, + line = data.l, + col = data.c + } + end + end +end + +return M diff --git a/plugin/matchparrents.lua b/plugin/matchparrents.lua @@ -0,0 +1,50 @@ +local PAREN_CHARS = { + ['('] = true, + [')'] = false, + ['{'] = true, + ['}'] = false, + ['['] = true, + [']'] = false, +} + +-- local ns = vim.api.nvim_create_namespace('ts_matchpaten') +-- vim.api.nvim_create_autocmd('CursorMoved', { +-- callback = function() +-- vim.api.nvim_buf_clear_namespace(0, ns, 0, -1) +-- local cursor = vim.api.nvim_win_get_cursor(0) +-- local row, col = cursor[1] - 1, cursor[2] +-- local cursor_char = vim.api.nvim_buf_get_text(0, row, col, row, col + 1, {})[1] +-- +-- local match = PAREN_CHARS[cursor_char] +-- if match == nil then +-- return +-- end +-- +-- local ok, res = pcall(vim.treesitter.get_node) +-- if not ok then return end +-- +-- local node = {res:range()} +-- local row2, col2 --- @type integer, integer +-- if match then +-- row2, col2 = node[3], node[4] -1 +-- else +-- row2, col2 = node[1], node[2] +-- end +-- +-- local cursor_char2 = vim.api.nvim_buf_get_text(0, row2, col2, row2, col2 + 1, {})[1] +-- +-- vim.api.nvim_buf_set_extmark(0, ns, row, col, { +-- end_row = row, +-- end_col = col+1, +-- end_right_gravity = false, +-- hl_group = 'MatchParen' +-- }) +-- +-- vim.api.nvim_buf_set_extmark(0, ns, row2, col2, { +-- end_row = row2, +-- end_col = col2+1, +-- end_right_gravity = false, +-- hl_group = 'MatchParen' +-- }) +-- end +-- }) diff --git a/syntax/seq.vim b/syntax/seq.vim @@ -0,0 +1,13 @@ +" Last Change: 2023 Mar 16 +syntax region Comment start=/\/\/ / end=/$/ +syntax match Keyword /&/ +syntax match Keyword /|/ +syntax match Keyword /,/ +syntax match Keyword /-/ + +syntax match Type /:-/ + +syntax match Delimiter /\.\./ +syntax match Delimiter /\./ +syntax match Constant /T/ +syntax match Constant /F/