feat(nvim): add visual mode comment toggle and SQL commentstring
This commit is contained in:
@@ -1 +1 @@
|
|||||||
{"copilot.lua":"1.393.0"}
|
{"copilot.lua":"1.417.0"}
|
||||||
|
|||||||
@@ -2,16 +2,24 @@ return {
|
|||||||
"numToStr/Comment.nvim",
|
"numToStr/Comment.nvim",
|
||||||
keys = {
|
keys = {
|
||||||
{ "<leader>/", desc = "Toggle comment" },
|
{ "<leader>/", desc = "Toggle comment" },
|
||||||
|
{ "<leader>/", mode = "v", desc = "Toggle comment" },
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
require('Comment').setup({
|
require('Comment').setup({
|
||||||
opleader = {
|
opleader = {
|
||||||
-- Line-comment toggle keymap
|
|
||||||
line = '<leader>/'
|
line = '<leader>/'
|
||||||
},
|
},
|
||||||
toggler = {
|
toggler = {
|
||||||
line = "<leader>/"
|
line = "<leader>/"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Set commentstring for SQL
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = { "sql", "mysql", "plsql" },
|
||||||
|
callback = function()
|
||||||
|
vim.bo.commentstring = "-- %s"
|
||||||
|
end,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,14 @@
|
|||||||
return {
|
return {
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
event = "VeryLazy",
|
lazy = false,
|
||||||
build = ':TSUpdate',
|
build = ':TSUpdate',
|
||||||
config = function()
|
config = function()
|
||||||
-- Neovim's built-in treesitter handles highlighting automatically
|
-- New nvim-treesitter just installs parsers, Neovim handles highlighting
|
||||||
-- nvim-treesitter is now mainly a parser installer
|
-- Start treesitter highlighting for all buffers with a parser
|
||||||
|
|
||||||
-- Auto-install parsers when opening files
|
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
local ft = args.match
|
pcall(vim.treesitter.start, args.buf)
|
||||||
local lang = vim.treesitter.language.get_lang(ft) or ft
|
end,
|
||||||
|
|
||||||
-- 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
|
|
||||||
})
|
})
|
||||||
end
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user