update my nvim config

This commit is contained in:
Hadi
2025-01-23 17:36:26 +01:00
parent 5cc7a65ea1
commit cd54511aa0
10 changed files with 385 additions and 203 deletions

View File

@@ -0,0 +1,187 @@
{
programs.nixvim = {
autoGroups = {
auto_quit.clear = true;
autoview.clear = true;
bufferline.clear = true;
checktime.clear = true;
create_dir.clear = true;
editorconfig_filetype.clear = true;
file_user_events.clear = true;
highlighturl.clear = true;
highlightyank.clear = true;
large_buf_settings.clear = true;
q_close_windows.clear = true;
terminal_settings.clear = true;
unlist_quickfix.clear = true;
};
autoCmd = [
# auto_quit
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L18-L46
{
desc =
"Quit neovim if more than one window is open and only sidebar windows are list";
event = "BufEnter";
group = "auto_quit";
callback.__raw = ''
function()
local wins = vim.api.nvim_tabpage_list_wins(0)
-- Both neo-tree and aerial will auto-quit if there is only a single window left
if #wins <= 1 then return end
local sidebar_fts = { aerial = true, ["neo-tree"] = true }
for _, winid in ipairs(wins) do
if vim.api.nvim_win_is_valid(winid) then
local bufnr = vim.api.nvim_win_get_buf(winid)
local filetype = vim.bo[bufnr].filetype
-- If any visible windows are not sidebars, early return
if not sidebar_fts[filetype] then
return
-- If the visible window is a sidebar
else
-- only count filetypes once, so remove a found sidebar from the detection
sidebar_fts[filetype] = nil
end
end
end
if #vim.api.nvim_list_tabpages() > 1 then
vim.cmd.tabclose()
else
vim.cmd.qall()
end
end
'';
}
# autoview
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L49-L70
{
desc = "Save view with mkview for real files";
event = [ "BufWinLeave" "BufWritePost" "WinLeave" ];
group = "autoview";
callback.__raw = ''
function(event)
if vim.b[event.buf].view_activated then vim.cmd.mkview { mods = { emsg_silent = true } } end
end
'';
}
{
desc =
"Try to load file view if available and enable view saving for real files";
event = "BufWinEnter";
group = "autoview";
callback.__raw = ''
function(event)
if not vim.b[event.buf].view_activated then
local filetype = vim.bo[event.buf].filetype
local buftype = vim.bo[event.buf].buftype
local ignore_filetypes = { "gitcommit", "gitrebase", "svg", "hgcommit" }
if buftype == "" and filetype and filetype ~= "" and not vim.tbl_contains(ignore_filetypes, filetype) then
vim.b[event.buf].view_activated = true
vim.cmd.loadview { mods = { emsg_silent = true } }
end
end
end
'';
}
# checktime
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L118-L122
{
desc = "Check if buffers changed on editor focus";
event = [ "FocusGained" "TermClose" "TermLeave" ];
group = "checktime";
command = "checktime";
}
# editorconfig_filetype
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L135-L144
{
desc =
"Configure editorconfig after filetype detection to override `ftplugin`s";
event = "FileType";
group = "editorconfig_filetype";
callback.__raw = ''
function(args)
if vim.F.if_nil(vim.b.editorconfig, vim.g.editorconfig, true) then
local editorconfig_avail, editorconfig = pcall(require, "editorconfig")
if editorconfig_avail then editorconfig.config(args.buf) end
end
end
'';
}
# highlightyank
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L206-L211
{
desc = "Highlight yanked text";
event = "TextYankPost";
group = "highlightyank";
pattern = "*";
callback.__raw = ''
function()
vim.highlight.on_yank()
end
'';
}
# q_close_windows
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L242-L255
{
desc = "Make q close help, man, quickfix, dap floats";
event = "BufWinEnter";
group = "q_close_windows";
callback.__raw = ''
function(event)
if vim.tbl_contains({ "help", "nofile", "quickfix" }, vim.bo[event.buf].buftype) then
vim.keymap.set("n", "q", "<Cmd>close<CR>", {
desc = "Close window",
buffer = event.buf,
silent = true,
nowait = true,
})
end
end
'';
}
# terminal_settings
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L258-L266
{
desc = "Disable line number/fold column/sign column for terminals";
event = "TermOpen";
group = "terminal_settings";
callback.__raw = ''
function()
vim.opt_local.number = false
vim.opt_local.relativenumber = false
vim.opt_local.foldcolumn = "0"
vim.opt_local.signcolumn = "no"
end
'';
}
# unlist_quickfix
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L270-L275
{
desc = "Unlist quickfix buffers";
event = "FileType";
group = "unlist_quickfix";
pattern = "qf";
callback.__raw = ''
function()
vim.opt_local.buflisted = false
end
'';
}
];
};
}

