|
|
@ -1,18 +1,20 @@ |
|
|
|
vim.api.nvim_set_hl(0, "YankColor", { fg = "#C8C093", bg = "#000000", ctermfg = 59, ctermbg = 41 }) |
|
|
|
|
|
|
|
local aucmd_dict = { |
|
|
|
VimEnter = { |
|
|
|
{ |
|
|
|
callback = function() |
|
|
|
local function find_project_root() |
|
|
|
local current_dir = vim.fn.getcwd() |
|
|
|
local current_dir = vim.fn.getcwd() |
|
|
|
|
|
|
|
while current_dir ~= "/" do |
|
|
|
if vim.fn.isdirectory(current_dir .. "/.git") == 1 or vim.fn.filereadable(current_dir .. "/.nvim.lua") then |
|
|
|
return current_dir |
|
|
|
while current_dir ~= "/" do |
|
|
|
if vim.fn.isdirectory(current_dir .. "/.git") == 1 or vim.fn.filereadable(current_dir .. "/.nvim.lua") then |
|
|
|
return current_dir |
|
|
|
end |
|
|
|
current_dir = vim.fn.fnamemodify(current_dir, ":h") |
|
|
|
end |
|
|
|
current_dir = vim.fn.fnamemodify(current_dir, ":h") |
|
|
|
end |
|
|
|
|
|
|
|
return vim.fn.getcwd() |
|
|
|
return vim.fn.getcwd() |
|
|
|
end |
|
|
|
|
|
|
|
local project_root = find_project_root() |
|
|
@ -21,14 +23,14 @@ local aucmd_dict = { |
|
|
|
if vim.fn.filereadable(project_specific_conf_file) == 1 then |
|
|
|
vim.cmd("source " .. project_specific_conf_file) |
|
|
|
print("Sourced project specific config file: " .. project_specific_conf_file) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
FileType = { |
|
|
|
{ |
|
|
|
-- Set tabstop to 2 for Dart, Vue, JavaScript, TypeScript, and JSON files |
|
|
|
-- Set tabstop to 2 for Dart, Vue, JavaScript, TypeScript, and JSON files |
|
|
|
pattern = "html,dart,vue,javascript,typescript,typescriptreact,json,markdown,css,sass", |
|
|
|
callback = function() |
|
|
|
vim.opt_local.tabstop = 2 |
|
|
@ -38,7 +40,7 @@ local aucmd_dict = { |
|
|
|
}, |
|
|
|
{ |
|
|
|
pattern = 'dart', |
|
|
|
callback = function () |
|
|
|
callback = function() |
|
|
|
vim.bo.commentstring = '// %s' |
|
|
|
end |
|
|
|
}, |
|
|
@ -61,6 +63,27 @@ local aucmd_dict = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
BufReadPost = { |
|
|
|
{ |
|
|
|
callback = function(event) |
|
|
|
local exclude = { 'gitcommit', 'commit', 'gitrebase' } |
|
|
|
local buf = event.buf |
|
|
|
if |
|
|
|
vim.tbl_contains(exclude, vim.bo[buf].filetype) |
|
|
|
or vim.b[buf].lazyvim_last_loc |
|
|
|
then |
|
|
|
return |
|
|
|
end |
|
|
|
vim.b[buf].lazyvim_last_loc = true |
|
|
|
local mark = vim.api.nvim_buf_get_mark(buf, '"') |
|
|
|
local lcount = vim.api.nvim_buf_line_count(buf) |
|
|
|
if mark[1] > 0 and mark[1] <= lcount then |
|
|
|
pcall(vim.api.nvim_win_set_cursor, 0, mark) |
|
|
|
end |
|
|
|
end, |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
BufNewFile = { |
|
|
|
{ |
|
|
|
-- Set syntax for Dockerfiles |
|
|
@ -70,6 +93,20 @@ local aucmd_dict = { |
|
|
|
end |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
TextYankPost = { |
|
|
|
{ |
|
|
|
callback = function() |
|
|
|
vim.hl.on_yank { higroup = "YankColor", timeout = 250 } |
|
|
|
end |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
VimResized = { |
|
|
|
{ |
|
|
|
command="wincmd =" |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
for event, opt_tbls in pairs(aucmd_dict) do |
|
|
@ -77,4 +114,3 @@ for event, opt_tbls in pairs(aucmd_dict) do |
|
|
|
vim.api.nvim_create_autocmd(event, opt_tbl) |
|
|
|
end |
|
|
|
end |
|
|
|
|