feat: add neogen and mdx syntax highlighting plugins
This commit is contained in:
3 files changed
+188
-187
No files matched your search
+130
-130
@@ -1,187 +1,187 @@
|
|||||||
local function augroup(name)
|
local function augroup(name)
|
||||||
return vim.api.nvim_create_augroup("nvim" .. name, { clear = true })
|
return vim.api.nvim_create_augroup('nvim' .. name, { clear = true })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Strip trailing spaces before write
|
-- Strip trailing spaces before write
|
||||||
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
|
||||||
group = augroup("strip_space"),
|
group = augroup('strip_space'),
|
||||||
pattern = { "*" },
|
pattern = { '*' },
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.cmd([[ %s/\s\+$//e ]])
|
vim.cmd([[ %s/\s\+$//e ]])
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Check if we need to reload the file when it changed
|
-- Check if we need to reload the file when it changed
|
||||||
vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, {
|
vim.api.nvim_create_autocmd({ 'FocusGained', 'TermClose', 'TermLeave' }, {
|
||||||
group = augroup("checktime"),
|
group = augroup('checktime'),
|
||||||
command = "checktime",
|
command = 'checktime',
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Highlight on yank
|
-- Highlight on yank
|
||||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||||
group = augroup("highlight_yank"),
|
group = augroup('highlight_yank'),
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.highlight.on_yank()
|
vim.highlight.on_yank()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- resize splits if window got resized
|
-- resize splits if window got resized
|
||||||
vim.api.nvim_create_autocmd({ "VimResized" }, {
|
vim.api.nvim_create_autocmd({ 'VimResized' }, {
|
||||||
group = augroup("resize_splits"),
|
group = augroup('resize_splits'),
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.cmd("tabdo wincmd =")
|
vim.cmd('tabdo wincmd =')
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- go to last loc when opening a buffer
|
-- go to last loc when opening a buffer
|
||||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
vim.api.nvim_create_autocmd('BufReadPost', {
|
||||||
group = augroup("last_loc"),
|
group = augroup('last_loc'),
|
||||||
callback = function()
|
callback = function()
|
||||||
local mark = vim.api.nvim_buf_get_mark(0, '"')
|
local mark = vim.api.nvim_buf_get_mark(0, '"')
|
||||||
local lcount = vim.api.nvim_buf_line_count(0)
|
local lcount = vim.api.nvim_buf_line_count(0)
|
||||||
if mark[1] > 0 and mark[1] <= lcount then
|
if mark[1] > 0 and mark[1] <= lcount then
|
||||||
pcall(vim.api.nvim_win_set_cursor, 0, mark)
|
pcall(vim.api.nvim_win_set_cursor, 0, mark)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- close some filetypes with <q>
|
-- close some filetypes with <q>
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
group = augroup("close_with_q"),
|
group = augroup('close_with_q'),
|
||||||
pattern = {
|
pattern = {
|
||||||
"Jaq",
|
'Jaq',
|
||||||
"PlenaryTestPopup",
|
'PlenaryTestPopup',
|
||||||
"Avante",
|
'Avante',
|
||||||
"AvanteInput",
|
'AvanteInput',
|
||||||
"AvanteSelectedFiles",
|
'AvanteSelectedFiles',
|
||||||
"fugitive",
|
'fugitive',
|
||||||
"git",
|
'git',
|
||||||
"help",
|
'help',
|
||||||
"lir",
|
'lir',
|
||||||
"lspinfo",
|
'lspinfo',
|
||||||
"man",
|
'man',
|
||||||
"netrw",
|
'netrw',
|
||||||
"notify",
|
'notify',
|
||||||
"qf",
|
'qf',
|
||||||
"spectre_panel",
|
'spectre_panel',
|
||||||
"startuptime",
|
'startuptime',
|
||||||
"tsplayground",
|
'tsplayground',
|
||||||
},
|
},
|
||||||
callback = function(event)
|
callback = function(event)
|
||||||
vim.bo[event.buf].buflisted = false
|
vim.bo[event.buf].buflisted = false
|
||||||
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
|
vim.keymap.set('n', 'q', '<cmd>close<cr>', { buffer = event.buf, silent = true })
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- wrap and check for spell in text filetypes
|
-- wrap and check for spell in text filetypes
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
group = augroup("wrap_spell"),
|
group = augroup('wrap_spell'),
|
||||||
pattern = { "gitcommit", "markdown" },
|
pattern = { 'gitcommit', 'markdown' },
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.opt_local.wrap = true
|
vim.opt_local.wrap = true
|
||||||
vim.opt_local.spell = true
|
vim.opt_local.spell = true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Auto create dir when saving a file, in case some intermediate directory does not exist
|
-- Auto create dir when saving a file, in case some intermediate directory does not exist
|
||||||
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
|
||||||
group = augroup("auto_create_dir"),
|
group = augroup('auto_create_dir'),
|
||||||
callback = function(event)
|
callback = function(event)
|
||||||
local file = vim.loop.fs_realpath(event.match) or event.match
|
local file = vim.loop.fs_realpath(event.match) or event.match
|
||||||
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
|
vim.fn.mkdir(vim.fn.fnamemodify(file, ':p:h'), 'p')
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Set arb filetype
|
-- Set arb filetype
|
||||||
vim.api.nvim_create_autocmd({ "BufEnter" }, {
|
vim.api.nvim_create_autocmd({ 'BufEnter' }, {
|
||||||
group = augroup("set_file_type"),
|
group = augroup('set_file_type'),
|
||||||
pattern = { "*.arb" },
|
pattern = { '*.arb' },
|
||||||
command = "setfiletype arb",
|
command = 'setfiletype arb',
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Disable format options
|
-- Disable format options
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
group = augroup("disable_formatoptions"),
|
group = augroup('disable_formatoptions'),
|
||||||
pattern = "*",
|
pattern = '*',
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.opt_local.formatoptions:remove({ "c", "r", "o" })
|
vim.opt_local.formatoptions:remove({ 'c', 'r', 'o' })
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
local function enable_autoformat()
|
local function enable_autoformat()
|
||||||
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
|
||||||
group = augroup("autoformat"),
|
group = augroup('autoformat'),
|
||||||
pattern = { "*" },
|
pattern = { '*' },
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.lsp.buf.format()
|
vim.lsp.buf.format()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
enable_autoformat()
|
enable_autoformat()
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("WriteNoFormat", function()
|
vim.api.nvim_create_user_command('WriteNoFormat', function()
|
||||||
-- Temporarily disable the autoformat autocmd
|
-- Temporarily disable the autoformat autocmd
|
||||||
vim.api.nvim_del_augroup_by_name("keycodex_autoformat")
|
vim.api.nvim_del_augroup_by_name('keycodex_autoformat')
|
||||||
vim.cmd("write")
|
vim.cmd('write')
|
||||||
-- Re-enable the autoformat autocmd
|
-- Re-enable the autoformat autocmd
|
||||||
enable_autoformat()
|
enable_autoformat()
|
||||||
end, {})
|
end, {})
|
||||||
|
|
||||||
-- Macro recording notifications
|
-- Macro recording notifications
|
||||||
vim.api.nvim_create_autocmd("RecordingEnter", {
|
vim.api.nvim_create_autocmd('RecordingEnter', {
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.notify("Macro recording started", vim.log.levels.INFO, {
|
vim.notify('Macro recording started', vim.log.levels.INFO, {
|
||||||
title = "Macro",
|
title = 'Macro',
|
||||||
timeout = 2000,
|
timeout = 2000,
|
||||||
})
|
})
|
||||||
-- Print to command line for debugging
|
-- Print to command line for debugging
|
||||||
vim.cmd("echo 'Recording macro...'")
|
vim.cmd("echo 'Recording macro...'")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("RecordingLeave", {
|
vim.api.nvim_create_autocmd('RecordingLeave', {
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.notify("Macro recording stopped", vim.log.levels.INFO, {
|
vim.notify('Macro recording stopped', vim.log.levels.INFO, {
|
||||||
title = "Macro",
|
title = 'Macro',
|
||||||
timeout = 2000,
|
timeout = 2000,
|
||||||
})
|
})
|
||||||
-- Print to command line for debugging
|
-- Print to command line for debugging
|
||||||
vim.cmd("echo 'Macro recording stopped'")
|
vim.cmd("echo 'Macro recording stopped'")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Function to show macro replay notification
|
-- Function to show macro replay notification
|
||||||
local function show_macro_replay(count)
|
local function show_macro_replay(count)
|
||||||
local message = count > 1 and string.format("Replaying macro %d times", count) or "Replaying macro"
|
local message = count > 1 and string.format('Replaying macro %d times', count) or 'Replaying macro'
|
||||||
vim.notify(message, vim.log.levels.INFO, {
|
vim.notify(message, vim.log.levels.INFO, {
|
||||||
title = "Macro",
|
title = 'Macro',
|
||||||
timeout = 2000,
|
timeout = 2000,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Function to clear all macros
|
-- Function to clear all macros
|
||||||
local function clear_all_macros()
|
local function clear_all_macros()
|
||||||
-- Clear all registers from a to z
|
-- Clear all registers from a to z
|
||||||
for i = 97, 122 do -- ASCII values for 'a' to 'z'
|
for i = 97, 122 do -- ASCII values for 'a' to 'z'
|
||||||
vim.fn.setreg(string.char(i), "")
|
vim.fn.setreg(string.char(i), '')
|
||||||
end
|
end
|
||||||
-- Clear all registers from 0 to 9
|
-- Clear all registers from 0 to 9
|
||||||
for i = 48, 57 do -- ASCII values for '0' to '9'
|
for i = 48, 57 do -- ASCII values for '0' to '9'
|
||||||
vim.fn.setreg(string.char(i), "")
|
vim.fn.setreg(string.char(i), '')
|
||||||
end
|
end
|
||||||
vim.notify("All macros cleared", vim.log.levels.INFO, {
|
vim.notify('All macros cleared', vim.log.levels.INFO, {
|
||||||
title = "Macro",
|
title = 'Macro',
|
||||||
timeout = 2000,
|
timeout = 2000,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create keymaps for macro replay with notifications
|
-- Create keymaps for macro replay with notifications
|
||||||
vim.keymap.set("n", "@", function()
|
vim.keymap.set('n', '@', function()
|
||||||
local count = vim.v.count1
|
local count = vim.v.count1
|
||||||
show_macro_replay(count)
|
show_macro_replay(count)
|
||||||
return "@"
|
return '@'
|
||||||
end, { expr = true })
|
end, { expr = true })
|
||||||
|
|
||||||
-- Add keybinding to clear all macros
|
-- Add keybinding to clear all macros
|
||||||
vim.keymap.set("n", "<leader>mc", clear_all_macros, { desc = "Clear all macros" })
|
vim.keymap.set('n', '<leader>oc', clear_all_macros, { desc = 'Clear all macros' })
|
||||||
@@ -174,4 +174,26 @@ return {
|
|||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- annotation generator
|
||||||
|
{
|
||||||
|
'danymat/neogen',
|
||||||
|
opts = {
|
||||||
|
snippet_engine = 'luasnip',
|
||||||
|
languages = {
|
||||||
|
python = {
|
||||||
|
template = {
|
||||||
|
annotation_convention = 'google_docstrings',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- syntax highlight for mdx
|
||||||
|
{
|
||||||
|
'davidmh/mdx.nvim',
|
||||||
|
config = true,
|
||||||
|
dependencies = { 'nvim-treesitter/nvim-treesitter' },
|
||||||
|
},
|
||||||
}
|
}
|
||||||
+36
-57
@@ -1,42 +1,21 @@
|
|||||||
return {
|
return {
|
||||||
|
|
||||||
{
|
|
||||||
"danymat/neogen",
|
|
||||||
dependencies = { "nvim-treesitter/nvim-treesitter" },
|
|
||||||
opts = {
|
|
||||||
snippet_engine = "luasnip",
|
|
||||||
languages = {
|
|
||||||
python = {
|
|
||||||
template = {
|
|
||||||
annotation_convention = "google_docstrings",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"davidmh/mdx.nvim",
|
|
||||||
config = true,
|
|
||||||
dependencies = { "nvim-treesitter/nvim-treesitter" },
|
|
||||||
},
|
|
||||||
|
|
||||||
-- better escape
|
-- better escape
|
||||||
{
|
{
|
||||||
"max397574/better-escape.nvim",
|
'max397574/better-escape.nvim',
|
||||||
config = function()
|
config = function()
|
||||||
require("better_escape").setup({
|
require('better_escape').setup({
|
||||||
mappings = {
|
mappings = {
|
||||||
-- i for insert, other modes are the first letter too
|
-- i for insert, other modes are the first letter too
|
||||||
i = {
|
i = {
|
||||||
-- map kj to exit insert mode
|
-- map kj to exit insert mode
|
||||||
k = {
|
k = {
|
||||||
j = "<Esc>",
|
j = '<Esc>',
|
||||||
},
|
},
|
||||||
-- map jk and jj to exit insert mode
|
-- map jk and jj to exit insert mode
|
||||||
j = {
|
j = {
|
||||||
k = "<Esc>",
|
k = '<Esc>',
|
||||||
j = "<Esc>",
|
j = '<Esc>',
|
||||||
},
|
},
|
||||||
-- disable jj
|
-- disable jj
|
||||||
j = {
|
j = {
|
||||||
@@ -50,43 +29,43 @@ return {
|
|||||||
|
|
||||||
-- Navigator
|
-- Navigator
|
||||||
{
|
{
|
||||||
"numToStr/Navigator.nvim",
|
'numToStr/Navigator.nvim',
|
||||||
event = "VeryLazy",
|
event = 'VeryLazy',
|
||||||
config = function()
|
config = function()
|
||||||
require("Navigator").setup({
|
require('Navigator').setup({
|
||||||
auto_save = "current",
|
auto_save = 'current',
|
||||||
disable_on_zoom = false,
|
disable_on_zoom = false,
|
||||||
mux = "auto",
|
mux = 'auto',
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- float terminal
|
-- float terminal
|
||||||
{
|
{
|
||||||
"akinsho/toggleterm.nvim",
|
'akinsho/toggleterm.nvim',
|
||||||
cmd = { "ToggleTerm" },
|
cmd = { 'ToggleTerm' },
|
||||||
version = "*",
|
version = '*',
|
||||||
config = function()
|
config = function()
|
||||||
require("toggleterm").setup({
|
require('toggleterm').setup({
|
||||||
size = 10,
|
size = 10,
|
||||||
open_mapping = [[<c-\>]],
|
open_mapping = [[<c-\>]],
|
||||||
hide_numbers = true,
|
hide_numbers = true,
|
||||||
shade_filetypes = {},
|
shade_filetypes = {},
|
||||||
shade_terminals = true,
|
shade_terminals = true,
|
||||||
shading_factor = "2",
|
shading_factor = '2',
|
||||||
start_in_insert = true,
|
start_in_insert = true,
|
||||||
insert_mappings = true,
|
insert_mappings = true,
|
||||||
terminal_mappings = true,
|
terminal_mappings = true,
|
||||||
persist_size = true,
|
persist_size = true,
|
||||||
direction = "float", -- 'vertical' | 'horizontal' | 'tab' | 'float'
|
direction = 'float', -- 'vertical' | 'horizontal' | 'tab' | 'float'
|
||||||
close_on_exit = true,
|
close_on_exit = true,
|
||||||
shell = vim.o.shell,
|
shell = vim.o.shell,
|
||||||
float_opts = {
|
float_opts = {
|
||||||
border = "curved", -- 'single', 'double', 'shadow', etc.
|
border = 'curved', -- 'single', 'double', 'shadow', etc.
|
||||||
winblend = 0, -- Set to 0 for full transparency
|
winblend = 0, -- Set to 0 for full transparency
|
||||||
highlights = {
|
highlights = {
|
||||||
border = "Normal",
|
border = 'Normal',
|
||||||
background = "Normal",
|
background = 'Normal',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -95,7 +74,7 @@ return {
|
|||||||
|
|
||||||
-- smooth scrolling
|
-- smooth scrolling
|
||||||
{
|
{
|
||||||
"karb94/neoscroll.nvim",
|
'karb94/neoscroll.nvim',
|
||||||
opts = {},
|
opts = {},
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -107,33 +86,33 @@ return {
|
|||||||
|
|
||||||
-- uv
|
-- uv
|
||||||
{
|
{
|
||||||
"benomahony/uv.nvim",
|
'benomahony/uv.nvim',
|
||||||
ft = "python",
|
ft = 'python',
|
||||||
event = "BufReadPre",
|
event = 'BufReadPre',
|
||||||
opts = {
|
opts = {
|
||||||
picker_integration = true,
|
picker_integration = true,
|
||||||
keymaps = {
|
keymaps = {
|
||||||
prefix = "<leader>u", -- Main prefix for uv commands
|
prefix = '<leader>u', -- Main prefix for uv commands
|
||||||
commands = true, -- Show uv commands menu (<leader>x)
|
commands = true, -- Show uv commands menu (<leader>x)
|
||||||
run_file = true, -- Run current file (<leader>xr)
|
run_file = true, -- Run current file (<leader>xr)
|
||||||
run_selection = true, -- Run selected code (<leader>xs)
|
run_selection = true, -- Run selected code (<leader>xs)
|
||||||
run_function = true, -- Run function (<leader>xf)
|
run_function = true, -- Run function (<leader>xf)
|
||||||
venv = true, -- Environment management (<leader>xe)
|
venv = true, -- Environment management (<leader>xe)
|
||||||
init = true, -- Initialize uv project (<leader>xi)
|
init = true, -- Initialize uv project (<leader>xi)
|
||||||
add = true, -- Add a package (<leader>xa)
|
add = true, -- Add a package (<leader>xa)
|
||||||
remove = true, -- Remove a package (<leader>xd)
|
remove = true, -- Remove a package (<leader>xd)
|
||||||
sync = true, -- Sync packages (<leader>xc)
|
sync = true, -- Sync packages (<leader>xc)
|
||||||
sync_all = true, -- Sync all packages, extras and groups (<leader>xC)
|
sync_all = true, -- Sync all packages, extras and groups (<leader>xC)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
-- wakatime
|
-- wakatime
|
||||||
{ "wakatime/vim-wakatime", event = "VimEnter", lazy = false },
|
{ 'wakatime/vim-wakatime', event = 'VimEnter', lazy = false },
|
||||||
|
|
||||||
-- workflow
|
-- workflow
|
||||||
{
|
{
|
||||||
"m4xshen/hardtime.nvim",
|
'm4xshen/hardtime.nvim',
|
||||||
lazy = false,
|
lazy = false,
|
||||||
opts = {},
|
opts = {},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user