feat(plugin): add showkeys integrationfor quick key preview
Adds nvzone/showkeys plugin and toggles it on demand to display current key bindings, enhancing developer workflow discoverability of mappings.
This commit is contained in:
3 files changed
+158
-138
No files matched your search
+64
-63
@@ -1,74 +1,75 @@
|
||||
add({
|
||||
"mfussenegger/nvim-lint", -- linter
|
||||
"rshkarin/mason-nvim-lint", -- linter installer
|
||||
"stevearc/conform.nvim", -- autoformater
|
||||
"zapling/mason-conform.nvim", -- formatter installer
|
||||
'mfussenegger/nvim-lint', -- linter
|
||||
'rshkarin/mason-nvim-lint', -- linter installer
|
||||
'stevearc/conform.nvim', -- autoformater
|
||||
'szw/vim-maximizer',
|
||||
'zapling/mason-conform.nvim', -- formatter installer
|
||||
})
|
||||
|
||||
-- linter
|
||||
require("lint").linters_by_ft = {
|
||||
["*"] = { "codespell" },
|
||||
["javascript"] = { "eslint_d", "cspell" },
|
||||
["typescript"] = { "eslint_d", "cspell" },
|
||||
["javascriptreact"] = { "eslint_d", "cspell" },
|
||||
["typescriptreact"] = { "eslint_d", "cspell" },
|
||||
["dockerfile"] = { "hadolint" },
|
||||
["markdown"] = { "write_good", "markdownlint" },
|
||||
["text"] = { "write_good" },
|
||||
["sh"] = { "shellcheck" },
|
||||
["yaml"] = { "actionlint" },
|
||||
["python"] = { "ruff" },
|
||||
require('lint').linters_by_ft = {
|
||||
['*'] = { 'codespell' },
|
||||
['javascript'] = { 'eslint_d', 'cspell' },
|
||||
['typescript'] = { 'eslint_d', 'cspell' },
|
||||
['javascriptreact'] = { 'eslint_d', 'cspell' },
|
||||
['typescriptreact'] = { 'eslint_d', 'cspell' },
|
||||
['dockerfile'] = { 'hadolint' },
|
||||
['markdown'] = { 'write_good', 'markdownlint' },
|
||||
['text'] = { 'write_good' },
|
||||
['sh'] = { 'shellcheck' },
|
||||
['yaml'] = { 'actionlint' },
|
||||
['python'] = { 'ruff' },
|
||||
}
|
||||
require("mason-nvim-lint").setup({
|
||||
ensure_installed = require("extensions").linter,
|
||||
automatic_installation = false,
|
||||
require('mason-nvim-lint').setup({
|
||||
ensure_installed = require('extensions').linter,
|
||||
automatic_installation = false,
|
||||
})
|
||||
|
||||
-- formatter
|
||||
require("conform").setup({
|
||||
formatters = {
|
||||
["markdown-toc"] = {
|
||||
condition = function(_, ctx)
|
||||
for _, line in ipairs(vim.api.nvim_buf_get_lines(ctx.buf, 0, -1, false)) do
|
||||
if line:find("<!%-%-% toc %-%->") then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end,
|
||||
},
|
||||
},
|
||||
formatters_by_ft = {
|
||||
["lua"] = { "stylua" },
|
||||
["c"] = { "clang_format" },
|
||||
["cpp"] = { "clang_format" },
|
||||
["h"] = { "clang_format" },
|
||||
["python"] = { "ruff_fix", "ruff_format", "ruff_organize_imports" },
|
||||
["javascript"] = { "biome" },
|
||||
["typescript"] = { "biome" },
|
||||
["typescriptreact"] = { "biome" },
|
||||
["markdown"] = { "prettier", "markdownlint-cli2"},
|
||||
["markdown.mdx"] = { "prettier", "markdownlint-cli2" },
|
||||
["mdx"] = { "prettier" },
|
||||
["_"] = { "trim_whitespace" },
|
||||
},
|
||||
options = {
|
||||
stop_after_first = true,
|
||||
},
|
||||
format_after_save = function(bufnr)
|
||||
if not vim.b[bufnr].conform_disable then
|
||||
return {
|
||||
lsp_format = "fallback",
|
||||
}
|
||||
end
|
||||
end,
|
||||
require('conform').setup({
|
||||
formatters = {
|
||||
['markdown-toc'] = {
|
||||
condition = function(_, ctx)
|
||||
for _, line in ipairs(vim.api.nvim_buf_get_lines(ctx.buf, 0, -1, false)) do
|
||||
if line:find('<!%-%-% toc %-%->') then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end,
|
||||
},
|
||||
},
|
||||
formatters_by_ft = {
|
||||
['lua'] = { 'stylua' },
|
||||
['c'] = { 'clang_format' },
|
||||
['cpp'] = { 'clang_format' },
|
||||
['h'] = { 'clang_format' },
|
||||
['python'] = { 'ruff_fix', 'ruff_format', 'ruff_organize_imports' },
|
||||
['javascript'] = { 'biome' },
|
||||
['typescript'] = { 'biome' },
|
||||
['typescriptreact'] = { 'biome' },
|
||||
['markdown'] = { 'prettier', 'markdownlint-cli2' },
|
||||
['markdown.mdx'] = { 'prettier', 'markdownlint-cli2' },
|
||||
['mdx'] = { 'prettier' },
|
||||
['_'] = { 'trim_whitespace' },
|
||||
},
|
||||
options = {
|
||||
stop_after_first = true,
|
||||
},
|
||||
format_after_save = function(bufnr)
|
||||
if not vim.b[bufnr].conform_disable then
|
||||
return {
|
||||
lsp_format = 'fallback',
|
||||
}
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<leader>tf", function()
|
||||
vim.b.conform_disable = not vim.b.conform_disable
|
||||
local status = vim.b.conform_disable and "disabled" or "enabled"
|
||||
vim.notify("Autoformat " .. status, vim.log.levels.INFO)
|
||||
end, { desc = "Toggle autoformat" })
|
||||
require("mason-conform").setup({
|
||||
ensure_installed = require("extensions").formatter,
|
||||
automatic_installation = true,
|
||||
vim.keymap.set('n', '<leader>tf', function()
|
||||
vim.b.conform_disable = not vim.b.conform_disable
|
||||
local status = vim.b.conform_disable and 'disabled' or 'enabled'
|
||||
vim.notify('Autoformat ' .. status, vim.log.levels.INFO)
|
||||
end, { desc = 'Toggle autoformat' })
|
||||
require('mason-conform').setup({
|
||||
ensure_installed = require('extensions').formatter,
|
||||
automatic_installation = true,
|
||||
})
|
||||
+76
-73
@@ -1,79 +1,82 @@
|
||||
add({
|
||||
"saghen/blink.lib",
|
||||
{ src = "saghen/blink.cmp", build = "cargo build --release" },
|
||||
"rafamadriz/friendly-snippets",
|
||||
'saghen/blink.lib',
|
||||
{ src = 'saghen/blink.cmp', build = 'cargo build --release' },
|
||||
'rafamadriz/friendly-snippets',
|
||||
})
|
||||
|
||||
require("blink.cmp").setup({
|
||||
fuzzy = { implementation = "prefer_rust" },
|
||||
snippets = { preset = "default" },
|
||||
sources = {
|
||||
default = function()
|
||||
local type = vim.fn.getcmdtype()
|
||||
if type == "/" or type == "?" then return { "buffer" } end
|
||||
if type == ":" then return { "cmdline" } end
|
||||
return { "lsp", "path", "snippets", "buffer" }
|
||||
end,
|
||||
providers = {
|
||||
snippets = {
|
||||
opts = {
|
||||
search_paths = { vim.fn.stdpath("config") .. "/snippets" },
|
||||
extended_filetypes = { mdx = { "markdown" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
require('blink.cmp').setup({
|
||||
fuzzy = { implementation = 'prefer_rust' },
|
||||
snippets = { preset = 'default' },
|
||||
sources = {
|
||||
default = function()
|
||||
local type = vim.fn.getcmdtype()
|
||||
if type == '/' or type == '?' then
|
||||
return { 'buffer' }
|
||||
end
|
||||
if type == ':' then
|
||||
return { 'cmdline' }
|
||||
end
|
||||
return { 'lsp', 'path', 'snippets', 'buffer' }
|
||||
end,
|
||||
providers = {
|
||||
snippets = {
|
||||
opts = {
|
||||
search_paths = { vim.fn.stdpath('config') .. '/snippets' },
|
||||
extended_filetypes = { mdx = { 'markdown' } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
completion = {
|
||||
ghost_text = { enabled = true },
|
||||
completion = {
|
||||
ghost_text = { enabled = true },
|
||||
|
||||
list = {
|
||||
selection = {
|
||||
preselect = false,
|
||||
auto_insert = true,
|
||||
},
|
||||
},
|
||||
documentation = {
|
||||
window = { border = "rounded" },
|
||||
auto_show = true,
|
||||
auto_show_delay_ms = 50,
|
||||
},
|
||||
menu = {
|
||||
border = "rounded",
|
||||
draw = {
|
||||
components = {
|
||||
kind_icon = {
|
||||
text = function(ctx)
|
||||
local kind_icon, _, _ = require("mini.icons").get("lsp", ctx.kind)
|
||||
return kind_icon
|
||||
end,
|
||||
highlight = function(ctx)
|
||||
local _, hl, _ = require("mini.icons").get("lsp", ctx.kind)
|
||||
return hl
|
||||
end,
|
||||
},
|
||||
kind = {
|
||||
highlight = function(ctx)
|
||||
local _, hl, _ = require("mini.icons").get("lsp", ctx.kind)
|
||||
return hl
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
signature = {
|
||||
window = { border = "rounded" },
|
||||
},
|
||||
keymap = {
|
||||
preset = "none",
|
||||
["<S-Tab>"] = { "select_prev", "snippet_backward", "fallback" },
|
||||
["<Tab>"] = { "select_next", "snippet_forward", "fallback" },
|
||||
["<CR>"] = { "accept", "fallback" },
|
||||
["<C-space>"] = { "hide", "show" },
|
||||
["<C-y>"] = { "show", "show_documentation", "hide_documentation" },
|
||||
["<C-u>"] = { "scroll_documentation_up", "fallback" },
|
||||
["<C-d>"] = { "scroll_documentation_down", "fallback" },
|
||||
},
|
||||
list = {
|
||||
selection = {
|
||||
preselect = false,
|
||||
auto_insert = true,
|
||||
},
|
||||
},
|
||||
documentation = {
|
||||
window = { border = 'rounded' },
|
||||
auto_show = true,
|
||||
auto_show_delay_ms = 50,
|
||||
},
|
||||
menu = {
|
||||
border = 'rounded',
|
||||
draw = {
|
||||
components = {
|
||||
kind_icon = {
|
||||
text = function(ctx)
|
||||
local kind_icon, _, _ = require('mini.icons').get('lsp', ctx.kind)
|
||||
return kind_icon
|
||||
end,
|
||||
highlight = function(ctx)
|
||||
local _, hl, _ = require('mini.icons').get('lsp', ctx.kind)
|
||||
return hl
|
||||
end,
|
||||
},
|
||||
kind = {
|
||||
highlight = function(ctx)
|
||||
local _, hl, _ = require('mini.icons').get('lsp', ctx.kind)
|
||||
return hl
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
signature = {
|
||||
window = { border = 'rounded' },
|
||||
},
|
||||
keymap = {
|
||||
preset = 'none',
|
||||
['<S-Tab>'] = { 'select_prev', 'snippet_backward', 'fallback' },
|
||||
['<Tab>'] = { 'select_next', 'snippet_forward', 'fallback' },
|
||||
['<CR>'] = { 'accept', 'fallback' },
|
||||
['<C-space>'] = { 'hide', 'show' },
|
||||
['<C-y>'] = { 'show', 'show_documentation', 'hide_documentation' },
|
||||
['<C-u>'] = { 'scroll_documentation_up', 'fallback' },
|
||||
['<C-d>'] = { 'scroll_documentation_down', 'fallback' },
|
||||
},
|
||||
})
|
||||
|
||||
+18
-2
@@ -2,11 +2,10 @@ add({
|
||||
'OXY2DEV/markview.nvim', -- rendering for html and markdown
|
||||
'serhez/bento.nvim', -- buffer manager
|
||||
'akinsho/toggleterm.nvim', --float terminal
|
||||
'nvzone/showkeys', -- show keystrokes
|
||||
})
|
||||
require('bento').setup({})
|
||||
|
||||
|
||||
|
||||
-- lazy load markdown preview
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'markdown',
|
||||
@@ -45,4 +44,21 @@ require('toggleterm').setup({
|
||||
},
|
||||
})
|
||||
|
||||
-- showkeys
|
||||
require('showkeys').setup({
|
||||
position = 'top-right',
|
||||
show_count = true,
|
||||
winopts = {
|
||||
focusable = false,
|
||||
relative = 'editor',
|
||||
style = 'minimal',
|
||||
border = 'single',
|
||||
height = 1,
|
||||
row = 1,
|
||||
col = 0,
|
||||
},
|
||||
})
|
||||
|
||||
vim.keymap.set('n', '<leader>ok', '<cmd>ShowkeysToggle<CR>', {
|
||||
desc = 'Toggle Showkeys',
|
||||
})
|
||||
Reference in new issue
Block a user