Compare commits

..

1 commit

Author SHA1 Message Date
cd5582af85
WIP 2024-11-25 22:11:42 -08:00
5 changed files with 137 additions and 150 deletions

View file

@ -23,43 +23,51 @@ in {
]; ];
autoCmd = [ autoCmd = [
(autocmds.mk' ["FocusGained" "TermClose" "TermLeave"] "checktime" (mkRaw '' (autocmds.mk' ["FocusGained" "TermClose" "TermLeave"] "checktime" (mkRaw
function() # lua
if vim.o.buftype ~= "nofile" then ''
vim.cmd("checktime") function()
if vim.o.buftype ~= "nofile" then
vim.cmd("checktime")
end
end end
end '') "Check if file needs to be reloaded when changed")
'') "Check if file needs to be reloaded when changed")
(autocmds.mk' ["TextYankPost"] "highlight_yank" (mkRaw '' (autocmds.mk' ["TextYankPost"] "highlight_yank" (mkRaw
function() # lua
(vim.hl or vim.highlight).on_yank() ''
end function()
'') "Highlight on yank") (vim.hl or vim.highlight).on_yank()
(autocmds.mk' ["VimResized"] "resize_splits" (mkRaw ''
function()
local current_tab = vim.fn.tabpagenr()
vim.cmd("tabdo wincmd =")
vim.cmd("tabnext " .. current_tab)
end
'') "Resize splits on window resize")
(autocmds.mk' ["BufReadPost"] "last_loc" (mkRaw ''
function(event)
local exclude = { "gitcommit" }
local buf = event.buf
if vim.tbl_contains(exclude, vim.bo[buf].filetype) or vim.b[buf].marleyvim_last_loc then
return
end end
vim.b[buf].marleyvim_last_loc = true '') "Highlight on yank")
local mark = vim.api.nvim_buf_get_mark(buf, '"')
local lcount = vim.api.nvim_buf_line_count(buf) (autocmds.mk' ["VimResized"] "resize_splits" (mkRaw
if mark[1] > 0 and mark[1] <= lcount then # lua
pcall(vim.api.nvim_win_set_cursor, 0, mark) ''
function()
local current_tab = vim.fn.tabpagenr()
vim.cmd("tabdo wincmd =")
vim.cmd("tabnext " .. current_tab)
end end
end '') "Resize splits on window resize")
'') "Go to last location when opening a buffer")
(autocmds.mk' ["BufReadPost"] "last_loc" (mkRaw
# lua
''
function(event)
local exclude = { "gitcommit" }
local buf = event.buf
if vim.tbl_contains(exclude, vim.bo[buf].filetype) or vim.b[buf].marleyvim_last_loc then
return
end
vim.b[buf].marleyvim_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
'') "Go to last location when opening a buffer")
(autocmds.mk ["FileType"] "close_with_q" [ (autocmds.mk ["FileType"] "close_with_q" [
"PlenaryTestPopup" "PlenaryTestPopup"
@ -78,27 +86,31 @@ in {
"spectre_panel" "spectre_panel"
"startuptime" "startuptime"
"tsplayground" "tsplayground"
] (mkRaw '' ] (mkRaw
# lua
''
function(event)
vim.bo[event.buf].buflisted = false
vim.schedule(function()
vim.keymap.set("n", "q", function()
vim.cmd("close")
pcall(vim.api.nvim_buf_delete, event.buf, { force = true })
end, {
buffer = event.buf,
silent = true,
desc = "Quit buffer",
})
end)
end
'') "Close some filetypes with <q>")
(autocmds.mk ["FileType"] "man_unlisted" ["man"] (mkRaw
# lua
''
function(event) function(event)
vim.bo[event.buf].buflisted = false vim.bo[event.buf].buflisted = false
vim.schedule(function()
vim.keymap.set("n", "q", function()
vim.cmd("close")
pcall(vim.api.nvim_buf_delete, event.buf, { force = true })
end, {
buffer = event.buf,
silent = true,
desc = "Quit buffer",
})
end)
end end
'') "Close some filetypes with <q>") '') "Easy-close man files")
(autocmds.mk ["FileType"] "man_unlisted" ["man"] (mkRaw ''
function(event)
vim.bo[event.buf].buflisted = false
end
'') "Easy-close man files")
(autocmds.mk ["FileType"] "wrap_spell" [ (autocmds.mk ["FileType"] "wrap_spell" [
"text" "text"
@ -106,27 +118,33 @@ in {
"typst" "typst"
"gitcommit" "gitcommit"
"markdown" "markdown"
] (mkRaw '' ] (mkRaw
# lua
''
function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end
'') "Wrap & check spelling in text files")
(autocmds.mk ["FileType"] "json_conceal" ["json" "jsonc" "json5"] (mkRaw
# lua
''
function() function()
vim.opt_local.wrap = true vim.opt_local.conceallevel = 0
vim.opt_local.spell = true
end end
'') "Wrap & check spelling in text files") '') "Fix conceallevel for json files")
(autocmds.mk ["FileType"] "json_conceal" ["json" "jsonc" "json5"] (mkRaw '' (autocmds.mk' ["BufWritePre"] "auto_create_dir" (mkRaw
function() # lua
vim.opt_local.conceallevel = 0 ''
end function(event)
'') "Fix conceallevel for json files") if event.match:match("^%w%w+:[\\/][\\/]") then
return
(autocmds.mk' ["BufWritePre"] "auto_create_dir" (mkRaw '' end
function(event) local file = vim.uv.fs_realpath(event.match) or event.match
if event.match:match("^%w%w+:[\\/][\\/]") then vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
return
end end
local file = vim.uv.fs_realpath(event.match) or event.match '') "Auto create missing parent dirs when saving")
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
end
'') "Auto create missing parent dirs when saving")
]; ];
} }

