Compare commits

...

3 commits

Author SHA1 Message Date
Sanchayan Maity 00da5c690f
nvim: colors: Minor clean up
The call to highlight_terminal was redundant since we were passing
just {}. Also remove cterm related settings. Upstream has diverged
significantly, so we need not care about upstream any more.
2023-07-11 16:08:31 +05:30
Sanchayan Maity 549bc29b6f
nvim: lsp: Update capabilities check
Dynamic capabilities were introduced in neovim with commit ddd92a7.

With dynamic registration of LSP capabilities, a client's `server_capabilities`
is no longer a sufficient indicator to see if a server supports a feature. We
instead need to use `client.supports_method(<method>)` which  considers both
the dynamic capabilities and static `server_capabilities`.
2023-07-11 16:08:31 +05:30
Sanchayan Maity 5b108ac9b4
nvim: plugins: Minor clean up
Also run TSUpdate if treesitter gets updated.
2023-07-11 16:08:31 +05:30
4 changed files with 52 additions and 66 deletions

View file

@ -706,13 +706,9 @@ local highlight_groups = {
MiniJump2dSpotAhead = { fg = white, style={ 'nocombine' }},
}
-- We do not care about terminals which do not support 256 colors
local terminal_ansi_colors = { }
require('yolokai')(
highlight_group_normal,
highlight_groups,
terminal_ansi_colors
highlight_groups
)
EOF

View file