View File

@@ -2,19 +2,19 @@
{ inputs, ... }: {
imports = [
inputs.nixvim.homeManagerModules.nixvim
./plugins/cmp.nix
./plugins/dashboard.nix
./plugins/lsp.nix
./plugins/markdown.nix
./plugins/tree.nix
./plugins/ui.nix
./plugins/utils.nix
./plugins/dap.nix
./plugins/telescope.nix
./plugins/zenmode.nix
./plugins/cmp.nix
./plugins/ui.nix
./plugins/lualine.nix
./plugins/utils.nix
./plugins/dashboard.nix
./plugins/markdown.nix
./options.nix
./keymaps.nix
./autocmds.nix
];
programs.nixvim.enable = true;

View File

@@ -1,38 +1,151 @@
{
programs.nixvim.globals.mapleader = " ";
programs.nixvim.opts = {
updatetime = 50; # Faster completion
number = true;
relativenumber = true;
programs.nixvim = {
globals.mapleader = " ";
opts = {
autoindent = true;
clipboard = "unnamed,unnamedplus";
expandtab = true;
tabstop = 2;
softtabstop = 2;
shiftwidth = 2;
smartindent = true;
breakindent = true;
ignorecase = true;
incsearch = true;
hlsearch = true;
smartcase = true;
wildmode = "list:longest";
completeopt = [ "menuone" "noselect" "noinsert" ];
signcolumn = "yes";
cursorline = false;
scrolloff = 8;
mouse = "a";
termguicolors = true;
showmode = false;
wrap = false;
swapfile = false;
undofile = true;
conceallevel = 3;
clipboard = "unnamed,unnamedplus";
# Don't stop backspace at insert
backspace.__raw = ''
vim.list_extend(vim.opt.backspace:get(), { "nostop" })
'';
# Keep visual indentation on wrapped lines
breakindent = true;
# Hide command line unless needed
cmdheight = 0;
# Insert mode completion options
completeopt = [ "menu" "menuone" "noselect" ];
# Raise a dialog asking if you wish to save the current file(s)
confirm = true;
# Copy previous indentation on autoindenting
copyindent = true;
# Highlight current line
cursorline = true;
# Enable linematch diff algorithm
diffopt.__raw = ''
vim.list_extend(vim.opt.diffopt:get(), { "algorithm:histogram", "linematch:60" })
'';
# Expand <Tab> to spaces
expandtab = true;
# Disable `~` on nonexistent lines
fillchars = { eob = " "; };
# Enable fold with all code unfolded
foldcolumn = "1";
foldenable = true;
foldlevel = 99;
foldlevelstart = 99;
# Ignore case in search patterns
ignorecase = true;
# Show substitution preview in split window
inccommand = "split";
# Infer casing on word completion
infercase = true;
# Global statusline
laststatus = 3;
# Wrap lines at 'breakat'
linebreak = true;
# Enable mouse support
mouse = "a";
# Show line numbers
number = true;
# Preserve indentation as much as possible
preserveindent = true;
# Height of the popup menu
pumheight = 10;
# Display line numbers relative to current line
relativenumber = true;
# Minimal number of lines to keep around the cursor
# This has the effect to move the view along with current line
#scrolloff = 999;
# Number of spaces to use for indentation
shiftwidth = 2;
# Disable search count wrap and startup messages
shortmess.__raw = ''
vim.tbl_deep_extend("force", vim.opt.shortmess:get(), { s = true, I = true })
'';
# Disable showing modes in command line
showmode = false;
# Always show tabline
showtabline = 2;
# Show signs column
signcolumn = "yes";
# Override ignorecase if search pattern contains uppercase characters
smartcase = true;
# Number of spaces input on <Tab>
softtabstop = 2;
# Open horizontal split below (:split)
splitbelow = true;
# Open vertical split to the right (:vsplit)
splitright = true;
# Number of spaces to represent a <Tab>
tabstop = 2;
# Enables 24-bit RGB color
termguicolors = true;
# Shorter timeout duration
timeoutlen = 500;
# Set window title to the filename
title = true;
# Save undo history to undo file (in $XDG_STATE_HOME/nvim/undo)
undofile = true;
viewoptions.__raw = ''
vim.tbl_filter(function(val) return val ~= "curdir" end, vim.opt.viewoptions:get())
'';
# Enable virtual edit in visual block mode
# This has the effect of selecting empty cells beyond lines boundaries
virtualedit = "block";
# Disable line wrapping
wrap = false;
# Disable making a backup before overwriting a file
writebackup = false;
};
};
}

View File

@@ -112,6 +112,5 @@
};
};
};
};
}

