nvim-config

Log | Files | Refs | Submodules | README

commit 6827d3da3d6fea36f83f09bf5139740ba7e7d682
parent 5d33305670670d10bb975a3589b86fc5ef527dca
Author: Thomas Vigouroux <thomas.vigouroux@protonmail.com>
Date:   Tue, 25 Jul 2023 14:12:03 +0200

feat: mega update

Diffstat:
Mafter/ftplugin/c.lua | 2+-
Aafter/ftplugin/query.lua | 1+
Mafter/ftplugin/tex.lua | 95++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mafter/plugin/colors.vim | 6+++---
Mafter/plugin/mappings.lua | 1+
Dafter/queries/latex/highlights.scm | 21---------------------
Mcolors/oakv2.lua | 204++++++++++++++++++++++++++++++++++++++-----------------------------------------
Minit.lua | 13++++---------
Mlua/azy_config.lua | 2++
Mlua/completree-config.lua | 11+++++++----
Mlua/lsp_config.lua | 162+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
Mlua/mappings.lua | 6++++--
Mlua/oakgen.lua | 62++++++++++++++++++++++++++++++++++++++++++--------------------
Mlua/plugins.lua | 53++++++++++++++++++++++++++++++++++-------------------
Aqueries/latex/highlights.scm | 27+++++++++++++++++++++++++++
15 files changed, 411 insertions(+), 255 deletions(-)