@ -48,29 +48,29 @@ protocol.CompletionItemKind = {
local lsp_augroup_id = vim.api.nvim_create_augroup("LSP", { clear = true })
local lsp_key_mappings = {
{ "definitionProvider" , 'n', 'pd' , '<cmd>lua PeekDefinition()<CR>' },
{ "definitionProvider" , 'n', 'gd' , '<cmd>lua vim.lsp.buf.definition()<CR>' },
--{ "declarationProvider" , 'n', 'gD' , '<cmd>lua vim.lsp.buf.declaration()<CR>' },
{ "typeDefinitionProvider" , 'n', '<C-k>' , '<cmd>lua vim.lsp.buf.type_definition()<CR>' },
{ "referencesProvider" , 'n', 'gr' , '<cmd>lua vim.lsp.buf.references()<CR>' },
{ "implementationProvider" , 'n', 'gD' , '<cmd>lua vim.lsp.buf.implementation()<CR>' },
{ "documentSymbolProvider" , 'n', '1gd' , '<cmd>lua vim.lsp.buf.document_symbol()<CR>' },
{ "workspaceSymbolProvider", 'n', '1gD' , '<cmd>lua vim.lsp.buf.workspace_symbol()<CR>' },
{ "hoverProvider" , 'n', '<Leader>k', '<cmd>lua vim.lsp.buf.hover()<CR>' },
{ "signatureHelpProvider" , 'n', '<Leader>S', '<cmd>lua vim.lsp.buf.signature_help()<CR>' },
{ "renameProvider" , 'n', 'gR' , '<cmd>lua vim.lsp.buf.rename()<CR>' },
{ "inlayHintProvider" , 'n', 'gi' , '<cmd>lua vim.lsp.inlay_hint(0, nil)<CR>' },
{ "textDocument/definition" , 'n', 'pd' , '<cmd>lua PeekDefinition()<CR>' },
{ "textDocument/definition" , 'n', 'gd' , '<cmd>lua vim.lsp.buf.definition()<CR>' },
--{ "textDocument/declaration" , 'n', 'gD' , '<cmd>lua vim.lsp.buf.declaration()<CR>' },
{ "textDocument/typeDefinition" , 'n', '<C-k>' , '<cmd>lua vim.lsp.buf.type_definition()<CR>' },
{ "textDocument/references" , 'n', 'gr' , '<cmd>lua vim.lsp.buf.references()<CR>' },
{ "textDocument/implementation" , 'n', 'gD' , '<cmd>lua vim.lsp.buf.implementation()<CR>' },
{ "textDocument/documentSymbol" , 'n', '1gd' , '<cmd>lua vim.lsp.buf.document_symbol()<CR>' },
{ "workspace/symbol" , 'n', '1gD' , '<cmd>lua vim.lsp.buf.workspace_symbol()<CR>' },
{ "textDocument/hover" , 'n', '<Leader>k', '<cmd>lua vim.lsp.buf.hover()<CR>' },
{ "textDocument/signatureHelp" , 'n', '<Leader>S', '<cmd>lua vim.lsp.buf.signature_help()<CR>' },
{ "textDocument/rename" , 'n', 'gR' , '<cmd>lua vim.lsp.buf.rename()<CR>' },
{ "textDocument/inlayHint" , 'n', 'gi' , '<cmd>lua vim.lsp.inlay_hint(0, nil)<CR>' },
{ "documentRangeFormattingProvider", 'x', 'gq', '<cmd>lua vim.lsp.buf.format({async=true})<CR>' },
{ "documentFormattingProvider" , 'n', 'gq', '<cmd>lua vim.lsp.buf.format({async=true})<CR>' },
{ "textDocument/rangeFormatting", 'x', 'gq', '<cmd>lua vim.lsp.buf.format({async=true})<CR>' },
{ "textDocument/formatting" , 'n', 'gq', '<cmd>lua vim.lsp.buf.format({async=true})<CR>' },
{ "codeActionProvider", 'n', 'ga' , '<cmd>lua vim.lsp.buf.code_action()<CR>' },
{ "codeActionProvider", 'v', 'ga' , '<cmd>lua vim.lsp.buf.code_action()<CR>' },
{ "codeActionProvider", 'n', '<Leader>r', '<cmd>lua vim.lsp.buf.code_action{only = \'refactor\' }<CR>' },
{ "codeActionProvider", 'v', '<Leader>r', '<cmd>lua vim.lsp.buf.code_action{only = \'refactor\' }<CR>' },
{ "textDocument/codeAction", 'n', 'ga' , '<cmd>lua vim.lsp.buf.code_action()<CR>' },
{ "textDocument/codeAction", 'v', 'ga' , '<cmd>lua vim.lsp.buf.code_action()<CR>' },
{ "textDocument/codeAction", 'n', '<Leader>r', '<cmd>lua vim.lsp.buf.code_action{only = \'refactor\' }<CR>' },
{ "textDocument/codeAction", 'v', '<Leader>r', '<cmd>lua vim.lsp.buf.code_action{only = \'refactor\' }<CR>' },
{ "codeLensProvider", 'n', '<LocalLeader>l', '<cmd>lua vim.lsp.codelens.run()<CR>' },
{ "codeLensProvider", 'n', '<LocalLeader>L', '<cmd>lua vim.lsp.codelens.clear()<CR>' },
{ "textDocument/codeLens", 'n', '<LocalLeader>l', '<cmd>lua vim.lsp.codelens.run()<CR>' },
{ "textDocument/codeLens", 'n', '<LocalLeader>L', '<cmd>lua vim.lsp.codelens.clear()<CR>' },
}
local CODE_ACTION_AVAILABLE = "CodeActionAvailable"
@ -189,12 +189,12 @@ local on_attach = function(client, bufnr)
for _, mappings in pairs(lsp_key_mappings) do
local capability, mode, lhs, rhs = unpack(mappings)
if client.server_capabilities[capability] then
if client.supports_method(capability) then
vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts)
end
end
if client.server_capabilities.codeActionProvider then
if client.supports_method('textDocument/codeAction') then
vim.api.nvim_create_autocmd({"CursorHold", "CursorHoldI"}, {
group = lsp_augroup_id,
buffer = bufnr,
@ -215,7 +215,7 @@ local on_attach = function(client, bufnr)
})
end
if client.server_capabilities.codeLensProvider then
if client.supports_method('textDocument/codeLens') then
vim.api.nvim_create_autocmd({"CursorHold", "CursorHoldI", "InsertLeave"}, {
group = lsp_augroup_id,
buffer = bufnr,
@ -223,7 +223,7 @@ local on_attach = function(client, bufnr)
})
end
if client.server_capabilities.documentHighlightProvider then
if client.supports_method('textDocument/documentHighlight') then
vim.api.nvim_create_autocmd("CursorHold", {
group = lsp_augroup_id,
buffer = bufnr,
@ -236,7 +236,7 @@ local on_attach = function(client, bufnr)
})
end
if client.server_capabilities.inlayHintProvider then
if client.supports_method('textDocument/inlayHint') then
vim.lsp.inlay_hint(bufnr, false)
end
end
@ -250,7 +250,7 @@ vim.api.nvim_create_autocmd("LspAttach", {
for _, mappings in pairs(lsp_key_mappings) do
local capability, mode, lhs, rhs = unpack(mappings)
if client.server_capabilities[capability] then
if client.supports_method(capability) then
vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts)
end
end
@ -267,7 +267,7 @@ vim.api.nvim_create_autocmd("LspDetach", {
for _, mappings in pairs(lsp_key_mappings) do
local capability, mode, lhs, _ = unpack(mappings)
if client.server_capabilities and client.server_capabilities[capability] then
if client.supports_method(capability) then
vim.api.nvim_buf_del_keymap(bufnr, mode, lhs)
end
end

View file

@ -2,28 +2,43 @@
vim.cmd 'packadd cfilter'
require "paq" {
-- Multi-purpose
'echasnovski/mini.nvim' ,
-- FZF
'ibhagwan/fzf-lua' ,
-- Snippets
'dcampos/nvim-snippy' ,
'honza/vim-snippets' ,
-- Git
'lewis6991/gitsigns.nvim' ,
'tpope/vim-fugitive' ,
'SanchayanMaity/gitlinker.nvim' ,
-- Quickfix
'yorickpeterse/nvim-pqf' ,
-- Text objects
'wellle/targets.vim' ,
'chrisgrieser/nvim-various-textobjs',
'andymass/vim-matchup' ,
-- Async jobs
'nvim-lua/plenary.nvim' ,
'tpope/vim-dispatch' ,
-- Tim Pope goodies
'tpope/vim-repeat' ,
'tpope/vim-sleuth' ,
'tpope/vim-dispatch' ,
'junegunn/vim-easy-align' ,
'nvim-lua/plenary.nvim' ,
'mfussenegger/nvim-lint' ,
'nvim-treesitter/nvim-treesitter' ,
-- Treesitter
{
'nvim-treesitter/nvim-treesitter' ,
run = ':TSUpdate'
},
'mfussenegger/nvim-treehopper' ,
'chentoast/marks.nvim' ,
'andymass/vim-matchup' ,
'christoomey/vim-tmux-navigator' ,
-- Linter
'mfussenegger/nvim-lint' ,
-- Language specific
'windwp/nvim-autopairs' ,
'gpanders/nvim-parinfer' ,
-- Miscellaneous
'junegunn/vim-easy-align' ,
'chentoast/marks.nvim' ,
'christoomey/vim-tmux-navigator' ,
'cbochs/portal.nvim'
}

View file

@ -1,5 +1,3 @@
--[[ NOTHING INSIDE THIS FILE NEEDS TO BE EDITED BY THE USER. ]]
--- @class Yolokai.Definition
--- @field bg? string|table the background color
--- @field blend? number the transparency value
@ -13,12 +11,6 @@
--[[/* Vars */]]
--- Which set of colors to use.
local _USE_256 = tonumber(vim.go.t_Co) > 255 or string.find(vim.env.TERM, '256')
--- Which index to use for `cterm` highlights.
local _PALETTE_CTERM = _USE_256 and 2 or 3
--- Which index to use for `gui` highlights.
local _PALETTE_HEX = 1
@ -104,9 +96,6 @@ function yolokai.highlight(group_name, definition) -- {{{ †
highlight.bg = get(definition.bg, _PALETTE_HEX)
highlight.fg = get(definition.fg, _PALETTE_HEX)
highlight.ctermbg = get(definition.bg, _PALETTE_CTERM)
highlight.ctermfg = get(definition.fg, _PALETTE_CTERM)
highlight.blend = definition.blend
local style = definition.style
@ -126,15 +115,7 @@ function yolokai.highlight(group_name, definition) -- {{{ †
vim.api.nvim_set_hl(0, group_name, highlight)
end --}}} ‡
--- Set `g:terminal_color_`s based on `terminal_colors`.
--- @param terminal_colors table a list 1..16 of colors to use in the terminal
function yolokai:highlight_terminal(terminal_colors)
for index, color in ipairs(terminal_colors) do vim.g['terminal_color_'..(index-1)] =
vim.go.termguicolors and color[_PALETTE_HEX] or color[_PALETTE_CTERM]
end
end
return setmetatable(yolokai, {__call = function(self, normal, highlights, terminal_colors)
return setmetatable(yolokai, {__call = function(self, normal, highlights)
--- resolve highlight groups being defined by function calls.
--- @param tbl table the current table being indexed.
--- @param key string the key to resolve the value for.
@ -165,9 +146,6 @@ return setmetatable(yolokai, {__call = function(self, normal, highlights, termin
-- replace the colors_name
vim.g.colors_name = color_name
-- If we aren't using hex nor 256 colorsets.
if not (vim.go.termguicolors or _USE_256) then vim.go.t_Co = '16' end
-- Highlight the baseline.
self.highlight('Normal', normal)
@ -175,7 +153,4 @@ return setmetatable(yolokai, {__call = function(self, normal, highlights, termin
for group_name, _ in pairs(highlights) do
self.highlight(group_name, resolve(highlights, group_name, false))
end
-- Set the terminal highlight colors.
self:highlight_terminal(terminal_colors)
end})