View File

@@ -1,28 +0,0 @@
{ pkgs, ... }: {
programs.nixvim.plugins.dap = {
enable = true;
adapters = { };
signs = {
dapBreakpoint = {
text = "";
texthl = "DapBreakpoint";
};
dapBreakpointCondition = {
text = "";
texthl = "DapBreakpointCondition";
};
dapLogPoint = {
text = "";
texthl = "DapLogPoint";
};
};
extensions = {
dap-go = {
enable = true;
delve.path = "${pkgs.delve}/bin/dlv";
};
dap-ui = { enable = true; };
dap-virtual-text = { enable = true; };
};
};
}

View File

@@ -0,0 +1,30 @@
{
programs.nixvim.plugins.lualine = {
enable = true;
settings = {
options.disabled_filetypes.statusline =
[ "dashboard" "alpha" "neo-tree" ];
alwaysDivideMiddle = true;
globalstatus = true;
ignoreFocus = [ "neo-tree" ];
extensions = [ "fzf" ];
componentSeparators = {
left = "|";
right = "|";
};
sectionSeparators = {
left = ""; # 
right = ""; # 
};
sections = {
lualine_a = [ "mode" ];
lualine_b = [ "branch" "diff" "diagnostics" ];
lualine_c = [ "filename" ];
lualine_x = [ "filetype" ];
lualine_y = [ "progress" ];
lualine_z = [ ''" " .. os.date("%R")'' ];
};
};
};
}

View File

