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,7 +1,8 @@
{ pkgs, ... }: { pkgs, ... }:
let let
treesitterWithGrammars = (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [ treesitterWithGrammars = (
pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [
p.bash p.bash
p.comment p.comment
p.css p.css
@ -27,7 +28,8 @@ let
p.typescript p.typescript
p.vue p.vue
p.yaml 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,6 +1,12 @@
{ pkgs, inputs, system, ... }:
{ {
environment.systemPackages = (with pkgs; [ pkgs,
inputs,
system,
...
}:
{
environment.systemPackages =
(with pkgs; [
# gtk theme # gtk theme
gtk3 gtk3
adwaita-icon-theme adwaita-icon-theme
@ -50,13 +56,15 @@
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
luajitPackages.lua
lua51Packages.lua lua51Packages.lua
lua51Packages.luarocks luajitPackages.luarocks
luajitPackages.magick luajitPackages.magick
imagemagick imagemagick
@ -81,9 +89,8 @@
# 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"