-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The 'BREAKING CHANGE: extras' table has been renamed to 'autocmd = tr…
…ue'.
- Loading branch information
Showing
7 changed files
with
96 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,68 @@ | ||
vim.api.nvim_create_autocmd('LspTokenUpdate', { | ||
callback = function(args) | ||
local token = args.data.token | ||
local buffer = args.buf | ||
local text = vim.api.nvim_buf_get_text( | ||
buffer, | ||
token.line, | ||
token.start_col, | ||
token.line, | ||
token.end_col, | ||
{} | ||
)[1] | ||
|
||
local highlights = { | ||
'TODO', | ||
'WARN', | ||
'TEST', | ||
'PERF', | ||
'NOTE', | ||
'HACK', | ||
'FIX', | ||
} | ||
local name = 'SolarizedTodo' | ||
|
||
for _, group_name in pairs(highlights) do | ||
if text ~= nil and token.type == 'comment' and text:match(group_name) then | ||
vim.lsp.semantic_tokens.highlight_token( | ||
token, | ||
buffer, | ||
args.data.client_id, | ||
name .. group_name | ||
) | ||
local M = {} | ||
|
||
function M.load_autocmd() | ||
local group = vim.api.nvim_create_augroup('solarized', { clear = true }) | ||
|
||
vim.api.nvim_create_autocmd('ColorSchemePre', { | ||
group = group, | ||
callback = function() | ||
vim.api.nvim_del_augroup_by_id(group) | ||
end, | ||
}) | ||
|
||
vim.api.nvim_create_autocmd('LspTokenUpdate', { | ||
group = group, | ||
callback = function(args) | ||
local token = args.data.token | ||
local buffer = args.buf | ||
local text = vim.api.nvim_buf_get_text( | ||
buffer, | ||
token.line, | ||
token.start_col, | ||
token.line, | ||
token.end_col, | ||
{} | ||
)[1] | ||
|
||
local highlights = { | ||
'TODO', | ||
'WARN', | ||
'TEST', | ||
'PERF', | ||
'NOTE', | ||
'HACK', | ||
'FIX', | ||
} | ||
local name = 'SolarizedTodo' | ||
|
||
for _, group_name in pairs(highlights) do | ||
if | ||
text ~= nil | ||
and token.type == 'comment' | ||
and text:match(group_name) | ||
then | ||
vim.lsp.semantic_tokens.highlight_token( | ||
token, | ||
buffer, | ||
args.data.client_id, | ||
name .. group_name | ||
) | ||
end | ||
end | ||
end | ||
end, | ||
}) | ||
end, | ||
}) | ||
end | ||
|
||
function M.load_autocmd_highlights(c) | ||
local set_hl = require('solarized.utils').set_hl | ||
|
||
set_hl('SolarizedTokenTODO', { fg = c.info }) | ||
set_hl('SolarizedTokenWARN', { fg = c.warning }) | ||
set_hl('SolarizedTokenTEST', { fg = c.violet }) | ||
set_hl('SolarizedTokenPERF', { fg = c.magenta }) | ||
set_hl('SolarizedTokenNOTE', { fg = c.hint }) | ||
set_hl('SolarizedTokenHACK', { fg = c.cyan }) | ||
set_hl('SolarizedTokenFIX', { fg = c.error }) | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
describe('Autocmd', function() | ||
test('Solarized Highlights is being created', function() | ||
vim.cmd.colorscheme('solarized') | ||
local todo = { | ||
'TODO', | ||
'WARN', | ||
'TEST', | ||
'PERF', | ||
'NOTE', | ||
'HACK', | ||
'FIX', | ||
} | ||
|
||
for _, name in pairs(todo) do | ||
local output = vim.api.nvim_get_hl(0, { name = 'SolarizedToken' .. name }) | ||
assert.is_true(type(output.fg) == 'number') | ||
end | ||
end) | ||
end) |