@@ -1,4 +1,3 @@
# The render-markdown.nvim plugin is a plugin that renders markdown files in a neovim in a more readable way.
{ config, ... }:
let
accent = "#${config.lib.stylix.colors.base0D}";
@@ -11,7 +10,6 @@ in {
plugins.mkdnflow = {
enable = true;
modules = { conceal = false; };
toDo.symbols = [ " " "-" "x" "!" "/" ];
mappings = {
MkdnCreateLink = false;
@@ -29,14 +27,17 @@ in {
modes = [ "v" ];
};
MkdnExtendList = false;
MkdnFoldSection = {
key = "<leader>mf";
modes = "n";
};
MkdnUnfoldSection = {
key = "<leader>mF";
modes = "n";
};
MkdnFollowLink = {
key = "gd";
modes = "n";
@@ -128,30 +129,16 @@ in {
RenderMarkdownH4.fg = accent-alt;
RenderMarkdownH5.fg = accent-alt;
RenderMarkdownH6.fg = accent-alt;
RenderMarkdownTodo.fg = muted;
RenderMarkdownWarning.fg = accent;
};
plugins.headlines = {
enable = true;
settings = {
markdown = {
headline_highlights = [
"RenderMarkdownH1"
"RenderMarkdownH2"
"RenderMarkdownH3"
"RenderMarkdownH4"
"RenderMarkdownH5"
"RenderMarkdownH6"
];
fat_headlines = false;
};
};
RenderMarkdownTodo.fg = "#f78c6c";
RenderMarkdownWarning.fg = "#ff5370";
RenderMarkdownDone.fg = muted;
};
plugins.render-markdown = {
enable = true;
settings = {
heading = {
icons = [ "# " "󰲣 " "󰲥 " "󰲧 " "󰲩 " "󰲫 " ];
sign = false;
backgrounds = [ "RenderMarkdownBg" ];
foregrounds = [
"RenderMarkdownH1"
@@ -164,22 +151,22 @@ in {
};
checkbox = {
unchecked = { highlight = "RenderMarkdownTodo"; };
checked = { highlight = "RenderMarkdownTodo"; };
checked = { highlight = "RenderMarkdownDone"; };
custom = {
pending = {
raw = "[-]";
rendered = "󰥔 ";
rendered = " ";
highlight = "RenderMarkdownTodo";
};
important = {
raw = "[!]";
rendered = " ";
rendered = "󰰱 ";
highlight = "RenderMarkdownWarning";
};
cancel = {
raw = "[/]";
rendered = "󱋬 ";
highlight = "RenderMarkdownTodo";
highlight = "RenderMarkdownWarning";
};
};
};

View File

@@ -1,54 +1,14 @@
{ pkgs, ... }: {
home.packages = with pkgs; [ ctags ];
programs.nixvim = {
plugins = {
lualine = {
enable = true;
settings = {
options.disabled_filetypes.statusline =
[ "dashboard" "alpha" "neo-tree" ];
alwaysDivideMiddle = true;
globalstatus = true;
ignoreFocus = [ "neo-tree" ];
extensions = [ "fzf" ];
theme = "auto";
componentSeparators = {
left = "|";
right = "|";
};
sectionSeparators = {
left = ""; # 
right = ""; # 
};
sections = {
lualine_a = [ "mode" ];
lualine_b = [ "branch" "diff" "diagnostics" ];
lualine_c = [ "filename" ];
lualine_x = [ "filetype" ];
lualine_y = [ "progress" ];
lualine_z = [ ''" " .. os.date("%R")'' ];
};
};
};
programs.nixvim.plugins = {
web-devicons.enable = true;
noice.enable = true;
notify = {
enable = true;
level = "warn";
};
gitsigns = {
enable = true;
settings.current_line_blame = false;
};
trouble.enable = true;
indent-blankline.enable = true;
colorizer.enable = true;
tagbar = {
enable = true;
tagsPackage = pkgs.universal-ctags;
};
};
bufferline.enable = true;
};
}

View File

@@ -17,34 +17,14 @@
tmux-navigator.enable = true;
comment.enable = true;
nvim-autopairs.enable = true;
friendly-snippets.enable = true;
todo-comments.enable = true;
treesitter = {
enable = true;
nixGrammars = true;
settings = {
ensure_installed = "all";
incremental_selection.enable = true;
indent.enable = true;
highlight.enable = true;
highlight.additional_vim_regex_highlighting = true;
};
};
harpoon = {
enable = true;
enableTelescope = true;
keymapsSilent = true;
keymaps = {
addFile = "<leader>ha";
toggleQuickMenu = "<leader>hu";
navNext = "<leader>hl";
navPrev = "<leader>hh";
navFile = {
"1" = "<leader>h1";
"2" = "<leader>h2";
"3" = "<leader>h3";
"4" = "<leader>h4";
};
};
};
};

View File

@@ -1,46 +0,0 @@
{
programs.nixvim.plugins = {
zen-mode = {
enable = true;
settings = {
on_close = ''
function()
require("gitsigns.actions").toggle_current_line_blame()
vim.cmd('IBLEnable')
vim.opt.signcolumn = "yes:2"
vim.wo.wrap = false
vim.wo.linebreak = false
require("gitsigns.actions").refresh()
end
'';
on_open = ''
function()
require("gitsigns.actions").toggle_current_line_blame()
vim.cmd('IBLDisable')
vim.opt.relativenumber = false
vim.opt.signcolumn = "no"
vim.wo.wrap = true
vim.wo.linebreak = true
require("gitsigns.actions").refresh()
end
'';
window = {
backdrop = 1;
height = 1;
options = {
signcolumn = "no";
number = false;
relativenumber = false;
cursorline = false;
cursorcolumn = false;
foldcolumn = "0";
list = false;
};
width = 0.8;
};
};
};
};
}