1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

6 Commits

Author SHA1 Message Date
jdhao
52426e0ce8 Remove config for neoformat 2025-06-08 00:18:43 +02:00
jdhao
ae5e7c5bb4 Add plugin neogit 2025-06-08 00:14:32 +02:00
jdhao
6e6a09e32f Add support for markdown ref-style link (#415) 2025-06-07 19:12:01 +02:00
jdhao
88044b252e add new colorscheme citruszest (#414) 2025-06-05 00:51:10 +02:00
jdhao
448f2394fe Add new bunch of colorschemes (#413) 2025-06-03 13:22:02 +02:00
jdhao
6c10223062 change kanagawa theme variant 2025-06-03 12:36:50 +02:00
5 changed files with 163 additions and 15 deletions

107
after/ftplugin/markdown.lua Normal file
View File

@@ -0,0 +1,107 @@
local function add_reference_at_end(label, url, title)
vim.schedule(function()
local bufnr = vim.api.nvim_get_current_buf()
local line_count = vim.api.nvim_buf_line_count(bufnr)
-- Prepare reference definition
local ref_def = "[" .. label .. "]: " .. url
if title and title ~= "" then
ref_def = ref_def .. ' "' .. title .. '"'
end
-- Check if references section exists
local buffer_lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
local has_ref_section = false
for _, line in ipairs(buffer_lines) do
if line:match("^%s*<!%-%-.*[Rr]eferences.*%-%->[%s]*$") then
has_ref_section = true
break
end
end
local lines_to_add = {}
-- Add references header if it doesn't exist
if not has_ref_section then
if #lines_to_add == 0 then
table.insert(lines_to_add, "")
end
table.insert(lines_to_add, "<!-- References -->")
end
table.insert(lines_to_add, ref_def)
-- Insert at buffer end
vim.api.nvim_buf_set_lines(bufnr, line_count, line_count, false, lines_to_add)
end)
end
local function get_ref_link_labels()
local labels = {}
local seen = {} -- To avoid duplicates
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
for _, line in ipairs(lines) do
-- Pattern explanation:
-- %[.-%] matches [link text] (non-greedy)
-- %[(.-)%] matches [label] and captures the label content
local start_pos = 1
while start_pos <= #line do
local match_start, match_end, label = string.find(line, "%[.-%]%[(.-)%]", start_pos)
if not match_start then
break
end
-- Only add unique labels
if label and label ~= "" and not seen[label] then
table.insert(labels, label)
seen[label] = true
end
start_pos = match_end + 1
end
end
return labels
end
local function count_consecutive_spaces(str)
-- Remove leading spaces first
local trimmed = str:match("^%s*(.*)")
local count = 0
-- Count each sequence of one or more consecutive spaces
for spaces in trimmed:gmatch("%s+") do
count = count + 1
end
return count
end
vim.api.nvim_buf_create_user_command(0, "AddRef", function(opts)
local args = vim.split(opts.args, " ", { trimempty = true })
if #args < 2 then
vim.print("Usage: :AddRef <label> <url>")
return
end
local label = args[1]
local url = args[2]
add_reference_at_end(label, url, "")
end, {
desc = "Add reference link at buffer end",
nargs = "+",
complete = function(arg_lead, cmdline, curpos)
vim.print(string.format("arg_lead: '%s', cmdline: '%s', curpos: %d", arg_lead, cmdline, curpos))
-- only complete the first argument
if count_consecutive_spaces(cmdline) > 1 then
-- we are now starting the second argument, so no completion anymore
return {}
end
local ref_link_labels = get_ref_link_labels()
return ref_link_labels
end,
})

View File

@@ -59,7 +59,38 @@ M.colorscheme_conf = {
vim.cmd("colorscheme arctic") vim.cmd("colorscheme arctic")
end, end,
kanagawa = function() kanagawa = function()
vim.cmd("colorscheme kanagawa-wave") vim.cmd("colorscheme kanagawa-dragon")
end,
modus = function()
vim.cmd([[colorscheme modus]])
end,
jellybeans = function()
vim.cmd([[colorscheme jellybeans]])
end,
github = function()
vim.cmd([[colorscheme github_dark_default]])
end,
e_ink = function()
require("e-ink").setup()
vim.cmd.colorscheme("e-ink")
end,
ashen = function()
vim.cmd([[colorscheme ashen]])
end,
melange = function()
vim.cmd([[colorscheme melange]])
end,
makurai = function()
vim.cmd.colorscheme("makurai_warrior")
end,
vague = function()
vim.cmd([[colorscheme vague]])
end,
kanso = function()
vim.cmd([[colorscheme kanso]])
end,
citruszest = function()
vim.cmd([[colorscheme citruszest]])
end, end,
} }

View File

@@ -199,6 +199,16 @@ local plugin_specs = {
branch = "v2", branch = "v2",
}, },
{ "rebelot/kanagawa.nvim", lazy = true }, { "rebelot/kanagawa.nvim", lazy = true },
{ "miikanissi/modus-themes.nvim", priority = 1000 },
{ "wtfox/jellybeans.nvim", priority = 1000 },
{ "projekt0n/github-nvim-theme", name = "github-theme" },
{ "e-ink-colorscheme/e-ink.nvim", priority = 1000 },
{ "ficcdaf/ashen.nvim", priority = 1000 },
{ "savq/melange-nvim", priority = 1000 },
{ "Skardyy/makurai-nvim", priority = 1000 },
{ "vague2k/vague.nvim", priority = 1000 },
{ "webhooked/kanso.nvim", priority = 1000 },
{ "zootedb0t/citruszest.nvim", priority = 1000 },
-- plugins to provide nerdfont icons -- plugins to provide nerdfont icons
{ {
@@ -386,6 +396,16 @@ local plugin_specs = {
require("config.fugitive") require("config.fugitive")
end, end,
}, },
{
"NeogitOrg/neogit",
dependencies = {
"nvim-lua/plenary.nvim", -- required
"sindrets/diffview.nvim", -- optional - Diff integration
-- Only one of these is needed.
"ibhagwan/fzf-lua", -- optional
},
event = "User InGitRepo",
},
-- Better git log display -- Better git log display
{ "rbong/vim-flog", cmd = { "Flog" } }, { "rbong/vim-flog", cmd = { "Flog" } },

View File

@@ -54,6 +54,10 @@ snippet link "Markdown links"
[$1]($2)$0 [$1]($2)$0
endsnippet endsnippet
snippet rlink "Markdown ref link"
[${1:link_text}][${2:label}]
endsnippet
post_jump "gen_header(snip)" post_jump "gen_header(snip)"
snippet "h([1-6])" "Markdown header" br snippet "h([1-6])" "Markdown header" br
`!p snip.rv = match.group(1)` `!p snip.rv = match.group(1)`

View File

@@ -58,20 +58,6 @@ let g:better_escape_interval = 200
""""""""""""""""""""""""""""vim-xkbswitch settings""""""""""""""""""""""""" """"""""""""""""""""""""""""vim-xkbswitch settings"""""""""""""""""""""""""
let g:XkbSwitchEnabled = 1 let g:XkbSwitchEnabled = 1
"""""""""""""""""""""""""""""" neoformat settings """""""""""""""""""""""
let g:neoformat_enabled_python = ['black', 'yapf']
let g:neoformat_cpp_clangformat = {
\ 'exe': 'clang-format',
\ 'args': ['--style="{IndentWidth: 4}"']
\ }
let g:neoformat_c_clangformat = {
\ 'exe': 'clang-format',
\ 'args': ['--style="{IndentWidth: 4}"']
\ }
let g:neoformat_enabled_cpp = ['clangformat']
let g:neoformat_enabled_c = ['clangformat']
"""""""""""""""""""""""""markdown-preview settings""""""""""""""""""" """""""""""""""""""""""""markdown-preview settings"""""""""""""""""""
" Only setting this for suitable platforms " Only setting this for suitable platforms
if g:is_win || g:is_mac if g:is_win || g:is_mac