Skip to content

Commit

Permalink
fact(highlight): ignore undesired highlights from vim side instead of…
Browse files Browse the repository at this point in the history
… vscode side (#1334)

fact(highlight): ignore undesired highlights from vim side instead of vscode side (#1334)
  BREAKING-CHANGE: `"vscode-neovim.highlightGroups.ignoreHighlights"` is removed, ignore syntax groups from nvim instead by using `hi MySyntaxGroup NONE`.
  • Loading branch information
theol0403 committed Jul 24, 2023
1 parent 0d334af commit 5ed8081
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 426 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 1 addition & 82 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,70 +151,6 @@
"default": false,
"description": "When on, print log messages to vscode developer console (not output channel!)"
},
"vscode-neovim.highlightGroups.ignoreHighlights": {
"type": "array",
"title": "Ignore Highlighs Groups",
"description": "List of vim highlights groups to ignore",
"default": [
"EndOfBuffer",
"ErrorMsg",
"MoreMsg",
"ModeMsg",
"Question",
"VisualNC",
"WarningMsg",
"^Diff",
"Sign",
"SignColumn",
"^Spell",
"^Pmenu",
"^Tab",
"ColorColumn",
"QuickFixLine",
"MsgSeparator",
"MsgArea",
"^RedrawDebug",
"^MatchParen",
"^Nvim",
"Operator",
"Delimiter",
"Identifier",
"SpecialChar",
"Number",
"Type",
"String",
"Error",
"Comment",
"Constant",
"Special",
"Statement",
"PreProc",
"Underlined",
"Ignore",
"Todo",
"Character",
"Boolean",
"Float",
"Function",
"Conditional",
"Repeat",
"Label",
"Keyword",
"Exception",
"Include",
"Define",
"Macro",
"PreCondit",
"StorageClass",
"Structure",
"Typedef",
"Tag",
"SpecialComment",
"Debug",
"Folded",
"FoldColumn"
]
},
"vscode-neovim.highlightGroups.highlights": {
"type": "object",
"title": "Highlight Groups Configuration",
Expand All @@ -231,7 +167,6 @@
]
},
"default": {
"Directory": "vim",
"IncSearch": {
"backgroundColor": "theme.editor.findMatchBackground",
"borderColor": "theme.editor.findMatchBorder"
Expand All @@ -242,24 +177,8 @@
},
"Visual": {
"backgroundColor": "theme.editor.selectionBackground"
},
"Conceal": "vim",
"Substitute": "vim"
}
},
"vscode-neovim.highlightGroups.unknownHighlight": {
"oneOf": [
{
"type": "object"
},
{
"type": "string",
"const": "vim"
}
],
"title": "Unknown Highlight Groups",
"description": "Highlight Configuration for non defined group. Can accept 'vim' to use colors coming from vim or text decoration properties object",
"default": "vim"
}
}
}
},
Expand Down
1 change: 1 addition & 0 deletions runtime/lua/vscode.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require("vscode.defaults")
require("vscode.cursor")

local M = {}
Expand Down
30 changes: 30 additions & 0 deletions runtime/lua/vscode/defaults.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- customise statusbar
vim.opt.shortmess = "filnxtToOFI"

--- Turn on auto-indenting
vim.opt.autoindent = true
vim.opt.smartindent = true

--- split/nosplit doesn't work currently, see https://github.com/asvetliakov/vscode-neovim/issues/329
vim.opt.inccommand = ""

-- disable matchparen because we don't need it
vim.g.loaded_matchparen = 1

-- syntax groups that are hidden by default but can be overridden by `vscode-neovim.highlightGroups.highlights` or init.vim config (inside ColorScheme au)
local function apply_highlights()
vim.api.nvim_set_hl(0, "Normal", {})
vim.api.nvim_set_hl(0, "NormalNC", {})
vim.api.nvim_set_hl(0, "NormalFloat", {})
vim.api.nvim_set_hl(0, "NonText", {})
vim.api.nvim_set_hl(0, "Visual", {})
vim.api.nvim_set_hl(0, "VisualNOS", {})
vim.api.nvim_set_hl(0, "Substitute", {})
vim.api.nvim_set_hl(0, "Whitespace", {})

-- make cursor visible for plugins that use fake cursor
vim.api.nvim_set_hl(0, 'Cursor', { reverse = true })
end

apply_highlights()
vim.api.nvim_create_autocmd({ "FileType", "ColorScheme" }, { callback = apply_highlights })
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- This file is used to force set options which may break the extension. Loaded manually after user config by main_controller.
--- This file is used to force set options which may break the extension. Loaded after user config by main_controller.

vim.opt.shortmess = "filnxtToOFI"
-- ------------------------- forced global options ------------------------- --
vim.opt.cmdheight = 1
vim.opt.wildmode = "list"
vim.cmd [[set wildchar=<C-e>]]
Expand All @@ -10,6 +10,7 @@ vim.opt.backup = false
vim.opt.wb = false
vim.opt.swapfile = false
vim.opt.autoread = false
vim.opt.autowrite = false
vim.opt.cursorline = false
vim.opt.signcolumn = "no"

Expand All @@ -22,33 +23,22 @@ vim.opt.ruler = false
vim.opt.modeline = false
vim.opt.modelines = 0

--- Turn on auto-indenting
vim.opt.autoindent = true
vim.opt.smartindent = true

--- split/nosplit doesn't work currently, see https://github.com/asvetliakov/vscode-neovim/issues/329
vim.opt.inccommand = ""

--- Allow to use vim HL for external buffers, vscode buffers explicitly disable it
vim.cmd [[syntax on]]

-- make cursor visible for plugins what use fake cursor
vim.api.nvim_set_hl(0, 'Cursor', { reverse = true })

-- these are applied to global options and forced on local options
-- --------------------- forced global and local critical options -------------------- --
local function forceoptions(opt)
opt.wrap = false
opt.conceallevel = 0
opt.hidden = true
opt.bufhidden = "hide"
opt.autowrite = false
opt.number = false
opt.relativenumber = false
opt.list = true
--- Need to know tabs for HL
opt.listchars = { tab = "❥♥" }
-- disable syntax hl for vscode buffers
if vim.b.vscode_controlled then
if vim.b.vscode_controlled and opt == vim.opt_local then
opt.syntax = "off"
end
--- Turn off auto-folding
Expand All @@ -59,6 +49,7 @@ local function forceoptions(opt)
opt.lazyredraw = false
end

-- force global options on startup
forceoptions(vim.opt)

-- force local options on buffer load
Expand Down
4 changes: 0 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
const neovimPath = getNeovimPath();
const isWindows = process.platform == "win32";

const highlightConfIgnore = settings.get("highlightGroups.ignoreHighlights");
const highlightConfHighlights = settings.get("highlightGroups.highlights");
const highlightConfUnknown = settings.get("highlightGroups.unknownHighlight");
const useCtrlKeysNormalMode = settings.get("useCtrlKeysForNormalMode", true);
const useCtrlKeysInsertMode = settings.get("useCtrlKeysForInsertMode", true);
const useWsl = isWindows && settings.get("useWSL", false);
Expand All @@ -38,8 +36,6 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
extensionPath: context.extensionPath.replace(/\\/g, "\\\\"),
highlightsConfiguration: {
highlights: highlightConfHighlights,
ignoreHighlights: highlightConfIgnore,
unknownHighlight: highlightConfUnknown,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
neovimPath: neovimPath,
Expand Down

0 comments on commit 5ed8081

Please sign in to comment.