View file

@ -165,9 +165,9 @@ in {
# Diagnostics - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Diagnostics - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++ [ ++ [
(keys.mk ["n"] "<LEADER>cd" ( (keys.mk ["n"] "<LEADER>cd" (
mkRaw '' mkRaw
function() vim.diagnostic.open_float() end # lua
'' "function() vim.diagnostic.open_float() end"
) "Line Diagnostics") ) "Line Diagnostics")
] ]
++ ( ++ (
@ -200,11 +200,13 @@ in {
cmd = toLower dir; cmd = toLower dir;
sev = sevs."${key}".key; sev = sevs."${key}".key;
in in
keys.mk ["n"] kmap ( keys.mk ["n"] kmap
mkRaw '' (
function() vim.diagnostic.goto_${cmd}({ severity = ${sev} }) end mkRaw
'' # lua
) "${dir} ${sevs."${key}".desc}" "function() vim.diagnostic.goto_${cmd}({ severity = ${sev} }) end"
)
"${dir} ${sevs."${key}".desc}"
) )
{ {
dir = ["Next" "Prev"]; dir = ["Next" "Prev"];

View file

@ -3,20 +3,27 @@
helpers, helpers,
... ...
}: let }: let
inherit (lib) flatten mapAttrsToList map;
inherit (lib.marleyvim) icons keys autocmds;
inherit (helpers) mkRaw; inherit (helpers) mkRaw;
inherit (lib) flatten mapAttrsToList map;
inherit (lib.marleyvim) icons keys;
in { in {
plugins.bufferline = { plugins.bufferline = {
enable = true; enable = true;
settings = { settings = {
options = { options = {
close_command.__raw = "function(n) Snacks.bufdelete(n) end"; close_command =
right_mouse_command.__raw = "function(n) Snacks.bufdelete(n) end"; mkRaw
# lua
"function(n) Snacks.bufdelete(n) end";
right_mouse_command =
mkRaw
# lua
"function(n) Snacks.bufdelete(n) end";
diagnostics = "nvim_lsp"; diagnostics = "nvim_lsp";
diagnostics_indicator.__raw = diagnostics_indicator =
mkRaw
# lua # lua
'' ''
function(_, _, diag) function(_, _, diag)
@ -25,42 +32,10 @@ in {
return vim.trim(ret) return vim.trim(ret)
end end
''; '';
always_show_bufferline = true;
offsets = [
{
filetype = "neo-tree";
text = "Explorer";
highlight = "Directory";
text_align = "left";
}
];
get_element_icon.__raw = ''
function(elem)
local icon, hl, _ =
require('mini.icons').get('filetype', elem.filetype)
return icon, hl
end
'';
}; };
}; };
}; };
autoGroups.marleyos_bufferline.clear = true;
autoCmd = [
(autocmds.mk' ["BufAdd" "BufDelete"] "bufferline" (
mkRaw ''
function()
vim.schedule(function()
pcall(nvim_bufferline)
end)
end
''
) "Fix bufferline when restoring a session")
];
keymaps = keymaps =
[ [
(keys.mk ["n"] "<LEADER>bp" "<CMD>BufferLineTogglePin<CR>" "Toggle Pin") (keys.mk ["n"] "<LEADER>bp" "<CMD>BufferLineTogglePin<CR>" "Toggle Pin")

View file

@ -1,8 +0,0 @@
_: {
plugins.mini = {
enable = true;
mockDevIcons = true;
modules.icons = {};
};
}

View file

@ -23,62 +23,62 @@ in {
keymaps = [ keymaps = [
(keys.mk ["n"] "<LEADER>un" ( (keys.mk ["n"] "<LEADER>un" (
mkRaw '' mkRaw
function() Snacks.notifier.hide() end # lua
'' "function() Snacks.notifier.hide() end"
) "Dismiss All Notifications") ) "Dismiss All Notifications")
(keys.mk ["n"] "<LEADER>bd" ( (keys.mk ["n"] "<LEADER>bd" (
mkRaw '' mkRaw
function() Snacks.bufdelete() end # lua
'' "function() Snacks.bufdelete() end"
) "Delete Buffer") ) "Delete Buffer")
(keys.mk ["n"] "<LEADER>bo" ( (keys.mk ["n"] "<LEADER>bo" (
mkRaw '' mkRaw
function() Snacks.bufdelete.other() end # lua
'' "function() Snacks.bufdelete.other() end"
) "Delete Other Buffers") ) "Delete Other Buffers")
# LazyGit - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # LazyGit - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(keys.mk ["n"] "<LEADER>gg" ( (keys.mk ["n"] "<LEADER>gg" (
mkRaw '' mkRaw
function() Snacks.lazygit() end # lua
'' "function() Snacks.lazygit() end"
) "Lazygit") ) "Lazygit")
(keys.mk ["n"] "<LEADER>gf" ( (keys.mk ["n"] "<LEADER>gf" (
mkRaw '' mkRaw
function() Snacks.lazygit.log_file() end # lua
'' "function() Snacks.lazygit.log_file() end"
) "Lazygit Current File History") ) "Lazygit Current File History")
(keys.mk ["n"] "<LEADER>gl" ( (keys.mk ["n"] "<LEADER>gl" (
mkRaw '' mkRaw
function() Snacks.lazygit.log() end # lua
'' "function() Snacks.lazygit.log() end"
) "Lazygit Log") ) "Lazygit Log")
# Git - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Git - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(keys.mk ["n"] "<LEADER>gb" ( (keys.mk ["n"] "<LEADER>gb" (
mkRaw '' mkRaw
function() Snacks.git.blame_line() end # lua
'' "function() Snacks.git.blame_line() end"
) "Git Blame Line") ) "Git Blame Line")
(keys.mk ["n" "x"] "<LEADER>gB" ( (keys.mk ["n" "x"] "<LEADER>gB" (
mkRaw '' mkRaw
function() Snacks.gitbrowse() end # lua
'' "function() Snacks.gitbrowse() end"
) "Git Browse (open)") ) "Git Browse (open)")
(keys.mk ["n" "x"] "<LEADER>gY" ( (keys.mk ["n" "x"] "<LEADER>gY" (mkRaw
mkRaw '' # lua
''
function() function()
Snacks.gitbrowse({ open = function(url) vim.fn.setreg("+", url) end }) Snacks.gitbrowse({ open = function(url) vim.fn.setreg("+", url) end })
end end
'' '') "Git Browse (copy)")
) "Git Browse (copy)")
]; ];
# Toggles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Toggles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -