init
This commit is contained in:
commit
1e2ca5a6fc
71 changed files with 3330 additions and 0 deletions
152
config/plugins/lsp/conform-nvim.nix
Normal file
152
config/plugins/lsp/conform-nvim.nix
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
helpers,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (helpers) mkRaw;
|
||||
in
|
||||
{
|
||||
plugins = {
|
||||
# https://github.com/stevearc/conform.nvim/
|
||||
# Preserves extmarks and folds
|
||||
# Fixes bad-behaving LSP formatters
|
||||
# Enables range formatting for all formatters
|
||||
# And more
|
||||
conform-nvim = {
|
||||
enable = lib.mkIf config.plugins.lsp.enable true;
|
||||
settings = {
|
||||
formatters_by_ft = {
|
||||
perl = [ "perltidy" ];
|
||||
# nix = ["nixfmt" "alejandra"];
|
||||
nix = [ "nixfmt" ];
|
||||
sh = [
|
||||
"shellcheck"
|
||||
"shellharden"
|
||||
"shfmt"
|
||||
];
|
||||
bash = [
|
||||
"shellcheck"
|
||||
"shellharden"
|
||||
"shfmt"
|
||||
];
|
||||
cpp = [ "clang_format" ];
|
||||
javascript = {
|
||||
__unkeyed-1 = "prettierd";
|
||||
__unkeyed-2 = "prettier";
|
||||
timeout_ms = 2000;
|
||||
stop_after_first = true;
|
||||
};
|
||||
lua = [ "stylua" ];
|
||||
# -- Conform will run multiple formatters sequentially
|
||||
python = [
|
||||
"isort"
|
||||
"black"
|
||||
];
|
||||
# -- You can customize some of the format options for the filetype (:help conform.format)
|
||||
rust = {
|
||||
_unkeyed-1 = "rustfmt";
|
||||
lsp_format = "fallback";
|
||||
};
|
||||
tex = [ "latexindent" ];
|
||||
# Use the "_" filetype to run formatters on filetypes that don't
|
||||
# have other formatters configured.
|
||||
"_" = [
|
||||
"squeeze_blanks"
|
||||
"trim_whitespace"
|
||||
"trim_newlines"
|
||||
];
|
||||
};
|
||||
# format_on_save =
|
||||
# # Lua
|
||||
# ''
|
||||
# function(bufnr)
|
||||
# if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
# return
|
||||
# end
|
||||
#
|
||||
# if slow_format_filetypes[vim.bo[bufnr].filetype] then
|
||||
# return
|
||||
# end
|
||||
#
|
||||
# local function on_format(err)
|
||||
# if err and err:match("timeout$") then
|
||||
# slow_format_filetypes[vim.bo[bufnr].filetype] = true
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# return { timeout_ms = 200, lsp_fallback = true }, on_format
|
||||
# end
|
||||
# '';
|
||||
# format_after_save =
|
||||
# # Lua
|
||||
# ''
|
||||
# function(bufnr)
|
||||
# if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
# return
|
||||
# end
|
||||
#
|
||||
# if not slow_format_filetypes[vim.bo[bufnr].filetype] then
|
||||
# return
|
||||
# end
|
||||
#
|
||||
# return { lsp_fallback = true }
|
||||
# end
|
||||
# '';
|
||||
log_level = "warn";
|
||||
notify_on_error = true;
|
||||
notify_no_formatters = true;
|
||||
formatters = {
|
||||
perltidy = {
|
||||
command = lib.getExe pkgs.perlPackages.PerlTidy;
|
||||
prepend_args = [ "-i=2" ]; # default 4 spaces
|
||||
};
|
||||
shfmt = {
|
||||
command = lib.getExe pkgs.shfmt;
|
||||
};
|
||||
shellcheck = {
|
||||
command = lib.getExe pkgs.shellcheck;
|
||||
};
|
||||
shellharden = {
|
||||
command = lib.getExe pkgs.shellharden;
|
||||
};
|
||||
squeeze_blanks = {
|
||||
command = lib.getExe' pkgs.coreutils "cat";
|
||||
};
|
||||
latexindent = {
|
||||
command = lib.getExe' pkgs.texlivePackages.latexindent "latexindent";
|
||||
# latexindent always produce indent.log in the current directory. It cannot be disabled in indentconfig.yaml
|
||||
# This flag redirect it to /dev/null
|
||||
prepend_args = [
|
||||
"-g"
|
||||
"/dev/null"
|
||||
];
|
||||
};
|
||||
# alejandra = {
|
||||
# command = lib.getExe pkgs.alejandra;
|
||||
# prepend_args = ["--quiet"];
|
||||
# };
|
||||
nixfmt = {
|
||||
command = lib.getExe pkgs.nixfmt-rfc-style;
|
||||
};
|
||||
stylua = {
|
||||
command = lib.getExe pkgs.stylua;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
keymaps = [
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>lf";
|
||||
action = mkRaw ''
|
||||
function()
|
||||
require("conform").format()
|
||||
end'';
|
||||
options.desc = "Format with conform-nvim";
|
||||
}
|
||||
];
|
||||
}
|
||||
133
config/plugins/lsp/lsp.nix
Normal file
133
config/plugins/lsp/lsp.nix
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
{
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
./lspkind.nix
|
||||
./conform-nvim.nix # fix lsp formatter issues
|
||||
|
||||
./servers/clangd.nix
|
||||
./servers/eslint.nix
|
||||
./servers/pyright.nix
|
||||
./servers/ruff.nix
|
||||
./servers/lua_ls.nix
|
||||
./servers/bashls.nix
|
||||
# ./servers/nil_ls.nix # replaced by nixd
|
||||
./servers/nixd.nix
|
||||
./servers/rust_analyzer.nix
|
||||
./servers/ts_ls.nix
|
||||
./servers/texlab/texlab.nix
|
||||
];
|
||||
plugins = {
|
||||
# # https://github.com/lukas-reineke/lsp-format.nvim/
|
||||
# # auto format on save
|
||||
# lsp-format = {
|
||||
# enable = false; # Enable it if you want lsp-format integration for none-ls
|
||||
# };
|
||||
# # formatter and diagnose
|
||||
# none-ls = {
|
||||
# enable = true;
|
||||
# # don't enable use lsp-format plugin
|
||||
# enableLspFormat = false;
|
||||
# sources = {
|
||||
# formatting = {
|
||||
# alejandra.enable = true;
|
||||
# stylua.enable = true;
|
||||
# };
|
||||
# };
|
||||
# };
|
||||
lsp = {
|
||||
enable = true;
|
||||
capabilities = "offsetEncoding = 'utf-16'";
|
||||
keymaps = {
|
||||
silent = true;
|
||||
lspBuf = {
|
||||
# use require("conform").format() instead
|
||||
# "<space>lf" = {
|
||||
# action = "format";
|
||||
# desc = "Lsp format";
|
||||
# };
|
||||
gd = {
|
||||
action = "definition";
|
||||
desc = "Goto Definition";
|
||||
};
|
||||
gr = {
|
||||
action = "references";
|
||||
desc = "Goto References";
|
||||
};
|
||||
gD = {
|
||||
action = "declaration";
|
||||
desc = "Goto Declaration";
|
||||
};
|
||||
gI = {
|
||||
action = "implementation";
|
||||
desc = "Goto Implementation";
|
||||
};
|
||||
gT = {
|
||||
action = "type_definition";
|
||||
desc = "Type Definition";
|
||||
};
|
||||
K = {
|
||||
action = "hover";
|
||||
desc = "Hover";
|
||||
};
|
||||
"<leader>cw" = {
|
||||
action = "workspace_symbol";
|
||||
desc = "Workspace Symbol";
|
||||
};
|
||||
"<leader>cr" = {
|
||||
action = "rename";
|
||||
desc = "Rename";
|
||||
};
|
||||
"<leader>ca" = {
|
||||
action = "code_action";
|
||||
desc = "Code Action";
|
||||
};
|
||||
# "<C-k>" = {
|
||||
"<C-S-k>" = {
|
||||
action = "signature_help";
|
||||
desc = "Signature Help";
|
||||
};
|
||||
};
|
||||
diagnostic = {
|
||||
"<leader>cd" = {
|
||||
action = "open_float";
|
||||
desc = "Line Diagnostics";
|
||||
};
|
||||
"[d" = {
|
||||
action = "goto_next";
|
||||
desc = "Next Diagnostic";
|
||||
};
|
||||
"]d" = {
|
||||
action = "goto_prev";
|
||||
desc = "Previous Diagnostic";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
extraConfigLua = ''
|
||||
local _border = "rounded"
|
||||
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
|
||||
vim.lsp.handlers.hover, {
|
||||
border = _border
|
||||
}
|
||||
)
|
||||
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
|
||||
vim.lsp.handlers.signature_help, {
|
||||
border = _border
|
||||
}
|
||||
)
|
||||
|
||||
vim.diagnostic.config{
|
||||
float={border=_border}
|
||||
};
|
||||
|
||||
require('lspconfig.ui.windows').default_options = {
|
||||
border = _border
|
||||
}
|
||||
'';
|
||||
}
|
||||
19
config/plugins/lsp/lspkind.nix
Normal file
19
config/plugins/lsp/lspkind.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
helpers,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (helpers) mkRaw;
|
||||
in
|
||||
{
|
||||
# TJ
|
||||
# https://www.youtube.com/watch?v=_DnmphIwnjo
|
||||
plugins = {
|
||||
# Make cmp have icons and colors
|
||||
lspkind = {
|
||||
enable = lib.mkIf config.plugins.cmp.enable true;
|
||||
};
|
||||
};
|
||||
}
|
||||
24
config/plugins/lsp/servers/bashls.nix
Normal file
24
config/plugins/lsp/servers/bashls.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
plugins.lsp.servers = {
|
||||
bashls = {
|
||||
enable = true;
|
||||
filetypes = [
|
||||
"sh"
|
||||
"bash"
|
||||
];
|
||||
# extraOptions = {
|
||||
# settings = {
|
||||
# Lua = {
|
||||
# completion = {
|
||||
# callSnippet = "Replace";
|
||||
# };
|
||||
# telemetry = {
|
||||
# enabled = false;
|
||||
# };
|
||||
# hint = {enable = true;};
|
||||
# };
|
||||
# };
|
||||
# };
|
||||
};
|
||||
};
|
||||
}
|
||||
7
config/plugins/lsp/servers/clangd.nix
Normal file
7
config/plugins/lsp/servers/clangd.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
plugins = {
|
||||
lsp.servers = {
|
||||
clangd.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
7
config/plugins/lsp/servers/eslint.nix
Normal file
7
config/plugins/lsp/servers/eslint.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
plugins = {
|
||||
lsp.servers = {
|
||||
eslint.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
22
config/plugins/lsp/servers/lua_ls.nix
Normal file
22
config/plugins/lsp/servers/lua_ls.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
plugins.lsp.servers = {
|
||||
lua_ls = {
|
||||
enable = true;
|
||||
extraOptions = {
|
||||
settings = {
|
||||
Lua = {
|
||||
completion = {
|
||||
callSnippet = "Replace";
|
||||
};
|
||||
telemetry = {
|
||||
enabled = false;
|
||||
};
|
||||
hint = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
12
config/plugins/lsp/servers/nil_ls.nix
Normal file
12
config/plugins/lsp/servers/nil_ls.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
plugins.lsp.servers = {
|
||||
nil_ls = {
|
||||
enable = true;
|
||||
# Fix error message:
|
||||
# lsp.message LSP Message (nil_ls) Some flake inputs are not available, please run `nix flake archive` to fetch them.
|
||||
# Your LSP client doesn't support confirmation. You can enable autoArchive in lsp configuration.
|
||||
# https://github.com/oxalica/nil/issues/131#issuecomment-2241281279
|
||||
settings.nix.flake.autoArchive = false;
|
||||
};
|
||||
};
|
||||
}
|
||||
21
config/plugins/lsp/servers/nixd.nix
Normal file
21
config/plugins/lsp/servers/nixd.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
variant,
|
||||
lib,
|
||||
self,
|
||||
system,
|
||||
...
|
||||
}:
|
||||
{
|
||||
plugins.lsp.servers = {
|
||||
nixd = {
|
||||
enable = true;
|
||||
settings = lib.mkMerge [
|
||||
{
|
||||
diagnostic.suppress = [ ];
|
||||
# This will not be used, formatters use conform-nvim.nix instead in keymaps
|
||||
# formatting.command = ["alejandra"];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
7
config/plugins/lsp/servers/pyright.nix
Normal file
7
config/plugins/lsp/servers/pyright.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
plugins = {
|
||||
lsp.servers = {
|
||||
pyright.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
7
config/plugins/lsp/servers/ruff.nix
Normal file
7
config/plugins/lsp/servers/ruff.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
plugins = {
|
||||
lsp.servers = {
|
||||
ruff.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
24
config/plugins/lsp/servers/rust_analyzer.nix
Normal file
24
config/plugins/lsp/servers/rust_analyzer.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
plugins.lsp.servers = {
|
||||
rust_analyzer = {
|
||||
enable = true;
|
||||
installCargo = true;
|
||||
installRustc = true;
|
||||
settings = {
|
||||
checkOnSave = true;
|
||||
check = {
|
||||
command = "clippy";
|
||||
};
|
||||
# inlayHints = {
|
||||
# enable = true;
|
||||
# showParameterNames = true;
|
||||
# parameterHintsPrefix = "<- ";
|
||||
# otherHintsPrefix = "=> ";
|
||||
# };
|
||||
procMacro = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
1
config/plugins/lsp/servers/texlab/indentconfig.yaml
Normal file
1
config/plugins/lsp/servers/texlab/indentconfig.yaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
# defaultIndent: " "
|
||||
117
config/plugins/lsp/servers/texlab/texlab.nix
Normal file
117
config/plugins/lsp/servers/texlab/texlab.nix
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (helpers) mkRaw;
|
||||
use_tectonic = false;
|
||||
in
|
||||
{
|
||||
plugins.lsp.servers = {
|
||||
texlab = {
|
||||
enable = true;
|
||||
filetypes = [
|
||||
"tex"
|
||||
"plaintex"
|
||||
"bib"
|
||||
];
|
||||
settings = {
|
||||
texlab = {
|
||||
# --------------------------------
|
||||
# -- START texlab main config
|
||||
# -- if used with texmagic, disable this
|
||||
# --------------------------------
|
||||
# https://github.com/latex-lsp/texlab/wiki/Configuration#deprecated-texlabauxdirectory
|
||||
# auxDirectory = "tex_aux_output"; # deprecated
|
||||
rootDirectory = false;
|
||||
build = lib.mkMerge [
|
||||
(lib.mkIf (!use_tectonic) {
|
||||
executable = "latexmk";
|
||||
args = [
|
||||
"-xelatex"
|
||||
"-verbose"
|
||||
# -- "-outdir=%f_output"
|
||||
# -- "-auxdir=%f_aux"
|
||||
"-auxdir=tex_aux_output"
|
||||
"-file-line-error"
|
||||
# https://github.com/latex-lsp/texlab/wiki/Previewing
|
||||
# use for forward serach and inverse search
|
||||
"-synctex=1"
|
||||
|
||||
"-interaction=nonstopmode"
|
||||
# "-pvc" # preview continuously update instead if -pv (open a new instance)
|
||||
"%f"
|
||||
];
|
||||
})
|
||||
(lib.mkIf use_tectonic {
|
||||
executable = "tectonic";
|
||||
# https://github.com/latex-lsp/texlab/wiki/Tectonic
|
||||
# V2
|
||||
args = [
|
||||
"-X"
|
||||
"compile"
|
||||
"%f"
|
||||
"--synctex"
|
||||
"--keep-logs"
|
||||
"--keep-intermediates"
|
||||
];
|
||||
})
|
||||
{
|
||||
auxDirectory = "tex_aux_output";
|
||||
logDirectory = "tex_aux_output";
|
||||
pdfDirectory = ".";
|
||||
# -- forwardSearchAfter = true,
|
||||
isContinuous = true;
|
||||
# -- "onSave = true" failed to work properly with large files like moderncv
|
||||
# -- it would not build properly until you delete all the intermediate files
|
||||
onSave = true;
|
||||
# --------------------------------
|
||||
# -- END texlab main config
|
||||
# -- if used with texmagic, disable this
|
||||
# --------------------------------
|
||||
# https://github.com/latex-lsp/texlab/wiki/Previewing#zathura
|
||||
}
|
||||
];
|
||||
forwardSearch = {
|
||||
executable = "zathura";
|
||||
args = [
|
||||
"--synctex-forward"
|
||||
"%l:1:%f"
|
||||
"%p"
|
||||
];
|
||||
};
|
||||
# Inverse Search for zathura set in ~/.config/zathura/zathurarc
|
||||
# set synctex true
|
||||
# set synctex-editor-command "texlab inverse-search -i %{input} -l %{line}"
|
||||
chktex = {
|
||||
onOpenAndSave = true;
|
||||
onEdit = true;
|
||||
};
|
||||
# https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/configs/texlab.lua#L179-L183
|
||||
# https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/configs/texlab.lua#L179-L183
|
||||
latexindent = {
|
||||
local = ./indentconfig.yaml;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
autoCmd = [
|
||||
{
|
||||
pattern = [ "tex" ];
|
||||
event = [ "FileType" ];
|
||||
callback = mkRaw ''
|
||||
function()
|
||||
-- vim.keymap.set( 'n', '<leader>TH', "<CMD>TexlabBuild<CR>", { desc = 'TexlabBuild' })
|
||||
-- vim.keymap.set( 'n', '<leader>TD', "<CMD>TexlabCleanAuxiliary<CR>", { desc = 'TexlabCleanAuxiliary' })
|
||||
-- vim.keymap.set( 'n', '<leader>TN', "<CMD>TexlabForward<CR>", { desc = 'TexlabForward' })
|
||||
vim.keymap.set( 'n', '<leader>TH', function() vim.cmd.TexlabBuild() end, { desc = 'TexlabBuild' })
|
||||
vim.keymap.set( 'n', '<leader>TD', function() vim.cmd.TexlabCancelBuild(); vim.cmd.TexlabCleanAuxiliary() end, { desc = 'TexlabCancelBuild+CleanAuxiliary' })
|
||||
vim.keymap.set( 'n', '<leader>Td', function() vim.cmd.TexlabCleanArtifacts() end, { desc = 'TexlabCleanArtifacts' })
|
||||
vim.keymap.set( 'n', '<leader>TN', function() vim.cmd.TexlabForward() end, { desc = 'TexlabForward' })
|
||||
end
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
39
config/plugins/lsp/servers/ts_ls.nix
Normal file
39
config/plugins/lsp/servers/ts_ls.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
plugins.lsp.servers = {
|
||||
ts_ls = {
|
||||
enable = false;
|
||||
filetypes = [
|
||||
"javascript"
|
||||
"javascriptreact"
|
||||
"typescript"
|
||||
"typescriptreact"
|
||||
];
|
||||
extraOptions = {
|
||||
settings = {
|
||||
javascript = {
|
||||
inlayHints = {
|
||||
includeInlayEnumMemberValueHints = true;
|
||||
includeInlayFunctionLikeReturnTypeHints = true;
|
||||
includeInlayFunctionParameterTypeHints = true;
|
||||
includeInlayParameterNameHints = "all";
|
||||
includeInlayParameterNameHintsWhenArgumentMatchesName = true;
|
||||
includeInlayPropertyDeclarationTypeHints = true;
|
||||
includeInlayVariableTypeHints = true;
|
||||
};
|
||||
};
|
||||
typescript = {
|
||||
inlayHints = {
|
||||
includeInlayEnumMemberValueHints = true;
|
||||
includeInlayFunctionLikeReturnTypeHints = true;
|
||||
includeInlayFunctionParameterTypeHints = true;
|
||||
includeInlayParameterNameHints = "all";
|
||||
includeInlayParameterNameHintsWhenArgumentMatchesName = true;
|
||||
includeInlayPropertyDeclarationTypeHints = true;
|
||||
includeInlayVariableTypeHints = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue