feat: effectively finish nvf as ide #10

This commit is contained in:
Mohammad Rafiq 2025-03-13 23:51:47 +08:00
parent ab4113b74d
commit 3f82161bae
16 changed files with 564 additions and 53 deletions

View file

@ -7,9 +7,18 @@
nerd-fonts.terminess-ttf
];
stylix.fonts = {
serif = config.stylix.fonts.monospace;
sansSerif = config.stylix.fonts.monospace;
emoji = config.stylix.fonts.monospace;
serif = {
package = pkgs.nerd-fonts.terminess-ttf;
name = "Terminess Nerd Font";
};
sansSerif = {
package = pkgs.nerd-fonts.terminess-ttf;
name = "Terminess Nerd Font";
};
emoji = {
package = pkgs.nerd-fonts.terminess-ttf;
name = "Terminess Nerd Font";
};
monospace = {
package = pkgs.nerd-fonts.terminess-ttf;
name = "Terminess Nerd Font Mono";

View file

@ -1,58 +1,26 @@
{inputs, ...}: {
imports = [
inputs.nvf.homeManagerModules.default
./nvf/blink-cmp.nix
./nvf/conform-nvim.nix
./nvf/languages/nix.nix
./nvf/lualine.nix
./nvf/noice.nix
./nvf/options.nix
./nvf/keymaps.nix
./nvf/lsp.nix
./nvf/debugger.nix
./nvf/languages.nix
./nvf/visual.nix
./nvf/input.nix
./nvf/filetree.nix
./nvf/search.nix
./nvf/utilities.nix
./nvf/notes.nix
];
home.sessionVariables.EDITOR = "nvim";
programs.nvf = {
enable = true;
enableManpages = true;
settings.vim = {
options = {
# Indentation
autoindent = true;
smartindent = true;
expandtab = true;
smarttab = true;
wrap = false;
shiftwidth = 2;
tabstop = 2;
foldlevel = 1000; # Open all folds by default
# Search
hlsearch = true;
ignorecase = true;
incsearch = true;
smartcase = true; # case-sensitive if search contains uppercase
# Visual
number = true;
relativenumber = true;
cursorline = true;
visualbell = true;
termguicolors = true;
# Input
backspace = "indent,eol,start";
};
keymaps = [
{
key = "gf";
mode = "n";
action = ":cd %:p:h<CR>:e <cfile><CR>";
silent = true;
}
];
languages = {
enableFormat = true;
enableLSP = true;
enableTreesitter = true;
};
viAlias = true;
vimAlias = true;
spellcheck.enable = true;
};
};
}

View file

@ -0,0 +1,32 @@
{
programs.nvf.settings.vim.debugger.nvim-dap = {
# nvim-dap enables debugging
# you can set breakpoints and step through code or use a REPL
enable = true;
mappings = {
# default mappings:
# - Continue:<leader>dc
# - Go down stacktrace:<leader>dvi
# - Go up stacktrace:<leader>dvo
# - Hover:<leader>dh
# - Restart:<leader>dR
# - Re-run Last Debug Session:<leader>d.
# - Continue to the current cursor:<leader>dgc
# - Step back:<leader>dgk
# - Step into function:<leader>dgi
# - Step out of function:<leader>dgo
# - Next step:<leader>dgj
# - Terminate:<leader>dq
# - Toggle breakpoint:<leader>db
# - Toggle DAP-UI:<leader>du
# - Toggle Repl:<leader>dr
};
# list of debuggers to install
sources = {};
# install nvim-dap-ui which provides a debugging ui
ui = {
enable = true;
setupOpts = {};
};
};
}

View file

@ -0,0 +1,17 @@
{
programs.nvf.settings.vim.filetree = {
# press ? in the tree view for a list of keybindings
# < and > to switch sources
# backspace to go up one level
neo-tree = {
enable = true;
setupOpts = {
enable_cursor_hijack = true; # keep the cursor on the first char
};
};
# TODO: add keymap for :NeoTree action=show position=right toggle=true reveal=true
# action=show is to not focus the window
# toggle will toggle the window
# reveal will find and focus the current file
};
}

View file

@ -0,0 +1,2 @@
{
}

View file

@ -0,0 +1,44 @@
{
programs.nvf.settings.vim = {
autopairs = {
nvim-autopairs.enable = true;
};
autocomplete = {
enableSharedCmpSources = true;
blink-cmp = {
enable = true;
friendly-snippets.enable = true;
mappings = {
# default mappings:
# - Close [blink.cmp]:<C-e>
# - Complete [blink.cmp]:<C-Space>
# - Confirm [blink.cmp]:<CR>
# - Next item [blink.cmp]:<Tab>
# - Previous item [blink.cmp]:<S-Tab>
# - Scroll docs down [blink.cmp]:<C-f>
# - Scroll docs up [blink.cmp]:<C-d>
};
setupOpts = {
cmdline.sources = null; # use default source list
completion.documentation.auto_show_delay_ms = 0;
signature.enabled = true;
};
};
nvim-cmp = {};
};
# enable code snippets using luasnip
# loads from vscode by default using friendly-snippets
snippets.luasnip = {
enable = true;
setupOpts = {
enable_autosnippets = true;
};
};
binds = {
# cheatsheet.nvim provides cheatsheets with fuzzy finding with <leader>?
cheatsheet.enable = true;
# whichkey provides a popup window with hotkeys
whichKey.enable = true;
};
};
}

View file

@ -0,0 +1,10 @@
{
programs.nvf.settings.vim.keymaps = [
{
key = "gf";
mode = "n";
action = ":cd %:p:h<CR>:e <cfile><CR>";
silent = true;
}
];
}

View file

@ -0,0 +1,13 @@
{
programs.nvf.settings.vim.languages = {
# The below settings enable defaults for all languages
enableDAP = true;
enableExtraDiagnostics = true;
enableFormat = true;
enableLSP = true;
enableTreesitter = true;
# Enable specific languages
nix.enable = true;
};
}

View file

@ -1,8 +1,13 @@
{
{pkgs, ...}: {
home.packages = [pkgs.nixd];
programs.nvf.settings.vim.languages.nix = {
enable = true;
lsp = {
server = "nixd";
};
# lsp = {
# server = "nixd";
# options = {
# nixpkgs.expr = ''(builtins.getFlake ("git+file://" + toString ./.)).inputs.nixpkgs'';
# options.nixos.expr = ''(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.${builtins.getEnv "HOSTNAME"}.options'';
# };
# };
};
}

View file

@ -0,0 +1,119 @@
{
programs.nvf.settings.vim.lsp = {
# enable is automatically set by null-ls and lspconfig options
# enable = true;
formatOnSave = true;
# lightbulb shows a lightbulb when code actions are available
# TODO: Look into code actions and how to enable them with telescope
lightbulb = {
enable = true;
setupOpts = {};
};
# ls-signature shows a small signature for functions etc
# TODO: Look into configuring this
# does not work with blink cmp
lspSignature = {
enable = false;
setupOpts = {};
};
# lspconfig should be enabled and configured automatically
lspconfig = {
enable = true;
sources = {}; # strings for snippet sources?
};
# lspkind provides vs code like icons for signatures
lspkind = {
enable = true;
setupOpts = {
# call before lspkind modifications are applied
before = null; # takes luainline
# defines orders of symbols shown, e.g. text_symbol or symbol
mode = "symbol_text";
};
};
# lsplines moves diagnostics to virtual lines after the actual line
lsplines.enable = true; # TODO: add a keymap to toggle this
# lspsaga provides many features:
# - breadcrumbs: provides trace to current symbol at top
# - callhierarchy: provides a list of the call hierarchy
# - code actions: shows a list of available code actions
# - definition: peek or go to definitions
# - diagnostic: jump around the diagnostics in the file and see the diagnostic in a floating window
# - finder: search for references etc
# - float terminal: open a floating terminal
# - hover: opens a floating docs window
# - implement: see interfaces
# - lightbulb: same as lightbulb
# - outline: see entire file outline
# - rename: change all occurrences
# - ui beacon: highlight the cursor
# default keybinds:
# - codeAction "<leader>ca"
# - lspFinder "<leader>lf"
# - nextDiagnostic "<leader>ln"
# - previewDefinition "<leader>ld"
# - previousDiagnostic "<leader>lp"
# - rename "<leader>lr"
# - renderHoveredDoc "<leader>lh"
# - showCursorDiagnostics "<leader>lc"
# - showLineDiagnostics "<leader>ll"
# - signatureHelp "<leader>ls"
# - smartScrollDown "<C-b>"
# - smartScrollUp "<C-f>"
lspsaga.enable = false;
# null-ls exposes nvim as a language server, also used automatically
null-ls = {
enable = true;
sources = {};
};
# nvim-docs-view provides documentation in the side panel
nvim-docs-view = {
enable = true;
# default mappings:
# - viewToggle "<leader>lvt"
# - viewUpdate "<leader>lvu"
mappings = {};
setupOpts = {};
};
# otter-nvim allows embedding code in other documents
otter-nvim = {
enable = true;
mappings.toggle = "<leader>lo"; # default
setupOpts = {};
};
# trouble.nvim shows diagnostics and search results
trouble = {
enable = true;
# default mappings:
# - documentDiagnostics "<leader>ld"
# - locList "<leader>xl"
# - lspReferences "<leader>lr"
# - quickfix "<leader>xq"
# - symbols "<leader>xs"
# - workspaceDiagnostics "<leader>lwd"
mappings = {};
setupOpts = {};
};
# default mappings for lsp:
# - addWorkspaceFolder "<leader>lwa"
# - codeAction "<leader>la"
# - documentHighlight "<leader>lH"
# - format "<leader>lf"
# - goToDeclaration "<leader>lgD"
# - goToDefinition "<leader>lgd"
# - goToType "<leader>lgt"
# - hover "<leader>lh"
# - listDocumentSymbols "<leader>lS"
# - listImplementations "<leader>lgi"
# - listReferences "<leader>lgr"
# - listWorkspaceFolders "<leader>lwl"
# - listWorkspaceSymbols "<leader>lws"
# - nextDiagnostic "<leader>lgn"
# - openDiagnosticFloat "<leader>le"
# - previousDiagnostic "<leader>lgp"
# - removeWorkspaceFolder "<leader>lwr"
# - renameSymbol "<leader>ln"
# - signatureHelp "<leader>ls"
# - toggleFormatOnSave "<leader>ltf"
};
}

View file

@ -0,0 +1,11 @@
{
programs.nvf.settings.vim.notes = {
# TODO: look into mind nvim
# todo-comments provides quick search for keywords like TODO
# default mappings
# - Open Todo-s in a quickfix list:<leader>tdq
# - Open Todo-s in telescope:<leader>tds
# - Open Todo-s in Trouble:<leader>tdt
todo-comments.enable = true;
};
}

View file

@ -0,0 +1,31 @@
{
programs.nvf.settings.vim = {
options = {
# Indentation
autoindent = true;
smartindent = true;
expandtab = true;
smarttab = true;
wrap = false;
shiftwidth = 2;
tabstop = 2;
foldlevel = 1000; # Open all folds by default
# Search
hlsearch = true;
ignorecase = true;
incsearch = true;
smartcase = true; # case-sensitive if search contains uppercase
# Visual
number = true;
relativenumber = true;
cursorline = true;
visualbell = true;
termguicolors = true;
# Input
backspace = "indent,eol,start";
};
};
}

View file

@ -0,0 +1,29 @@
{
programs.nvf.settings.vim.telescope = {
enable = true;
mappings = {
# default mappings
# - Buffers [Telescope]:<leader>fb
# - Diagnostics [Telescope]:<leader>fld
# - Find files [Telescope]:<leader>ff
# - Find projects [Telescope]:<leader>fp
# - Git branches [Telescope]:<leader>fvb
# - Git buffer commits [Telescope]:<leader>fvcb
# - Git commits [Telescope]:<leader>fvcw
# - Git stash [Telescope]:<leader>fvx
# - Git status [Telescope]:<leader>fvs
# - Help tags [Telescope]:<leader>fh
# - Live grep [Telescope]:<leader>fg
# - LSP Definitions [Telescope]:<leader>flD
# - LSP Document Symbols [Telescope]:<leader>flsb
# - LSP Implementations [Telescope]:<leader>fli
# - LSP References [Telescope]:<leader>flr
# - LSP Type Definitions [Telescope]:<leader>flt
# - LSP Workspace Symbols [Telescope]:<leader>flsw
# - Open [Telescope]:<leader>ft
# - Resume (previous search) [Telescope]:<leader>fr
# - Treesitter [Telescope]:<leader>fs
};
setupOpts = {};
};
}

View file

@ -0,0 +1,89 @@
{
programs.nvf.settings.vim = {
projects.project-nvim.enable = true;
utility = {
# ccc is a colour picker
ccc.enable = true;
# diffview-nvim lets you easily go through diffs for a given rev
diffview-nvim.enable = true;
# direnv.vim syncs the nvim shell environment with direnv
direnv.enable = true;
# icon-picker gives you a way to pick icons from nerd fonts
# TODO: find out keybinds
icon-picker.enable = true;
# image rendering
# TODO: look into image-magick and if it is needed
images.image-nvim.enable = true;
# leetcode
leetcode-nvim = {
enable = true;
setupOpts = {
image_support = true; # requires image.nvim
lang = "rust";
};
};
# mkdir.nvim creates directory when the path doesnt exist
mkdir.enable = true;
motion = {
hop.enable = true; # <leader>h
leap.enable = true;
leap.mappings = {
# default mappings
# - Leap backward till:<leader>sX
# - Leap backward to:<leader>sS
# - Leap forward till:<leader>sx
# - Leap forward to:<leader>ss
# - Leap from window:gs
};
# precognition.nvim shows hints for motions
precognition = {
enable = true;
setupOpts = {
# TODO: may want to fix dashboard
};
};
};
# multicursors.nvim enables vscode like multicursors
multicursors.enable = true;
# new-file-template.nvim automatically inserts templates in new files
new-file-template = {
enable = true;
# add a directory containing lua/tempaltes/*.lua to vim.additionalRuntimePaths
# TODO: add for nix
};
# allows usage of nix commands in nvim
nix-develop.enable = true;
# aerial.nvim shows a preview of your entire code file
outline.aerial-nvim.enable = true; # "g0"
# glow.nvim displays a floating window with a markdown preview
preview.glow.enable = true; # "<leader>p"
# nvim-surround allows you to easily surround and delete words or phrases
surround.enable = true;
# vim-wakatime allows sending statistics to wakatime or a compatible backend vim-wakatime.enable = true;
# yanky allows cycling through yank history when putting text
yanky-nvim.enable = true;
# yazi-nvim gives integration with yazi
# default mappings:
# - Open yazi at the current file [yazi.nvim]:<leader>-
# - Open the file manager in nvims working directory [yazi.nvim]:<leader>cw
# - Resume the last yazi session [yazi.nvim]:<c-up>
yazi-nvim.enable = true;
yazi-nvim.setupOpts.open_for_directories = true; # FIXME: does this work with neotree?
};
# TODO: look into terminal integration
terminal.toggleterm.enable = true;
terminal.toggleterm.lazygit.enable = true;
# nvim session manager manages sessions like folders in vscode
session.nvim-session-manager = {
enable = true;
mappings = {
# default mappings:
# - Delete session:<leader>sd
# - Load last session:<leader>slt
# - Load session:<leader>sl
# - Save current session:<leader>sc
};
};
comments.comment-nvim.enable = true;
};
}

View file

@ -0,0 +1,130 @@
{
programs.nvf.settings.vim = {
visuals = {
# fidget.nvim shows messages in the bottom right
fidget-nvim = {
enable = true;
setupOpts = {};
};
# highlight-undo.nvim highlights what text was changed when performing an action that modifies the buffer while not in insert mode
highlight-undo = {
enable = true;
setupOpts = {
duration = 100; # in ms
};
};
# indent-blankline.nvim adds indentation guides
indent-blankline = {
enable = true;
setupOpts = {};
};
# nvim-cursorline provides cursor word and line highlighting
nvim-cursorline = {
enable = true;
setupOpts = {
cursorword.enable = true;
cursorline.enable = false;
};
};
nvim-scrollbar.enable = true;
rainbow-delimiters.enable = true;
nvim-web-devicons.enable = true;
tiny-devicons-auto-colors.enable = true;
};
statusline.lualine = {
enable = true;
};
tabline.nvimBufferline = {
enable = true;
mappings = {
# default mappings:
# - Close buffer:null
# - Next buffer:<leader>bn
# - Previous buffer:<leader>bp
# - Move next buffer:<leader>bmn
# - Move previous buffer:<leader>bmp
# - Pick buffer:<leader>bc
# - Sort buffers by directory:<leader>bsd
# - Sort buffers by extension:<leader>bse
# - Sort buffers by ID:<leader>bsi
closeCurrent = "<C-w>";
# TODO: check these mappigns
# cycleNext = "<C-Tab>";
# cyclePrevious = "<C-Shift-Tab>";
};
setupOpts = {};
};
# treesitter handles syntax highlighting
treesitter = {
enable = true;
autotagHtml = true;
fold = true;
# provide context for current scope
context = {
enable = true;
setupOpts = {
mode = "topline";
};
};
mappings.incrementalSelection = {
# - Decrement selection by node [treesitter]:grm
# - Increment selection by node [treesitter]:grn
# - Increment selection by scope [treesitter]:grc
# - Init selection [treesitter]:gnn
};
};
git = {
enable = true;
# gitsigns indicates added, changed, deleted lines among other things
gitsigns.mappings = {
# - Blame line [Gitsigns]:<leader>hb
# - Diff project [Gitsigns]:<leader>hD
# - Diff this [Gitsigns]:<leader>hd
# - Next hunk [Gitsigns]:]c
# - Preview hunk [Gitsigns]:<leader>hP
# - Previous hunk [Gitsigns]:[c
# - Reset buffer [Gitsigns]:<leader>hR
# - Reset hunk [Gitsigns]:<leader>hr
# - Stage buffer [Gitsigns]:<leader>hS
# - Stage hunk [Gitsigns]:<leader>hs
# - Toggle blame [Gitsigns]:<leader>tb
# - Toggle deleted [Gitsigns]:<leader>td
# - Undo stage hunk [Gitsigns]:<leader>hu
};
# git-conflict visualises git conflicts and resolves
git-conflict.mappings = {
# Default mappings:
# - Choose Both [Git-Conflict]:<leader>cb
# - Go to the next Conflict [Git-Conflict]:[x
# - Choose None [Git-Conflict]:<leader>c0
# - Choose Ours [Git-Conflict]:<leader>co
# - Go to the previous Conflict [Git-Conflict]:]x
# - Choose Theirs [Git-Conflict]:<leader>ct
};
# vim-fugitive provides git cmds
};
dashboard.alpha.enable = true;
notify.nvim-notify.enable = true;
ui = {
borders.enable = true; # TODO: enable plugin specific
breadcrumbs.enable = true;
breadcrumbs.navbuddy.enable = true; # nvim-navic
# nvim-colorizer highlights color codes
colorizer.enable = true; # TODO: check if it works
# fastaction.nvim overrides vim.ui.select with fast action
# TODO: look into this
fastaction.enable = true;
# vim-illuminate highlights all occurrences
illuminate.enable = true; # TOOD: check if neotree is covered
# modes-nvim colors the whole line
modes-nvim.enable = true;
# noice displays the command window in a floating window and disables the cmd line
# TODO: look at the options
noice.enable = true;
# nvim-ufo makes folds look nicer
nvim-ufo.enable = true;
# smartcolumn enables line length indicators
smartcolumn.enable = true;
};
};
}

View file

@ -3,6 +3,8 @@
fastfetch # system info
wl-clipboard # provides cli copy and paste commands
aichat # duh
ripgrep
ueberzugpp # image rendering backend for the terminal
];
services = {