feat(nvim): add visual mode comment toggle and SQL commentstring

This commit is contained in:
Oliver
2026-03-13 15:09:55 +01:00
parent 2ec13f085c
commit 4e0f21a398
3 changed files with 17 additions and 21 deletions

View File

@@ -1 +1 @@
{"copilot.lua":"1.393.0"}
{"copilot.lua":"1.417.0"}

View File

@@ -2,16 +2,24 @@ return {
"numToStr/Comment.nvim",
keys = {
{ "<leader>/", desc = "Toggle comment" },
{ "<leader>/", mode = "v", desc = "Toggle comment" },
},
config = function ()
config = function()
require('Comment').setup({
opleader = {
-- Line-comment toggle keymap
line = '<leader>/'
},
toggler = {
line = "<leader>/"
}
})
-- Set commentstring for SQL
vim.api.nvim_create_autocmd("FileType", {
pattern = { "sql", "mysql", "plsql" },
callback = function()
vim.bo.commentstring = "-- %s"
end,
})
end
}

View File

@@ -1,26 +1,14 @@
return {
'nvim-treesitter/nvim-treesitter',
event = "VeryLazy",
lazy = false,
build = ':TSUpdate',
config = function()
-- Neovim's built-in treesitter handles highlighting automatically
-- nvim-treesitter is now mainly a parser installer
-- Auto-install parsers when opening files
-- New nvim-treesitter just installs parsers, Neovim handles highlighting
-- Start treesitter highlighting for all buffers with a parser
vim.api.nvim_create_autocmd("FileType", {
callback = function(args)
local ft = args.match
local lang = vim.treesitter.language.get_lang(ft) or ft
-- Try to start treesitter highlighting
local ok = pcall(vim.treesitter.start, args.buf, lang)
if not ok then
-- Parser not installed, try to install it
pcall(function()
vim.cmd('TSInstall ' .. lang)
end)
end
end
pcall(vim.treesitter.start, args.buf)
end,
})
end
end,
}