update: neovim lsp

This commit is contained in:
DACHXY 2025-01-03 01:33:15 +08:00
parent e63917ca85
commit 43e394c86a
14 changed files with 244 additions and 128 deletions

View file

@ -45,9 +45,6 @@
nix-version = "25.05"; nix-version = "25.05";
in in
{ {
formatter.x86_64-linux =
nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
nixosConfigurations = { nixosConfigurations = {
dn-pre7780 = nixpkgs.lib.nixosSystem { dn-pre7780 = nixpkgs.lib.nixosSystem {
modules = [ modules = [

View file

@ -36,7 +36,7 @@ require("lazy").setup({
{ import = "lazyvim.plugins.extras.lang.markdown" }, { import = "lazyvim.plugins.extras.lang.markdown" },
{ import = "lazyvim.plugins.extras.lang.nushell" }, { import = "lazyvim.plugins.extras.lang.nushell" },
{ import = "lazyvim.plugins.extras.lang.omnisharp" }, { import = "lazyvim.plugins.extras.lang.omnisharp" },
{ import = "lazyvim.plugins.extras.lang.python" }, -- { import = "lazyvim.plugins.extras.lang.python" },
{ import = "lazyvim.plugins.extras.lang.rust" }, { import = "lazyvim.plugins.extras.lang.rust" },
{ import = "lazyvim.plugins.extras.lang.tailwind" }, { import = "lazyvim.plugins.extras.lang.tailwind" },
{ import = "lazyvim.plugins.extras.lang.toml" }, { import = "lazyvim.plugins.extras.lang.toml" },

View file

@ -1,8 +1,37 @@
local util = require("lspconfig.util") require("lspconfig").lua_ls.setup({
on_init = function(client)
local path = client.workspace_folders[1].name
if vim.loop.fs_stat(path .. "/.luarc.json") or vim.loop.fs_stat(path .. "/.luarc.jsonc") then
return
end
client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
-- Depending on the usage, you might want to add additional paths here.
"${3rd}/luv/library",
-- "${3rd}/busted/library",
},
},
})
end,
settings = {
Lua = {},
},
})
return { return {
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
event = "LazyFile",
opts = { opts = {
servers = { servers = {
-- biome = { -- biome = {
@ -14,7 +43,35 @@ return {
-- or util.find_git_ancestor(fname) -- or util.find_git_ancestor(fname)
-- end, -- end,
-- }, -- },
nil_ls = false,
nixd = {
cmd = { "nixd" },
settings = {
nixd = {
nixpkgs = {
expr = "import <nixpkgs> { }",
},
formatting = {
command = { "nixfmt" },
},
options = {
nixos = {
expr = '(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.k-on.options',
},
home_manager = {
expr = '(builtins.getFlake ("git+file://" + toString ./.)).homeConfigurations."ruixi@k-on".options',
},
},
},
},
},
nginx_language_server = {
cmd = { "nginx-language-server" },
filetypes = { "nginx" },
rootPatterns = { "nginx.conf", ".git" },
},
}, },
}, },
setup = {},
}, },
} }

View file

@ -0,0 +1,11 @@
return {
{
"iamcco/markdown-preview.nvim",
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
build = "cd app && yarn install",
init = function()
vim.g.mkdp_filetypes = { "markdown" }
end,
ft = { "markdown" },
},
}

View file

@ -0,0 +1,5 @@
-- Mason is not usable on NixOS
return {
{ "williamboman/mason-lspconfig.nvim", enabled = false },
{ "williamboman/mason.nvim", enabled = false },
}

View file

@ -0,0 +1,7 @@
return {
{
"lambdalisue/vim-suda",
cmd = "SudaWrite",
keys = { { "<leader>bs", "<cmd>SudaWrite<cr>", desc = "Save Buffer as Root" } },
},
}

View file

@ -1,4 +1,4 @@
{ config, pkgs, pkgsUnstable, nix-version, ... }: { nix-version, ... }:
{ {
imports = [ ./user ]; imports = [ ./user ];

View file

@ -1,12 +1,9 @@
{ pkgs, ... }: { ... }:
let configDir = ../config; let
configDir = ../config;
in in
{ {
home.file = { home.file = {
# ".config/nvim" = {
# source = "${configDir}/nvim";
# recursive = true;
# };
".config/wallpapers".source = "${configDir}/wallpapers"; ".config/wallpapers".source = "${configDir}/wallpapers";
".config/kitty".source = "${configDir}/kitty"; ".config/kitty".source = "${configDir}/kitty";
".config/neofetch".source = "${configDir}/neofetch"; ".config/neofetch".source = "${configDir}/neofetch";

View file

@ -1,10 +1,14 @@
let let
userName = "dachxy"; userName = "dachxy";
email = "Danny10132024@gmail.com"; email = "Danny10132024@gmail.com";
in { in
{
programs.git = { programs.git = {
enable = true; enable = true;
userName = userName; userName = userName;
userEmail = email; userEmail = email;
extraConfig = {
safe.directory = [ "/etc/nixos" ];
};
}; };
} }

View file

@ -1,33 +1,35 @@
{ pkgs, ... }: { pkgs, ... }:
let let
treesitterWithGrammars = (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [ treesitterWithGrammars = (
p.bash pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [
p.comment p.bash
p.css p.comment
p.dockerfile p.css
p.fish p.dockerfile
p.gitattributes p.fish
p.gitignore p.gitattributes
p.go p.gitignore
p.gomod p.go
p.gowork p.gomod
p.hcl p.gowork
p.javascript p.hcl
p.jq p.javascript
p.json5 p.jq
p.json p.json5
p.lua p.json
p.make p.lua
p.markdown p.make
p.nix p.markdown
p.python p.nix
p.rust p.python
p.toml p.rust
p.typescript p.toml
p.vue p.typescript
p.yaml p.vue
])); p.yaml
])
);
treesitter-parsers = pkgs.symlinkJoin { treesitter-parsers = pkgs.symlinkJoin {
name = "treesitter-parsers"; name = "treesitter-parsers";
@ -36,13 +38,20 @@ let
configDir = ../config; configDir = ../config;
in in
{ {
# Other Lsp servers are defined in system/module/lsp.nix
home.packages = with pkgs; [ home.packages = with pkgs; [
ripgrep
fd
lua-language-server
black
nodejs_22
gh gh
vue-language-server
dockerfile-language-server-nodejs
black
prettierd
javascript-typescript-langserver
marksman
tailwindcss-language-server
ruff
ruff-lsp
pyright
hadolint
]; ];
programs.neovim = { programs.neovim = {
@ -51,9 +60,13 @@ in
coc.enable = false; coc.enable = false;
withNodeJs = true; withNodeJs = true;
plugins = [ plugins =
treesitterWithGrammars [
]; treesitterWithGrammars
]
++ (with pkgs.vimPlugins; [
markdown-preview-nvim
]);
extraPackages = [ pkgs.imagemagick ]; extraPackages = [ pkgs.imagemagick ];
extraLuaPackages = ps: with ps; [ magick ]; extraLuaPackages = ps: with ps; [ magick ];
}; };

View file

@ -24,5 +24,6 @@
./display-manager.nix ./display-manager.nix
./gc.nix ./gc.nix
./polkit.nix ./polkit.nix
./lsp.nix
]; ];
} }

17
system/modules/lsp.nix Normal file
View file

@ -0,0 +1,17 @@
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
ripgrep
fd
lua-language-server
nodejs_22
nixfmt-rfc-style
markdownlint-cli2
shfmt
nixd
marksman
nginx-language-server
nodePackages_latest.vscode-json-languageserver
];
}

View file

@ -1,89 +1,96 @@
{ pkgs, inputs, system, ... }:
{ {
environment.systemPackages = (with pkgs; [ pkgs,
# gtk theme inputs,
gtk3 system,
adwaita-icon-theme ...
}:
{
environment.systemPackages =
(with pkgs; [
# gtk theme
gtk3
adwaita-icon-theme
# Browser # Browser
firefox firefox
# File Manager # File Manager
nemo nemo
# Utils # Utils
bat bat
btop btop
eza eza
fzf fzf
neofetch neofetch
ripgrep ripgrep
tree tree
tldr # Alternative for man tldr # Alternative for man
wget wget
unzip unzip
p7zip p7zip
killall killall
zip zip
glxinfo # OpenGL info glxinfo # OpenGL info
pciutils # PCI info pciutils # PCI info
xdotool # Keyboard input simulation xdotool # Keyboard input simulation
ffmpeg # Video encoding ffmpeg # Video encoding
mpv # Media player mpv # Media player
brightnessctl brightnessctl
# Dev # Dev
git git
gh # Github cli tool gh # Github cli tool
gnumake gnumake
lm_sensors lm_sensors
libsForQt5.qt5.qtquickcontrols2 libsForQt5.qt5.qtquickcontrols2
libsForQt5.qt5.qtgraphicaleffects libsForQt5.qt5.qtgraphicaleffects
libsForQt5.qt5.qtsvg libsForQt5.qt5.qtsvg
openssl openssl
openssl.dev openssl.dev
pkg-config # Include Lib pkg-config # Include Lib
nodejs nodejs
yarn-berry yarn-berry
dotnetCorePackages.sdk_8_0_3xx dotnetCorePackages.sdk_8_0_3xx
dotnetCorePackages.dotnet_9.sdk dotnetCorePackages.dotnet_9.sdk
dotnetCorePackages.dotnet_9.runtime dotnetCorePackages.dotnet_9.runtime
dotnetCorePackages.dotnet_9.aspnetcore dotnetCorePackages.dotnet_9.aspnetcore
rustup rustup
gcc
# Editor # Editor
neovim neovim
stylua stylua
lazygit lazygit
lua51Packages.lua luajitPackages.lua
lua51Packages.luarocks lua51Packages.lua
luajitPackages.magick luajitPackages.luarocks
imagemagick luajitPackages.magick
imagemagick
# Shell # Shell
fishPlugins.done fishPlugins.done
fishPlugins.fzf-fish fishPlugins.fzf-fish
fishPlugins.forgit fishPlugins.forgit
fishPlugins.hydro fishPlugins.hydro
fishPlugins.grc fishPlugins.grc
grc # Colorize grc # Colorize
zoxide # Dir jumper zoxide # Dir jumper
starship # Shell theme starship # Shell theme
carapace # Autocomplete carapace # Autocomplete
# USB auto mount # USB auto mount
usbutils usbutils
udiskie udiskie
udisks udisks
# Media # Media
vlc vlc
# Thumbnail # Thumbnail
ffmpegthumbnailer ffmpegthumbnailer
]) ++ ([ ])
inputs.ghostty.packages.${system}.default ++ ([
]); inputs.ghostty.packages.${system}.default
]);
} }

View file

@ -33,8 +33,8 @@ in
set -g status-left "#[fg=#84977f,bg=default,bold] session: #S" set -g status-left "#[fg=#84977f,bg=default,bold] session: #S"
set -g status-right " #[fg=#828bb8,bg=default,bold]${config.networking.hostName} " set -g status-right " #[fg=#828bb8,bg=default,bold]${config.networking.hostName} "
setw -g window-status-format "#[bg=default] #[fg=#495361,bg=default]#(${getIconScript}/get-icon #I)#W" setw -g window-status-format "#[bg=#171616,bg=default] #[fg=#495361,bg=default]#(${getIconScript}/get-icon #I)#W"
setw -g window-status-current-format "#[bg=default] #[fg=#7e93a9,bg=default,bold]#(${getIconScript}/get-icon #I) #W" setw -g window-status-current-format "#[fg=#7e93a9,bg=default] #[fg=#7e93a9,bg=default,bold]#(${getIconScript}/get-icon #I) #W"
set -g default-terminal "xterm-256color" set -g default-terminal "xterm-256color"