From e6cd9d72728c0237fe928e41a4b1557f73cc4f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Dudr?= Date: Mon, 17 Oct 2022 13:51:24 +0200 Subject: [PATCH] neovim: fix treesitter --- dot_config/nvim/init.lua | 16 +-- dot_config/nvim/lua/configs/colors.lua | 130 ++++++++++++++++++++++++ dot_config/nvim/lua/configs/options.lua | 2 +- 3 files changed, 132 insertions(+), 16 deletions(-) create mode 100644 dot_config/nvim/lua/configs/colors.lua diff --git a/dot_config/nvim/init.lua b/dot_config/nvim/init.lua index 7271352..ec9482e 100644 --- a/dot_config/nvim/init.lua +++ b/dot_config/nvim/init.lua @@ -39,21 +39,7 @@ vim.cmd [[ -- }}} --- color handling {{{ -local term = vim.env.TERM -if (term ~= 'linux' or vim.g.neoray) -then - vim.cmd('set termguicolors') - vim.g.gruvbox_contrast_dark = 'hard' - vim.cmd('colorscheme gruvbox') - - vim.cmd 'highlight link Directory GruvboxGreen' - vim.cmd 'highlight link Function GruvboxFg1' - vim.cmd 'highlight link Operator GruvboxFg1' -end - -vim.cmd 'highlight link TSVariable Identifier' -vim.cmd 'highlight link TSVariableBuiltin Identifier' +require("configs.colors") -- }}} diff --git a/dot_config/nvim/lua/configs/colors.lua b/dot_config/nvim/lua/configs/colors.lua new file mode 100644 index 0000000..b03c8a1 --- /dev/null +++ b/dot_config/nvim/lua/configs/colors.lua @@ -0,0 +1,130 @@ +local hl = function(group, opts) + if (opts.default == nil) then + opts.default = true + end + vim.api.nvim_set_hl(0, group, opts) +end + +local function normalizeTSHighlight() + -- Misc {{{ + hl('@comment', { link = 'Comment' }) + -- hl('@error', {link = 'Error'}) + hl('@none', { bg = 'NONE', fg = 'NONE' }) + hl('@preproc', { link = 'PreProc' }) + hl('@define', { link = 'Define' }) + hl('@operator', { link = 'Operator' }) + -- }}} + -- Punctuation {{{ + hl('@punctuation.delimiter', { link = 'Delimiter' }) + hl('@punctuation.bracket', { link = 'Delimiter' }) + hl('@punctuation.special', { link = 'Delimiter' }) + -- }}} + -- Literals {{{ + hl('@string', { link = 'String' }) + hl('@string.regex', { link = 'String' }) + hl('@string.escape', { link = 'SpecialChar' }) + hl('@string.special', { link = 'SpecialChar' }) + + hl('@character', { link = 'Character' }) + hl('@character.special', { link = 'SpecialChar' }) + + hl('@boolean', { link = 'Boolean' }) + hl('@number', { link = 'Number' }) + hl('@float', { link = 'Float' }) + -- }}} + -- Functions {{{ + hl('@function', { link = 'Function' }) + hl('@function.call', { link = 'Function' }) + hl('@function.builtin', { link = 'Special' }) + hl('@function.macro', { link = 'Macro' }) + + hl('@method', { link = 'Function' }) + hl('@method.call', { link = 'Function' }) + + hl('@constructor', { link = 'Special' }) + hl('@parameter', { link = 'Identifier' }) + -- }}} + -- Keywords {{{ + hl('@keyword', { link = 'Keyword' }) + hl('@keyword.function', { link = 'Keyword' }) + hl('@keyword.operator', { link = 'Keyword' }) + hl('@keyword.return', { link = 'Keyword' }) + + hl('@conditional', { link = 'Conditional' }) + hl('@repeat', { link = 'Repeat' }) + hl('@debug', { link = 'Debug' }) + hl('@label', { link = 'Label' }) + hl('@include', { link = 'Include' }) + hl('@exception', { link = 'Exception' }) + -- }}} + -- Types {{{ + hl('@type', { link = 'Type' }) + hl('@type.builtin', { link = 'Type' }) + hl('@type.qualifier', { link = 'Type' }) + hl('@type.definition', { link = 'Typedef' }) + + hl('@storageclass', { link = 'StorageClass' }) + hl('@attribute', { link = 'PreProc' }) + hl('@field', { link = 'Identifier' }) + hl('@property', { link = 'Identifier' }) + -- }}} + -- Identifiers {{{ + hl('@variable', { link = 'Identifier' }) + hl('@variable.builtin', { link = 'Identifier' }) + + hl('@constant', { link = 'Constant' }) + hl('@constant.builtin', { link = 'Special' }) + hl('@constant.macro', { link = 'Define' }) + + hl('@namespace', { link = 'Include' }) + hl('@symbol', { link = 'Identifier' }) + -- }}} + -- Text {{{ + hl('@text', { link = 'Normal' }) + hl('@text.strong', { bold = true }) + hl('@text.emphasis', { italic = true }) + hl('@text.underline', { underline = true }) + hl('@text.strike', { strikethrough = true }) + hl('@text.title', { link = 'Title' }) + hl('@text.literal', { link = 'String' }) + hl('@text.uri', { link = 'Underlined' }) + hl('@text.math', { link = 'Special' }) + hl('@text.environment', { link = 'Macro' }) + hl('@text.environment.name', { link = 'Type' }) + hl('@text.reference', { link = 'Constant' }) + + hl('@text.todo', { link = 'Todo' }) + hl('@text.note', { link = 'SpecialComment' }) + hl('@text.warning', { link = 'WarningMsg' }) + hl('@text.danger', { link = 'ErrorMsg' }) + -- }}} + -- Tags {{{ + hl('@tag', { link = 'Tag' }) + hl('@tag.attribute', { link = 'Identifier' }) + hl('@tag.delimiter', { link = 'Delimiter' }) + -- }}} +end + +local function customLinks() + hl('Function', { link = 'Normal', default = false }) + hl('Operator', { link = 'Normal', default = false }) +end + +vim.api.nvim_create_autocmd('Colorscheme', + { pattern = "*", callback = function() normalizeTSHighlight(); customLinks(); end } +) + +vim.api.nvim_create_autocmd('Colorscheme', { + pattern = "gruvbox", + callback = function() + hl('Directory', { link = 'GruvboxGreen', default = false }) + end +}) + +local term = vim.env.TERM +if (term ~= 'linux' or vim.g.neoray) +then + vim.cmd('set termguicolors') + vim.g.gruvbox_contrast_dark = 'hard' + vim.cmd('colorscheme gruvbox') +end diff --git a/dot_config/nvim/lua/configs/options.lua b/dot_config/nvim/lua/configs/options.lua index ffb0ecd..c3bcadf 100644 --- a/dot_config/nvim/lua/configs/options.lua +++ b/dot_config/nvim/lua/configs/options.lua @@ -20,7 +20,7 @@ function M.setup() vim.o.shiftwidth = 4 vim.o.number = true --vim.o.colorcolumn=0 - --vim.o.foldmethod='marker' + vim.o.foldmethod='marker' vim.o.foldcolumn = 'auto:1' vim.o.signcolumn = 'yes' vim.o.list = false