diff --git a/after/ftplugin/c.lua b/after/ftplugin/c.lua @@ -1,7 +1,7 @@ vim.opt_local.expandtab = true vim.opt_local.textwidth = 100 vim.opt_local.foldmethod = "expr" -vim.opt_local.foldexpr = "nvim_treesitter#foldexpr()" +-- vim.opt_local.foldexpr = "nvim_treesitter#foldexpr()" vim.opt_local.foldlevel = 0 vim.opt_local.comments:prepend(":///") vim.opt_local.commentstring = "//%s" diff --git a/after/ftplugin/query.lua b/after/ftplugin/query.lua @@ -0,0 +1 @@ +vim.bo.omnifunc = 'v:lua.vim.treesitter.query.omnifunc' diff --git a/after/ftplugin/tex.lua b/after/ftplugin/tex.lua @@ -14,6 +14,11 @@ if #vim.fs.find({ "Makefile", "makefile" }, { type = "file" }) == 0 then vim.cmd [[compiler latexmk]] end +MiniPairs.map_buf(0, 'i', '$', { action = 'closeopen', pair = '$$', register = { cr = false } }) +-- XXX: when calling map_buf, it resets the mapping for `<CR>` and `<BS>`, so we need to reset them +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 p = require 'nvim-treesitter.parsers' @@ -117,12 +122,15 @@ do [ (inline_formula) (displayed_equation) + (math_environment) ] @_root ]]) vim.keymap.set({ 'o', 'v' }, 'am', with_current_position(function(curbuf, _, cursor) local _, node = find_smallest_match(cursor[1] - 1, cursor[2], query, curbuf) - ts_utils.update_selection(curbuf, node) + if node then + ts_utils.update_selection(curbuf, node) + end end), { buffer = true }) end @@ -260,3 +268,88 @@ end)) vis_input_change('<LocalLeader>e', 'Environment name: ', preffix_suffix_change(function(input) return string.format('\\begin{%s}', input), string.format('\\end{%s}', input) end)) + +local function toggle_thing(query, left, right) + return function(buf, win, cursor) + local match, node = find_smallest_match(cursor[1] - 1, cursor[2], query, buf) + + local innode = index_by_name(query, match or {}, "in") + if not innode then + if node then + local sline, scol, eline, ecol = vim.treesitter.get_node_range(node) + vim.api.nvim_buf_set_text(buf, sline, scol, eline, ecol, {}) + else + vim.api.nvim_buf_set_text(buf, cursor[1] - 1, cursor[2], cursor[1] - 1, cursor[2], { left .. right }) + vim.api.nvim_win_set_cursor(win, { cursor[1], cursor[2] + #left }) + end + else + local _, _, _, ecol = vim.treesitter.get_node_range(innode) + if ecol == cursor[2] then + -- At the end of the node, move out + vim.api.nvim_win_set_cursor(win, { cursor[1], cursor[2] + #right }) + end + end + end +end + +do + local inline_fml_query = vim.treesitter.query.parse("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", [[ + ((generic_command + command: (command_name) @_name + arg: (curly_group (_)? @in)) + (#match? @_name "^(\\\\textit|\\\\mathit)$")) @_root + ]]) + vim.keymap.set('i', '<C-T>', with_current_position(toggle_thing(italics_query, "\\textit{", "}"))) + + local bold_query = vim.treesitter.query.parse("latex", [[ + ((generic_command + command: (command_name) @_name + arg: (curly_group (_)? @in)) + (#match? @_name "^(\\\\textbf|\\\\mathbf)$")) @_root + ]]) + vim.keymap.set('i', '<C-B>', with_current_position(toggle_thing(bold_query, "\\textbf{", "}"))) +end + +-- Delete surrounding environment / function call +do + local function_query = vim.treesitter.query.parse("latex", [[ + (generic_command + command: (command_name) @_name + arg: (curly_group (_) @in)) @_root + ]]) + + vim.keymap.set('n', '<LocalLeader>df', with_current_position(function(curbuf, curwin, cursor) + local match, node = find_smallest_match(cursor[1] - 1, cursor[2], function_query, curbuf) + + if not match then + print("Not in an function") + return + end + + local start_row, _, end_row, _ = node:range() + + local innode = index_by_name(function_query, match, "in") + + -- Correct the cursor position (this is at best a guesstimation) + local cname = index_by_name(function_query, match, "_name") + local cstartline = cname:start() + local srow, scol, _, ecol = innode:range() + if cstartline == cursor[1] - 1 then + cursor[2] = math.min(math.max(scol, cursor[2]), ecol - 1) + local offset = #vim.treesitter.get_node_text(cname, curbuf) + 1 -- the bracket + vim.api.nvim_win_set_cursor(curwin, { cursor[1], cursor[2] - offset }) + elseif srow == cursor[1] - 1 then + vim.api.nvim_win_set_cursor(curwin, { cursor[1] - 1, math.max(scol, cursor[2]) - scol }) + else + vim.api.nvim_win_set_cursor(curwin, { cursor[1] - 1, cursor[2] }) + end + + local current = vim.treesitter.get_node_text(innode, curbuf) + edit.edit_match(curbuf, match, function_query, { _root = current }, start_row, end_row) + end), { buffer = true }) +end diff --git a/after/plugin/colors.vim b/after/plugin/colors.vim @@ -1,4 +1,4 @@ -" Last Change: 2022 Jul 25 +" Last Change: 2023 Jun 14 highlight link GitSignsAdd DiffAdd highlight link GitSignsAddInline DiffAdd highlight link GitSignsAddLn DiffAdd @@ -11,5 +11,5 @@ highlight link GitSignsDelete DiffDelete highlight link GitSignsDeleteInline DiffDelete highlight link GitSignsDeleteLn DiffDelete -highlight! link StatusLine WinBar -highlight! link StatusLineNC WinBarNC +" highlight! link StatusLine WinBar +" highlight! link StatusLineNC WinBarNC diff --git a/after/plugin/mappings.lua b/after/plugin/mappings.lua @@ -1 +1,2 @@ vim.keymap.set('n', '<Leader>zn', require'zest'.open) +vim.keymap.set('n', '<Leader>q', vim.diagnostic.setqflist) diff --git a/after/queries/latex/highlights.scm b/after/queries/latex/highlights.scm @@ -1,21 +0,0 @@ -;; extends - -;; Some commands should not be spellchecked -[ - (command_name) - (begin) - (end) - (citation) - (color_reference) - (package_include) - (new_command_definition) - (environment_definition) - ] @nospell - -;; Exclude some enviroments from spell-checking -( - (generic_environment (begin name: (curly_group_text text: (_) @_txt))) @nospell - (#eq? @_txt "tikzpicture") - ) - -(key_value_pair key: (_) @nospell) diff --git a/colors/oakv2.lua b/colors/oakv2.lua @@ -1,106 +1,98 @@ -local self = MiniColors.as_colorscheme {} - -local base = MiniColors.convert('#E27950', 'oklch') - -local function colorn(t, clip) - return MiniColors.convert({ - l = t.l or 70, - h = t.h or t.n * (360 / 7) + base.h, - c = t.c or base.c - }, 'hex', { gamut_clip = clip or 'chroma' }) -end - -local new_bg = colorn { n = 0, l = 3.5 } -local new_fg = colorn { n = 0, l = 98 } - -local palette = { - bg = new_bg, - dark = colorn { n = 0, l = 20, c = 5 }, - light = colorn { n = 0, l = 50, c = 5 }, - fg = new_fg, - green = colorn { n = 2 }, - blue = colorn { n = 4 }, - orange = colorn { n = 0 }, - yellow = colorn({ n = 1, l = 80 }, 'lightness'), - red = colorn { h = 30, c = 24, l = 63 }, - - kwcold = colorn { n = 5, c = 11 }, - funchot = colorn { n = 0 }, - string = colorn({ n = 3 }, 'lightness'), - type = colorn { n = 2 }, -} - -self.groups.Normal = { fg = palette.fg, bg = palette.bg } -self.groups.Identifier = { link = 'Normal' } - -self.groups.Search = { bg = palette.orange, fg = palette.bg } - -self.groups.MatchParen = { bg = palette.dark } -self.groups.Visual = { bg = palette.dark } -self.groups.LineNr = { fg = palette.light } -self.groups.CursorLineNr = { bg = palette.dark } -self.groups.StatusLine = { bg = palette.dark, bold = true, fg = palette.fg } -self.groups.StatusLineNC = { bg = palette.dark, fg = palette.fg } -self.groups.WinSeparator = { fg = palette.dark } -self.groups.Pmenu = { bg = palette.dark } -self.groups.PmenuSel = { bg = palette.light } -self.groups.ColorColumn = { bg = palette.bg } -self.groups.CursorColumn = { bg = palette.dark } -self.groups.CursorLine = { bg = palette.dark } - -self.groups.NonText = { fg = palette.dark } - -self.groups.Comment = { fg = palette.light, italic = true } -self.groups.Special = { fg = palette.fg } -self.groups["@namespace"] = { fg = palette.type } - -self.groups.Keyword = { fg = palette.kwcold } -self.groups.Statement = { link = 'Keyword'} -self.groups.Conditional = { link = 'Keyword'} -self.groups.Operator = { link = 'Keyword'} -self.groups.PreProc = { link = 'Keyword' } -self.groups.Macro = { link = 'Keyword' } - -self.groups.Function = { fg = palette.funchot } - -self.groups.String = { fg = palette.string } - -self.groups.Number = { fg = palette.yellow } -self.groups.Boolean = { fg = palette.yellow, bold = true } - -self.groups.Type = { fg = palette.type, italic = true } -self.groups.Char = { fg = palette.type } -self.groups.SpecialChar = { fg = palette.type } -self.groups.DiffAdd = { fg = palette.green } -self.groups.DiffChange = { fg = palette.yellow } -self.groups.DiffDelete = { fg = palette.red } - -self.groups.NormalFloat = { link = 'Normal' } -self.groups.SignColumn = { link = 'Normal' } --- self.groups.NormalFloat = { bg = colorn { n = 4 } } - -local function diag(name, color) - self.groups['Diagnostic' .. name] = { fg = color } - self.groups['DiagnosticUnderline' .. name] = { sp = color, underline = true } -end - -diag('Warn', palette.orange) -diag('Hint', palette.fg) -diag('Info', palette.blue) -self.groups.Error = { fg = palette.red } -diag('Error', palette.red) -self.groups.ErrorMsg = { link = 'Error' } - -self.groups.Title = { fg = palette.orange } -self.groups.Underlined = { fg = palette.fg, underline = true } -self.groups['@parameter'] = { fg = palette.fg, italic = true } -self.groups['@text.reference'] = { fg = palette.yellow } -self.groups['@text.environment'] = { link = 'Keyword' } -self.groups['@text.environment.name'] = { fg = palette.light } -self.groups['@text.emphasis'] = { italic = true } -self.groups['@text.strong'] = { bold = true } -self.groups.Todo = { link = 'Normal' } - -self = self:resolve_links() --- self = self:compress() -self:apply() +-- Made with 'mini.colors' module of https://github.com/echasnovski/mini.nvim + +if vim.g.colors_name ~= nil then vim.cmd('highlight clear') end +vim.g.colors_name = "oak" + +-- Highlight groups +local hi = vim.api.nvim_set_hl + +hi(0, "@attribute", { link = "Keyword" }) +hi(0, "@constant.builtin", { bold = true, ctermfg = 95, fg = "#846154" }) +hi(0, "@function.builtin", { ctermfg = 95, fg = "#846154" }) +hi(0, "@namespace", { ctermfg = 71, fg = "#69bd6b" }) +hi(0, "@parameter", { ctermfg = 255, fg = "#ffebe2", italic = true }) +hi(0, "@punctuation.special", { ctermfg = 95, fg = "#846154" }) +hi(0, "@text.emphasis", { italic = true }) +hi(0, "@text.environment", { link = "Keyword" }) +hi(0, "@text.environment.name", { ctermfg = 95, fg = "#846154" }) +hi(0, "@text.reference", { ctermfg = 185, fg = "#e6c44b" }) +hi(0, "@text.strong", { bold = true }) +hi(0, "Boolean", { bold = true, ctermfg = 185, fg = "#e6c44b" }) +hi(0, "Char", { ctermfg = 71, fg = "#69bd6b" }) +hi(0, "ColorColumn", { bg = "#0e0200", ctermbg = 232 }) +hi(0, "Comment", { ctermfg = 95, fg = "#846154", italic = true }) +hi(0, "Conditional", { link = "Keyword" }) +hi(0, "Constant", { ctermfg = 185, fg = "#e6c44b", italic = true }) +hi(0, "CursorColumn", { bg = "#43251a", ctermbg = 236 }) +hi(0, "CursorLine", { bg = "#43251a", ctermbg = 236 }) +hi(0, "CursorLineNr", { bg = "#43251a", ctermbg = 236 }) +hi(0, "DiagnosticError", { ctermfg = 197, fg = "#fe394f" }) +hi(0, "DiagnosticHint", { ctermfg = 255, fg = "#ffebe2" }) +hi(0, "DiagnosticInfo", { ctermfg = 75, fg = "#53adfa" }) +hi(0, "DiagnosticUnderlineError", { sp = "#fe394f", underline = true }) +hi(0, "DiagnosticUnderlineHint", { sp = "#ffebe2", underline = true }) +hi(0, "DiagnosticUnderlineInfo", { sp = "#53adfa", underline = true }) +hi(0, "DiagnosticUnderlineWarn", { sp = "#e6c44b", underline = true }) +hi(0, "DiagnosticUnnecessary", { sp = "#ffebe2", underline = true }) +hi(0, "DiagnosticWarn", { ctermfg = 185, fg = "#e6c44b" }) +hi(0, "DiffAdd", { ctermfg = 71, fg = "#69bd6b" }) +hi(0, "DiffChange", { ctermfg = 185, fg = "#e6c44b" }) +hi(0, "DiffDelete", { ctermfg = 197, fg = "#fe394f" }) +hi(0, "Error", { ctermfg = 197, fg = "#fe394f" }) +hi(0, "ErrorMsg", { link = "Error" }) +hi(0, "Function", { ctermfg = 209, fg = "#ef855c" }) +hi(0, "Identifier", { link = "Normal" }) +hi(0, "Keyword", { ctermfg = 140, fg = "#af96e2" }) +hi(0, "LineNr", { ctermfg = 95, fg = "#846154" }) +hi(0, "LspInlayHint", { link = "Comment" }) +hi(0, "LspReferenceRead", { sp = "#ef855c", underline = true }) +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, "NonText", { ctermfg = 236, fg = "#43251a" }) +hi(0, "Normal", { bg = "#0e0200", ctermbg = 232, ctermfg = 255, fg = "#ffebe2" }) +hi(0, "NormalFloat", { link = "Normal" }) +hi(0, "Number", { ctermfg = 185, fg = "#e6c44b" }) +hi(0, "Operator", { link = "Keyword" }) +hi(0, "Pmenu", { bg = "#43251a", ctermbg = 236 }) +hi(0, "PmenuSel", { bg = "#846154", ctermbg = 95 }) +hi(0, "PreProc", { link = "Keyword" }) +hi(0, "Search", { bg = "#ef855c", ctermbg = 209, ctermfg = 232, fg = "#0e0200" }) +hi(0, "SignColumn", { link = "Normal" }) +hi(0, "Special", { ctermfg = 255, fg = "#ffebe2" }) +hi(0, "SpecialChar", { ctermfg = 71, fg = "#69bd6b" }) +hi(0, "SpellBad", { sp = "#fe394f", undercurl = true }) +hi(0, "SpellCap", { sp = "#53adfa", undercurl = true }) +hi(0, "SpellLocal", { link = "SpellBad" }) +hi(0, "SpellRare", { sp = "#ef855c", undercurl = true }) +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, "Title", { ctermfg = 209, fg = "#ef855c" }) +hi(0, "Todo", { link = "Normal" }) +hi(0, "Type", { ctermfg = 71, fg = "#69bd6b", italic = true }) +hi(0, "Underlined", { ctermfg = 255, fg = "#ffebe2", underline = true }) +hi(0, "Visual", { bg = "#43251a", ctermbg = 236 }) +hi(0, "WinSeparator", { ctermfg = 236, fg = "#43251a" }) + +-- Terminal colors +local g = vim.g + +g.terminal_color_0 = "#0e0200" +g.terminal_color_1 = "#ffebe2" +g.terminal_color_2 = "#69bd6b" +g.terminal_color_3 = "#e6c44b" +g.terminal_color_4 = "#53adfa" +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_10 = "#69bd6b" +g.terminal_color_11 = "#e6c44b" +g.terminal_color_12 = "#53adfa" +g.terminal_color_13 = "#af96e2" +g.terminal_color_14 = "#00bdbf" +g.terminal_color_15 = "#ffebe2" diff --git a/init.lua b/init.lua @@ -1,10 +1,7 @@ -local M = {} +vim.loader.enable() -local ok, imp = pcall(require, 'impatient') - --- if ok then --- imp.enable_profile() --- end +vim.g.loaded_matchparen = 1 +vim.g.loaded_matchit = 1 vim.g.python_host_prog = "/bin/python" vim.g.oak_statusline = 1 @@ -104,10 +101,8 @@ vim.api.nvim_create_autocmd("TextYankPost", { }) vim.cmd [[language en_US.utf8]] vim.cmd [[language time POSIX]] -vim.cmd.colorscheme "oak" +vim.cmd.colorscheme "oakv2" -- Now load plugins and such require "mappings" require "neogit-config" - -return M diff --git a/lua/azy_config.lua b/lua/azy_config.lua @@ -13,4 +13,6 @@ vim.keymap.set('n', '<Leader>h', ab.help(), {}) vim.keymap.set('n', '<Leader>b', ab.buffers(), {}) vim.keymap.set('n', '<Leader>q', ab.quickfix(), {}) +vim.ui.select = ab.select + return M diff --git a/lua/completree-config.lua b/lua/completree-config.lua @@ -46,7 +46,6 @@ local fuzzy_lsp = cc.pipeline(cc.optional(s.lsp_matches {}, s.luasnip_matches {} local lsp_completion = { default = fuzzy_lsp, string = cdef.ins_completion "C-F", - path = cdef.ins_completion "C-F", comment = cdef.luasnip, } @@ -57,9 +56,13 @@ comp.setup { 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, cpp = lsp_completion, - lua = lsp_completion, + lua = { + default = fuzzy_lsp, + string = cdef.ins_completion "C-F", + }, rust = lsp_completion, ocaml = lsp_completion, python = lsp_completion, @@ -106,8 +109,8 @@ local function convcommit_snippet(type) 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] + 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 diff --git a/lua/lsp_config.lua b/lua/lsp_config.lua @@ -36,7 +36,6 @@ local function on_attach(client, bufnr) 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>q', vim.diagnostic.setqflist) 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()) @@ -44,7 +43,7 @@ local function on_attach(client, bufnr) vim.opt_local.tagfunc = "v:lua.vim.lsp.tagfunc" - set_keymap('<Leader>e', require"azy.builtins".files(vim.tbl_filter(function(p) + 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()))) @@ -62,12 +61,16 @@ local function on_attach(client, bufnr) end if client.supports_method('textDocument/codeLens') then - set_autocmd({"BufEnter", "CursorHoldI", "InsertLeave"}, vim.lsp.codelens.refresh) + set_autocmd({ "BufEnter", "CursorHoldI", "InsertLeave" }, vim.lsp.codelens.refresh) + end + + if client.supports_method 'textDocument/inlayHint' then + vim.lsp.buf.inlay_hint(bufnr, true) end set_autocmd("CursorHold", function() if not vim.diagnostic.config().virtual_lines then - vim.diagnostic.open_float { focusable = false, scope = 'line' } + vim.diagnostic.open_float { focusable = false, scope = 'cursor' } end end) end @@ -78,59 +81,59 @@ local function texlab_attach(client, bufnr) vim.api.nvim_buf_set_keymap(bufnr, 'n', '<Leader>m', '<cmd>TexlabForward<CR>', { noremap = true, silent = true }) vim.lsp.protocol.SymbolKind = { - 'file'; - 'sec'; - 'fold'; - ''; - 'class'; - 'float'; - 'lib'; - 'field'; - 'label'; - 'enum'; - 'misc'; - 'cmd'; - 'thm'; - 'equ'; - 'strg'; - 'arg'; - ''; - ''; - 'PhD'; - ''; - ''; - 'item'; - 'book'; - 'artl'; - 'part'; - 'coll'; + 'file', + 'sec', + 'fold', + '', + 'class', + 'float', + 'lib', + 'field', + 'label', + 'enum', + 'misc', + 'cmd', + 'thm', + 'equ', + 'strg', + 'arg', + '', + '', + 'PhD', + '', + '', + 'item', + 'book', + 'artl', + 'part', + 'coll', } vim.lsp.protocol.CompletionItemKind = { - 'string'; - ''; - ''; - ''; - 'field'; - ''; - 'class'; - 'misc'; - ''; - 'library'; - 'thesis'; - 'argument'; - ''; - ''; - 'snippet'; - 'color'; - 'file'; - ''; - 'folder'; - ''; - ''; - 'book'; - 'article'; - 'part'; - 'collect'; + 'string', + '', + '', + '', + 'field', + '', + 'class', + 'misc', + '', + 'library', + 'thesis', + 'argument', + '', + '', + 'snippet', + 'color', + 'file', + '', + 'folder', + '', + '', + 'book', + 'article', + 'part', + 'collect', } on_attach(client, bufnr) end @@ -151,7 +154,6 @@ local function setup_lsp(name, filetypes, command, ucommands, config) pattern = filetypes, group = augroup, callback = function(args) - local cpreffix = name:gsub("[-_ ]", "") cpreffix = cpreffix:sub(1, 1):upper() .. cpreffix:sub(2) @@ -175,6 +177,10 @@ local function setup_lsp(name, filetypes, command, ucommands, config) }) end +local function execute_command(client, command, args, bufnr, handler) + return client.request("workspace/executeCommand", { command = command, arguments = args }, handler, bufnr) +end + -- System lsps local capabilities = vim.lsp.protocol.make_client_capabilities() @@ -222,7 +228,8 @@ local system_lsps = { }, clangd = { - command = { "clangd", "--limit-results=0", "--suggest-missing-includes", "--all-scopes-completion", "--compile-commands-dir=build/" }, + command = { "clangd", "--limit-results=0", "--suggest-missing-includes", "--all-scopes-completion", + "--compile-commands-dir=build/" }, filetypes = { "c", "cpp" }, root_markers = { "CMakeLists.txt", ".git" }, }, @@ -253,6 +260,7 @@ local system_lsps = { return { filetypes = { "lua" }, cfg = { + before_init = require("neodev.lsp").before_init, capabilities = capabilities, on_attach = on_attach, settings = { @@ -263,10 +271,24 @@ local system_lsps = { -- Setup your lua path path = vim.split(package.path, ';'), }, + hint = { + enable = true + }, diagnostics = { -- Get the language server to recognize the `vim` global globals = { 'vim' }, + workspaceDelay = -1, + + groupFileStatus = { + strict = "Opened", + strong = "Opened", + }, + + groupSeverity = { + strong = "Warning", + strict = "Warning", + }, }, workspace = { -- Make the server aware of Neovim runtime files @@ -287,6 +309,7 @@ local system_lsps = { end)(), texlab = { + command = { "texlab", "-vvvv" }, filetypes = { "tex", "bib" }, root_markers = { ".latexmkrc", ".git" }, ucommands = { @@ -298,15 +321,12 @@ local system_lsps = { Cancelled = 3, } - local params = { - textDocument = { uri = vim.uri_from_bufnr(bufnr) }, - } - + local params = vim.lsp.util.make_text_document_params(bufnr) client.request('textDocument/build', params, function(err, result) if err then error(tostring(err)) end - print('Build ' .. texlab_build_status[result.status]) + vim.notify('Build ' .. texlab_build_status[result.status]) end, bufnr) end, @@ -327,14 +347,14 @@ local system_lsps = { if err then error(tostring(err)) end - print('Search ' .. texlab_forward_status[result.status]) + vim.notify('Search ' .. texlab_forward_status[result.status]) end) end, CleanAuxiliary = function(client, bufnr) - local uri = vim.uri_from_bufnr(bufnr) client.request("workspace/executeCommand", - { command = "texlab.cleanAuxiliary", arguments = { document = { uri = uri } } }) + { command = "texlab.cleanAuxiliary", arguments = { document = vim.lsp.util.make_text_document_params(bufnr) } }, + function(...) end, bufnr) end, CleanArtifacts = function(client, bufnr) @@ -352,11 +372,14 @@ local system_lsps = { build = { onSave = true, forwardSearchAfter = false, - args = {"-interaction=nonstopmode", "-synctex=1", "-shell-escape", "-pdf", "%f"} + args = { "-interaction=nonstopmode", "-synctex=1", "-shell-escape", "-pdf", "%f" } }, forwardSearch = { executable = "zathura", - args = { "-x", string.format("nvim --server %s --remote-send '<cmd>edit +%%{line} %%{input}<cr>'", vim.fn.serverlist()[1]), "--synctex-forward", "%l:1:%f", "%p" } + 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]), + "--synctex-forward", "%l:1:%f", "%p" } }, } }, @@ -388,7 +411,7 @@ require 'ltex-ls'.setup { language = "auto", diagnosticSeverity = "information", additionalRules = { - enablePickyRules = true, + -- enablePickyRules = true, motherTongue = "fr", }, disabledRules = { @@ -397,7 +420,8 @@ require 'ltex-ls'.setup { }, latex = { commands = { - ["\\MaxMC"] = "dummy" + ["\\MaxMC"] = "dummy", + ["\\todo"] = "ignore" } }, dictionary = (function() diff --git a/lua/mappings.lua b/lua/mappings.lua @@ -1,6 +1,7 @@ -- Completion and so on require "completree-config" local complementree = require 'complementree' +local mpairs = require'mini.pairs' local luasnip = require 'luasnip' local rt = function(codes) return vim.api.nvim_replace_termcodes(codes, true, true, true) @@ -39,13 +40,14 @@ function cr_confirm() feed '<C-Y>' -- sjump() else - feed '<CR>' + feed(mpairs.cr()) end end function backspace() local pumvisible = vim.fn.pumvisible() - feed '<BS>' + -- feed(mpairs.bs()) + vim.api.nvim_feedkeys(mpairs.bs(), 'n', true) vim.schedule(function() if pumvisible == 1 then complementree.complete(true) diff --git a/lua/oakgen.lua b/lua/oakgen.lua @@ -1,35 +1,33 @@ -local self = MiniColors.as_colorscheme {} +local self = MiniColors.as_colorscheme { name = "oak" } local base = MiniColors.convert('#E27950', 'oklch') local function colorn(t, clip) return MiniColors.convert({ - l = t.l or 70, + l = t.l or 68, h = t.h or t.n * (360 / 7) + base.h, c = t.c or base.c }, 'hex', { gamut_clip = clip or 'chroma' }) end local new_bg = colorn { n = 0, l = 3.5 } -local new_fg = colorn { n = 0, l = 98 } +local new_fg = colorn { n = 0, l = 95 } local palette = { bg = new_bg, dark = colorn { n = 0, l = 20, c = 5 }, - light = colorn { n = 0, l = 50, c = 5 }, + light = colorn { n = 0, l = 45, c = 5 }, fg = new_fg, green = colorn { n = 2 }, blue = colorn { n = 4 }, orange = colorn { n = 0 }, - yellow = colorn({ n = 1, l = 80 }, 'lightness'), - red = colorn { h = 30, c = 24, l = 63 }, - + yellow = colorn { n = 1, l = 80 }, + red = colorn { h = 21, c = 23, l = 60 }, kwcold = colorn { n = 5, c = 11 }, funchot = colorn { n = 0 }, - string = colorn({ n = 3 }, 'lightness'), + string = colorn { n = 3 }, type = colorn { n = 2 }, } - self.groups.Normal = { fg = palette.fg, bg = palette.bg } self.groups.Identifier = { link = 'Normal' } @@ -55,9 +53,9 @@ self.groups.Special = { fg = palette.fg } self.groups["@namespace"] = { fg = palette.type } self.groups.Keyword = { fg = palette.kwcold } -self.groups.Statement = { link = 'Keyword'} -self.groups.Conditional = { link = 'Keyword'} -self.groups.Operator = { link = 'Keyword'} +self.groups.Statement = { link = 'Keyword' } +self.groups.Conditional = { link = 'Keyword' } +self.groups.Operator = { link = 'Keyword' } self.groups.PreProc = { link = 'Keyword' } self.groups.Macro = { link = 'Keyword' } @@ -67,6 +65,7 @@ self.groups.String = { fg = palette.string } self.groups.Number = { fg = palette.yellow } self.groups.Boolean = { fg = palette.yellow, bold = true } +self.groups.Constant = { fg = palette.yellow, italic = true } self.groups.Type = { fg = palette.type, italic = true } self.groups.Char = { fg = palette.type } @@ -84,24 +83,47 @@ local function diag(name, color) self.groups['DiagnosticUnderline' .. name] = { sp = color, underline = true } end -diag('Warn', palette.orange) +diag('Warn', palette.yellow) diag('Hint', palette.fg) diag('Info', palette.blue) self.groups.Error = { fg = palette.red } diag('Error', palette.red) self.groups.ErrorMsg = { link = 'Error' } +self.groups.DiagnosticUnnecessary = { sp = palette.fg, underline = true } self.groups.Title = { fg = palette.orange } self.groups.Underlined = { fg = palette.fg, underline = true } +self.groups.Todo = { link = 'Normal' } + +-- Spell groups +self.groups.SpellBad = { sp = palette.red, undercurl = true } +self.groups.SpellLocal = { link = 'SpellBad' } +self.groups.SpellCap = { sp = palette.blue, undercurl = true } +self.groups.SpellRare = { sp = palette.orange, undercurl = true } + +-- Tree sitter groups self.groups['@parameter'] = { fg = palette.fg, italic = true } self.groups['@text.reference'] = { fg = palette.yellow } self.groups['@text.environment'] = { link = 'Keyword' } -self.groups['@text.environment.name'] = { fg = palette.light } +self.groups['@text.environment.name'] = { fg = palette.light } self.groups['@text.emphasis'] = { italic = true } self.groups['@text.strong'] = { bold = true } -self.groups.Todo = { link = 'Normal' } - -self = self:resolve_links() --- self = self:compress() -vim.print(palette) -self:apply() +self.groups['@punctuation.special'] = { fg = palette.light } +self.groups['@attribute'] = { link = 'Keyword' } +self.groups['@function.builtin'] = { fg = palette.light } +self.groups['@constant.builtin'] = { fg = palette.light, bold = true } + +-- LSP groups +self.groups.LspReferenceText = { sp = palette.orange, underline = true } +self.groups.LspReferenceRead = { sp = palette.orange, underline = true } +self.groups.LspReferenceWrite = { sp = palette.orange, underline = true } +self.groups.LspInlayHint = { link = 'Comment' } + +-- self = self:resolve_links() +self = self:compress() +-- vim.print(palette) +self = self:add_cterm_attributes() +self = self:add_terminal_colors() +self:write { name = 'oakv2' } +-- vim.print(palette) +-- self:apply() diff --git a/lua/plugins.lua b/lua/plugins.lua @@ -39,22 +39,7 @@ paq { { 'vigoux/fzy-lua-native', run = 'make' }, --local azy.nvim - { - 'vigoux/notifier.nvim', - config = function() - require "notifier".setup { - component_name_recall = true, - status_width = 50, - notify = { - clear_time = 5000 - }, - } - end - }, - - -- TODO: replace these two - 'tpope/vim-commentary', - 'tpope/vim-surround', + --local notifier -- LSP stuff { @@ -76,17 +61,47 @@ paq { 'vigoux/templar.nvim', --local ratatoskr in opt - 'lewis6991/impatient.nvim', - 'nvim-lua/plenary.nvim', 'lewis6991/gitsigns.nvim', + 'folke/neodev.nvim', + --local oak - 'tamarin-prover/editors' + 'tamarin-prover/editors', + + { + 'echasnovski/mini.nvim', + config = function() + require 'mini.comment'.setup() + require 'mini.pairs'.setup { + modes = { insert = true } + } + require 'mini.colors'.setup() + require 'mini.surround'.setup { + mappings = { + add = 'gsa', + delete = 'gsd', + find = 'gsf', + find_left = 'gsF', + highlight = 'gsh', + replace = 'gsr', + update_n_lines = '', + }, + } + end + } } require 'azy_config' +require "notifier".setup { + component_name_recall = true, + status_width = 100, + notify = { + clear_time = 5000 + }, +} + -- -- sunjon <3 -- use 'sunjon/extmark-toy.nvim' diff --git a/queries/latex/highlights.scm b/queries/latex/highlights.scm @@ -0,0 +1,27 @@ +;; extends + +;; Some commands should not be spellchecked +[ + (command_name) + (begin) + (end) + (citation) + (color_reference) + (package_include) + (new_command_definition) + (environment_definition) + (label_reference) + ] @nospell + +;; Exclude some enviroments from spell-checking +( + (generic_environment (begin name: (curly_group_text text: (_) @_txt))) @nospell + (#eq? @_txt "tikzpicture") + ) + +( + (generic_command command: (_) @_name) @nospell + (#contains? @_name "cite") + ) + +(key_value_pair key: (_) @nospell)