This commit is contained in:
punkfairie 2024-11-22 15:00:17 -08:00
parent 255ca9207a
commit 29ae2d441a
Signed by: punkfairie
GPG key ID: 8CEDBFDF5C0D613D
7 changed files with 100 additions and 9 deletions

View file

@ -2,7 +2,7 @@
...
}:
{
imports = [
./options.nix
];
imports = with builtins;
map (fn: ./${fn})
(filter (fn: fn != "default.nix") (attrNames (readDir ./.)));
}

View file

@ -1,4 +1,4 @@
{ ... }:
{ config, ... }:
{
globals = {
mapleader = " ";
@ -67,7 +67,12 @@
};
foldlevel = 99;
formatexpr = "v:lua.require'lazyvim.util'.format.formatexpr()";
formatexpr =
if config.plugins.conform.enable
then "v:lua.require'conform'.formatexpr()"
else "vim.lsp.formatexpr({ timeout_ms = 3000 })";
formatoptions = "jcroqlnt";
grepformat = "%f:%l:%c:%m";
grepprg = "rg --vimgrep";
@ -150,8 +155,6 @@
# Put new windows right of current
splitright = true;
statuscolumn = "%!v:lua.require'snacks.statuscolumn'.get()";
# Number of spaces tabs count for
tabstop = 2;
@ -189,12 +192,12 @@
if vim.fn.has("nvim-0.10") == 1 then
vim.opt.smoothscroll = true
vim.opt.foldexpr = "v:lua.require'lazyvim.util'.ui.foldexpr()"
vim.opt.foldexpr = "v:lua.require'lixyvim.util'.ui.foldexpr()"
vim.opt.foldmethod = "expr"
vim.opt.foldtext = ""
else
vim.opt.foldmethod = "indent"
vim.opt.foldtext = "v:lua.require'lazyvim.util'.ui.foldtext()"
vim.opt.foldtext = "v:lua.require'lixyvim.util'.ui.foldtext()"
end
'';
}

View file

@ -0,0 +1,6 @@
{ ... }:
{
imports = with builtins;
map (fn: ./${fn})
(filter (fn: fn != "default.nix") (attrNames (readDir ./.)));
}

View file

@ -0,0 +1,41 @@
{ ... }:
{
plugins.snacks = {
enable = true;
settings = {
bigfile.enabled = true;
notifier.enabled = true;
quickfile.enabled = true;
statuscolumn.enabled = false;
terminal.win.keys = let
mkKey = k: d: {
__unkeyed.1 = "<C-${k}>";
__unkeyed.2 = helpers.mkRaw #lua
''
function(self)
return self:is_floating() and "<c-${k}>" or vim.schedule(function()
vim.cmd.wincmd(${k})
end)
end
'';
desc = "Go to ${d} Window";
expr = true;
mode = "t";
};
in {
nav_h = mkKey "h" "Left";
nav_j = mkKey "j" "Lower";
nav_k = mkKey "k" "Upper";
nav_l = mkKey "l" "Right";
};
toggle.map = "";
words.enabled = true;
};
opts = {
statuscolumn = "%!v:lua.require'snacks.statuscolumn'.get()";
};
}

View file

@ -0,0 +1,6 @@
{ ... }:
{
imports = with builtins;
map (fn: ./${fn})
(filter (fn: fn != "default.nix") (attrNames (readDir ./.)));
}

8
config/util/default.nix Normal file
View file

@ -0,0 +1,8 @@
{
...
}:
{
extraFiles = {
"util/ui.lua".source = ./ui.lua;
};
}

27
config/util/ui.lua Normal file
View file

@ -0,0 +1,27 @@
--@class util.ui
local M = {}
-- foldtext for Neovim < 0.10.0
function M.foldtext()
return vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum, false)[1]
end
-- optimized treesitter foldexpr for Neovim >= 0.10.0
function M.foldexpr()
local buf = vim.api.nvim_get_current_buf()
if vim.b[buf].ts_folds == nil then
-- as long as we don't have a filetype, don't bother
-- checking if treesitter is available (it won't)
if vim.bo[buf].filetype == "" then
return "0"
end
if vim.bo[buf].filetype:find("dashboard") then
vim.b[buf].ts_folds = false
else
vim.b[buf].ts_folds = pcall(vim.treesitter.get_parser, buf)
end
end
return vim.b[buf].ts_folds and vim.treesitter.foldexpr() or "0"
end
return M