From 64d5097f1ada44e7af4405266c8a5c905645f52d Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Thu, 13 Feb 2025 12:23:39 +1000 Subject: [PATCH] added nixd lsp to helix --- DEV_ENV | 65 ++++++++++++++++++++++++++++++++++ HELIX_LSP_GUIDE | 18 ++++++++++ homes/modules/editor/helix.nix | 65 +++++++++++++++++++--------------- hosts/lolcathost/default.nix | 5 +++ 4 files changed, 125 insertions(+), 28 deletions(-) create mode 100644 DEV_ENV create mode 100644 HELIX_LSP_GUIDE diff --git a/DEV_ENV b/DEV_ENV new file mode 100644 index 0000000..5d6ffca --- /dev/null +++ b/DEV_ENV @@ -0,0 +1,65 @@ +This file will document what features I believe I need +for NixOS to be a good development environment. + + +Issues I've encountered: +- [X] Audio not working +- [ ] Tesseract is a pain in the ass to setup on Nix +- [ ] ags no longer supports `-t` flag, so applauncher won't work, requires switching to Astral +- [ ] script to enable/disable passwordless sudo + +- [ ] Move Emile.Vault to new vault (I lost the password...) + +- [ ] Add a simple and ugly bar + +- [ ] Install powertop (funny name) for monitoring power usage by processes +- [ ] Try to make my battery life bettery + +- [ ] Apply for JetBrains student license +- [ ] JetBrains Rider and VSCodium for C# +2. Imperative development environment behind NixOS (declarative), +similar to python's virtualenv but for the entirety of my system. + +- [ ] Call my wishlist command "subspace (highway)" (Scott Pilgrim reference) + +- [ ] Create a GitHub profile readme like this persons: + https://github.com/yuyudhn +- [ ] Set a new GitHub profile picture (like github:@Vendicated) + artists credit: https://dotpict.net/users/1598051 +- [ ] Change GitHub location to /dev/zero, /dev/null, www, World Wide Web, etc +- [ ] Clean up my GitHub profile (only have things I'm proud of) + +- [X] Put a template website on my VPS +- [ ] Put a neoweb-esque webiste on my VPS +- [ ] Host a blog on my VPS + +- [ ] Clean laptop and PC, there's tons of unnecessary files and documents now +- [ ] Clean nixdots repo, start modularising it ^_^ +- [ ] Disable `allowUnfree` in nixdots everywhere, if a program needs it then they + can `mkForce` override it + +- [X] Add LSP for Nix in helix +- [ ] Make a way for me to put my laptop in a low power state, doing very specific actions like: + 1. disabling LSP use by default temporarily + +TODO: +- [X] make btop theming declarative +- [ ] Merge laptop and PC dotfiles repos + + +Cool Technologies: +- wishlist (by charmbracelet) +- Vaultwarden server + Keyguard client +- devbox + + + +Random Idea List: +- [ ] powertop is cool but it's outdated and ugly, make a prettier one with charmbracelet's tui library + and call it powerbtm lmao +- [ ] Blog Post: a modern alternative to the suckless philosphy, + why GNU keeps failing cause their programs are amazing but + aren't designed for humans. suckless programs are excellent + too when writing shell scripts, but they suck in dev environments. + The solution is to gamify our code and focus on aesthetics + and "ergonomics" (usability) like what CharmBracelet does diff --git a/HELIX_LSP_GUIDE b/HELIX_LSP_GUIDE new file mode 100644 index 0000000..e8bf5c5 --- /dev/null +++ b/HELIX_LSP_GUIDE @@ -0,0 +1,18 @@ +`gd` (goto definition when LSP is active) +`gy` (goto type definition) +`gr` (goto references) +`gi` (goto implementation) + +`k` (show documentation for item under cursor) +`s` (show picker for symbols in file) +`S` (show picker for symbols in workspace) +`d` (document diagnostics picker for file) +`D` (document diagnostics picker for workspace) +`r` (rename symbol) +`a` (apply code action, not show what that means though...) +`h` (select symbol references) + +`]d` (goto next diagnostic) +`[d` (goto previous diagnostic) +`]D` (goto last diagnostic in document) +`[D` (goto first diagnostic in document) diff --git a/homes/modules/editor/helix.nix b/homes/modules/editor/helix.nix index 4a66841..52c629a 100644 --- a/homes/modules/editor/helix.nix +++ b/homes/modules/editor/helix.nix @@ -1,13 +1,10 @@ -{ - config, - pkgs, - ... -}: { +{pkgs, ...}: { # read https://docs.helix-editor.com/editor.html programs.helix = { enable = true; settings = { theme = "dracula"; + editor = { line-number = "absolute"; popup-border = "all"; @@ -107,29 +104,41 @@ }; }; - languages.language = [ - { - name = "nix"; - indent = { - tab-width = 2; - unit = " "; + languages = { + language = [ + { + name = "nix"; + indent = { + tab-width = 2; + unit = " "; + }; + block-comment-tokens = { + start = "/*"; + end = "*/"; + }; + auto-format = true; + formatter.command = "${pkgs.alejandra}/bin/alejandra"; + language-servers = ["nixd"]; + } + { + name = "python"; + indent = { + tab-width = 4; + unit = " "; + }; + auto-format = false; # my python is beautiful ^_^ + rulers = [80]; + } + ]; + + language-server = { + # use nixd as default nix lsp (I haven't tried nil yet) + # NOTE: nixd will be supported by default after nix 24.07 + # SOURCE: https://github.com/nix-community/nixd/blob/main/nixd/docs/editor-setup.md#Helix + nixd = { + command = "${pkgs.nixd}/bin/nixd"; }; - block-comment-tokens = { - start = "/*"; - end = "*/"; - }; - auto-format = true; - formatter.command = "${pkgs.alejandra}/bin/alejandra"; - } - { - name = "python"; - indent = { - tab-width = 4; - unit = " "; - }; - auto-format = false; # my python is beautiful ^_^ - rulers = [80]; - } - ]; + }; + }; }; } diff --git a/hosts/lolcathost/default.nix b/hosts/lolcathost/default.nix index 172aa0f..0167200 100755 --- a/hosts/lolcathost/default.nix +++ b/hosts/lolcathost/default.nix @@ -200,6 +200,11 @@ in { tldr btop + # TODO: once upgraded past Nix-24.07 this line won't be necessary (I think) + # helix will support nixd by default + # SOURCE: https://github.com/nix-community/nixd/blob/main/nixd/docs/editor-setup.md#Helix + nixd # lsp for nix + # Pretty necessary git brightnessctl