parent
303122dfc8
commit
11adcacd6f
35 changed files with 524 additions and 415 deletions
homeManagerModules/neovim/langs
49
homeManagerModules/neovim/langs/bash.nix
Normal file
49
homeManagerModules/neovim/langs/bash.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) getExe mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
in {
|
||||
programs = mkIf cfg.enable {
|
||||
# I love doing typos
|
||||
bash.shellAliases = {
|
||||
nivm = "nvim";
|
||||
nivim = "nvim";
|
||||
};
|
||||
|
||||
neovim = {
|
||||
defaultEditor = true;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
|
||||
extraPackages = mkIf cfg.enableIde [
|
||||
pkgs.nodePackages.bash-language-server
|
||||
pkgs.shellcheck
|
||||
];
|
||||
|
||||
extraLuaConfig =
|
||||
mkIf cfg.enableIde
|
||||
# lua
|
||||
''
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'sh',
|
||||
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
||||
});
|
||||
|
||||
require('lspconfig').bashls.setup({
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
|
||||
settings = {
|
||||
bashIde = {
|
||||
shellcheckPath = '${getExe pkgs.shellcheck}',
|
||||
},
|
||||
},
|
||||
});
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
53
homeManagerModules/neovim/langs/clang.nix
Normal file
53
homeManagerModules/neovim/langs/clang.nix
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
in
|
||||
mkIf cfg.enableIde {
|
||||
programs = {
|
||||
neovim = {
|
||||
extraPackages = builtins.attrValues {
|
||||
inherit
|
||||
(pkgs)
|
||||
gcc
|
||||
clang-tools
|
||||
cmake-language-server
|
||||
;
|
||||
};
|
||||
|
||||
extraLuaConfig =
|
||||
# lua
|
||||
''
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = { 'cpp' , 'c'},
|
||||
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
||||
});
|
||||
|
||||
local lsp = require('lspconfig');
|
||||
|
||||
lsp.cmake.setup({
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
});
|
||||
|
||||
lsp.clangd.setup({
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
|
||||
handlers = require('lsp-status').extensions.clangd.setup(),
|
||||
on_attach = function(_, bufnr)
|
||||
require("clangd_extensions.inlay_hints").setup_autocmd()
|
||||
require("clangd_extensions.inlay_hints").set_inlay_hints()
|
||||
end,
|
||||
});
|
||||
'';
|
||||
|
||||
plugins = builtins.attrValues {
|
||||
inherit (pkgs.vimPlugins) clangd_extensions-nvim;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
67
homeManagerModules/neovim/langs/csharp.nix
Normal file
67
homeManagerModules/neovim/langs/csharp.nix
Normal file
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
in
|
||||
mkIf cfg.enableIde {
|
||||
programs = {
|
||||
neovim = {
|
||||
extraPackages = builtins.attrValues {
|
||||
inherit
|
||||
(pkgs)
|
||||
omnisharp-roslyn
|
||||
;
|
||||
};
|
||||
|
||||
extraLuaConfig =
|
||||
# lua
|
||||
''
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = { 'cs' },
|
||||
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
||||
});
|
||||
|
||||
local omnisharp_extended = require('omnisharp_extended');
|
||||
|
||||
require('lspconfig').omnisharp.setup({
|
||||
cmd = { "dotnet", "${pkgs.omnisharp-roslyn}/lib/omnisharp-roslyn/OmniSharp.dll" },
|
||||
|
||||
handlers = {
|
||||
["textDocument/definition"] = omnisharp_extended.definition_handler,
|
||||
["textDocument/typeDefinition"] = omnisharp_extended.type_definition_handler,
|
||||
["textDocument/references"] = omnisharp_extended.references_handler,
|
||||
["textDocument/implementation"] = omnisharp_extended.implementation_handler,
|
||||
},
|
||||
|
||||
settings = {
|
||||
FormattingOptions = {
|
||||
EnableEditorConfigSupport = true,
|
||||
OrganizeImports = true,
|
||||
},
|
||||
MsBuild = {
|
||||
LoadProjectsOnDemand = false,
|
||||
},
|
||||
RoslynExtensionsOptions = {
|
||||
EnableAnalyzersSupport = true,
|
||||
EnableDecompilationSupport = true,
|
||||
EnableImportCompletion = true,
|
||||
AnalyzeOpenDocumentsOnly = false,
|
||||
},
|
||||
Sdk = {
|
||||
IncludePrereleases = true,
|
||||
},
|
||||
},
|
||||
});
|
||||
'';
|
||||
|
||||
plugins = builtins.attrValues {
|
||||
inherit (pkgs.vimPlugins) omnisharp-extended-lsp-nvim;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
98
homeManagerModules/neovim/langs/default.nix
Normal file
98
homeManagerModules/neovim/langs/default.nix
Normal file
|
@ -0,0 +1,98 @@
|
|||
self: {
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) fileContents mkBefore mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
in {
|
||||
imports = [
|
||||
./bash.nix
|
||||
./clang.nix
|
||||
./csharp.nix
|
||||
./hyprlang.nix
|
||||
./java.nix
|
||||
./json.nix
|
||||
./lua.nix
|
||||
./python.nix
|
||||
./rust.nix
|
||||
(import ./markdown.nix self)
|
||||
(import ./nix.nix self)
|
||||
(import ./web.nix self)
|
||||
];
|
||||
|
||||
config.programs = mkIf cfg.enableIde {
|
||||
neovim = {
|
||||
extraLuaConfig =
|
||||
mkBefore
|
||||
# lua
|
||||
''
|
||||
-- Add formatting cmd
|
||||
vim.api.nvim_create_user_command(
|
||||
'Format',
|
||||
function()
|
||||
vim.lsp.buf.format({ async = true });
|
||||
end,
|
||||
{}
|
||||
);
|
||||
|
||||
-- LSP-Status setup
|
||||
local lsp_status = require('lsp-status');
|
||||
lsp_status.register_progress();
|
||||
|
||||
-- Remove LSP highlighting to use Treesitter
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id);
|
||||
client.server_capabilities.semanticTokensProvider = nil;
|
||||
lsp_status.on_attach(client);
|
||||
end,
|
||||
});
|
||||
|
||||
-- Disable virtual_text since it's redundant due to lsp_lines.
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
});
|
||||
|
||||
require('lsp_lines').setup();
|
||||
'';
|
||||
|
||||
plugins =
|
||||
(builtins.attrValues {
|
||||
inherit
|
||||
(pkgs.vimPlugins)
|
||||
nvim-lspconfig
|
||||
lsp-status-nvim
|
||||
lsp_lines-nvim
|
||||
cmp-buffer
|
||||
cmp-nvim-lsp
|
||||
cmp-path
|
||||
cmp-spell
|
||||
vim-vsnip
|
||||
;
|
||||
})
|
||||
++ [
|
||||
{
|
||||
plugin = pkgs.vimPlugins.nvim-cmp;
|
||||
type = "lua";
|
||||
config = fileContents ../plugins/cmp.lua;
|
||||
}
|
||||
|
||||
{
|
||||
plugin = pkgs.vimPlugins.nvim-autopairs;
|
||||
type = "lua";
|
||||
config =
|
||||
# lua
|
||||
''
|
||||
require('nvim-autopairs').setup({});
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
# For accurate stack trace
|
||||
_file = ./default.nix;
|
||||
}
|
27
homeManagerModules/neovim/langs/hyprlang.nix
Normal file
27
homeManagerModules/neovim/langs/hyprlang.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
in
|
||||
mkIf cfg.enableIde {
|
||||
programs = {
|
||||
neovim = {
|
||||
extraLuaConfig =
|
||||
# lua
|
||||
''
|
||||
vim.filetype.add({
|
||||
pattern = { ['.*/hypr/.*%.conf'] = 'hyprlang' },
|
||||
});
|
||||
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'hyprlang',
|
||||
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
||||
});
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
84
homeManagerModules/neovim/langs/java.nix
Normal file
84
homeManagerModules/neovim/langs/java.nix
Normal file
|
@ -0,0 +1,84 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) getExe mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
|
||||
javaSdk = pkgs.temurin-bin-17;
|
||||
javaPkgs = builtins.attrValues {inherit (pkgs) gradle maven;};
|
||||
in
|
||||
mkIf cfg.enableIde {
|
||||
home.packages = javaPkgs;
|
||||
|
||||
xdg.dataFile.".gradle/gradle.properties".text = ''
|
||||
org.gradle.java.home = ${javaSdk}
|
||||
'';
|
||||
|
||||
programs = {
|
||||
java = {
|
||||
enable = true;
|
||||
package = javaSdk;
|
||||
};
|
||||
|
||||
neovim = {
|
||||
extraPackages = javaPkgs;
|
||||
|
||||
extraLuaConfig =
|
||||
# lua
|
||||
''
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'java',
|
||||
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
||||
});
|
||||
'';
|
||||
|
||||
plugins = [
|
||||
{
|
||||
# TOOD: setup debugger https://github.com/mfussenegger/nvim-jdtls#debugger-via-nvim-dap
|
||||
plugin = pkgs.vimPlugins.nvim-jdtls;
|
||||
type = "lua";
|
||||
config =
|
||||
# lua
|
||||
''
|
||||
--
|
||||
local startJdtls = function()
|
||||
local config = {
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
|
||||
cmd = { '${getExe pkgs.jdt-language-server}' },
|
||||
root_dir = vim.fs.dirname(vim.fs.find(
|
||||
{ 'gradlew', '.git', 'mvnw', 'pom.xml' },
|
||||
{ upward = true }
|
||||
)[1]),
|
||||
|
||||
settings = {
|
||||
java = {
|
||||
configuration = {
|
||||
runtimes = {
|
||||
{
|
||||
name = 'JavaSE-17',
|
||||
path = '${javaSdk}',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
require('jdtls').start_or_attach(config);
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'java',
|
||||
callback = startJdtls,
|
||||
});
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
56
homeManagerModules/neovim/langs/json.nix
Normal file
56
homeManagerModules/neovim/langs/json.nix
Normal file
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
in
|
||||
mkIf cfg.enableIde {
|
||||
programs = {
|
||||
neovim = {
|
||||
extraPackages = builtins.attrValues {
|
||||
inherit
|
||||
(pkgs)
|
||||
vscode-langservers-extracted
|
||||
yaml-language-server
|
||||
;
|
||||
};
|
||||
|
||||
extraLuaConfig =
|
||||
# lua
|
||||
''
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'yaml',
|
||||
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
||||
});
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'json',
|
||||
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
||||
});
|
||||
|
||||
local lsp = require('lspconfig');
|
||||
|
||||
lsp.jsonls.setup({
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
});
|
||||
|
||||
lsp.yamlls.setup({
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
|
||||
settings = {
|
||||
yaml = {
|
||||
schemas = {
|
||||
[
|
||||
"https://json.schemastore.org/github-workflow.json"
|
||||
] = "/.github/workflows/*",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
50
homeManagerModules/neovim/langs/lua.nix
Normal file
50
homeManagerModules/neovim/langs/lua.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
|
||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||
in
|
||||
mkIf cfg.enableIde {
|
||||
programs = {
|
||||
neovim = {
|
||||
extraPackages = builtins.attrValues {
|
||||
inherit (pkgs) lua-language-server;
|
||||
};
|
||||
|
||||
plugins = [
|
||||
{
|
||||
plugin = pkgs.vimPlugins.neodev-nvim;
|
||||
type = "lua";
|
||||
config =
|
||||
# lua
|
||||
''
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'lua',
|
||||
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
||||
});
|
||||
|
||||
-- IMPORTANT: make sure to setup neodev BEFORE lspconfig
|
||||
require("neodev").setup({
|
||||
override = function(root_dir, library)
|
||||
if root_dir:find('${flakeEnv}', 1, true) == 1 then
|
||||
library.enabled = true
|
||||
library.plugins = true
|
||||
end
|
||||
end,
|
||||
});
|
||||
|
||||
require('lspconfig').lua_ls.setup({
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
});
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
133
homeManagerModules/neovim/langs/markdown.nix
Normal file
133
homeManagerModules/neovim/langs/markdown.nix
Normal file
|
@ -0,0 +1,133 @@
|
|||
self: {
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
self,
|
||||
...
|
||||
}: let
|
||||
inherit (self.inputs) vimplugin-easytables-src;
|
||||
inherit (self.lib.${pkgs.system}) buildPlugin;
|
||||
|
||||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
in {
|
||||
config = mkIf cfg.enableIde {
|
||||
programs = {
|
||||
neovim = {
|
||||
extraPackages = builtins.attrValues {
|
||||
inherit
|
||||
(pkgs)
|
||||
pandoc
|
||||
texlab
|
||||
texliveFull
|
||||
rubber
|
||||
;
|
||||
};
|
||||
|
||||
extraLuaConfig =
|
||||
# lua
|
||||
''
|
||||
local lsp = require('lspconfig');
|
||||
|
||||
lsp.texlab.setup({
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
|
||||
settings = {
|
||||
texlab = {
|
||||
formatterLineLength = 100,
|
||||
latexFormatter = 'latexindent',
|
||||
latexindent = {
|
||||
modifyLineBreaks = false,
|
||||
["local"] = '.indentconfig.yaml';
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
'';
|
||||
|
||||
plugins = [
|
||||
{
|
||||
plugin = buildPlugin "easytables-nvim" vimplugin-easytables-src;
|
||||
type = "lua";
|
||||
config =
|
||||
# lua
|
||||
''
|
||||
require('easytables').setup();
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
plugin = pkgs.vimPlugins.knap;
|
||||
type = "lua";
|
||||
config =
|
||||
# lua
|
||||
''
|
||||
--
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'tex',
|
||||
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
||||
});
|
||||
|
||||
vim.g.knap_settings = {
|
||||
-- HTML
|
||||
htmloutputext = 'html',
|
||||
htmltohtml = 'none',
|
||||
htmltohtmlviewerlaunch = "",
|
||||
htmltohtmlviewerrefresh = 'none',
|
||||
|
||||
-- Markdown
|
||||
mdoutputext = 'html',
|
||||
markdownoutputext = 'html',
|
||||
|
||||
-- Markdown to PDF
|
||||
mdtopdf = 'pandoc %docroot% -o /tmp/%outputfile%',
|
||||
markdowntopdf = 'pandoc %docroot% -o /tmp/%outputfile%',
|
||||
mdtopdfviewerlaunch = 'sioyek /tmp/%outputfile%',
|
||||
markdowntopdfviewerlaunch = 'sioyek /tmp/%outputfile%',
|
||||
mdtopdfviewerrefresh = 'none',
|
||||
markdowntopdfviewerrefresh = "none",
|
||||
|
||||
-- Markdown to HTML
|
||||
mdtohtml = 'pandoc --standalone %docroot% -o /tmp/%outputfile%',
|
||||
markdowntohtml = 'pandoc --standalone %docroot% -o /tmp/%outputfile%',
|
||||
mdtohtmlviewerlaunch = 'firefox -new-window /tmp/%outputfile%',
|
||||
markdowntohtmlviewerlaunch = 'firefox -new-window /tmp/%outputfile%',
|
||||
mdtohtmlviewerrefresh = 'none',
|
||||
markdowntohtmlviewerrefresh = 'none',
|
||||
|
||||
-- LaTeX
|
||||
-- TODO: stop from polluting workspace
|
||||
};
|
||||
|
||||
-- F4 processes the document once, and refreshes the view
|
||||
vim.keymap.set({ 'n', 'v', 'i' }, '<F4>', function()
|
||||
require('knap').process_once();
|
||||
end);
|
||||
|
||||
-- F5 closes the viewer application, and
|
||||
-- allows settings to be reset
|
||||
vim.keymap.set({ 'n', 'v', 'i' }, '<F5>', function()
|
||||
require('knap').close_viewer();
|
||||
end);
|
||||
|
||||
-- F6 toggles the auto-processing on and off
|
||||
vim.keymap.set({ 'n', 'v', 'i' }, '<F6>', function()
|
||||
require('knap').toggle_autopreviewing();
|
||||
end);
|
||||
|
||||
-- F7 invokes a SyncTeX forward search, or similar,
|
||||
-- where appropriate
|
||||
vim.keymap.set({ 'n', 'v', 'i' }, '<F7>', function()
|
||||
require('knap').forward_jump();
|
||||
end);
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# For accurate stack trace
|
||||
_file = ./markdown.nix;
|
||||
}
|
80
homeManagerModules/neovim/langs/nix.nix
Normal file
80
homeManagerModules/neovim/langs/nix.nix
Normal file
|
@ -0,0 +1,80 @@
|
|||
self: {
|
||||
config,
|
||||
lib,
|
||||
osConfig,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) getExe hasPrefix mkIf removePrefix;
|
||||
inherit (osConfig.networking) hostName;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
|
||||
defaultFormatter = self.formatter.${pkgs.system};
|
||||
|
||||
nixdPkg = self.inputs.nixd.packages.${pkgs.system}.default;
|
||||
|
||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||
flakeDir = "${removePrefix "/home/${cfg.user}/" flakeEnv}";
|
||||
in {
|
||||
config = mkIf cfg.enableIde {
|
||||
assertions = [
|
||||
{
|
||||
assertion =
|
||||
cfg.enableIde
|
||||
&& hasPrefix "/home/${cfg.user}/" flakeEnv
|
||||
|| !cfg.enableIde;
|
||||
message = ''
|
||||
Your $FLAKE environment variable needs to point to a directory in
|
||||
the main users' home to use the neovim module.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
home.packages = [
|
||||
defaultFormatter
|
||||
nixdPkg
|
||||
];
|
||||
|
||||
# nixd by default kinda spams LspLog
|
||||
home.sessionVariables.NIXD_FLAGS = "-log=error";
|
||||
|
||||
xdg.dataFile."${flakeDir}/.nixd.json".text = builtins.toJSON {
|
||||
nixpkgs = {
|
||||
expr = "import (builtins.getFlake \"${flakeDir}\").inputs.nixpkgs {}";
|
||||
};
|
||||
options.nixos = {
|
||||
expr = "(builtins.getFlake \"${flakeDir}\").nixosConfigurations.${hostName}.options";
|
||||
};
|
||||
};
|
||||
|
||||
programs = {
|
||||
neovim = {
|
||||
extraPackages = [
|
||||
nixdPkg
|
||||
];
|
||||
|
||||
extraLuaConfig =
|
||||
# lua
|
||||
''
|
||||
require('lspconfig').nixd.setup({
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
|
||||
filetypes = { 'nix', 'in.nix' },
|
||||
settings = {
|
||||
nixd = {
|
||||
formatting = {
|
||||
-- TODO: Try to find <flake>.formatter
|
||||
command = { '${getExe defaultFormatter}' },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# For accurate stack trace
|
||||
_file = ./nix.nix;
|
||||
}
|
29
homeManagerModules/neovim/langs/python.nix
Normal file
29
homeManagerModules/neovim/langs/python.nix
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
in
|
||||
mkIf cfg.enableIde {
|
||||
programs = {
|
||||
neovim = {
|
||||
withPython3 = true;
|
||||
|
||||
extraPackages = [
|
||||
pkgs.basedpyright
|
||||
];
|
||||
|
||||
extraLuaConfig =
|
||||
# lua
|
||||
''
|
||||
require('lspconfig').basedpyright.setup({
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
});
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
38
homeManagerModules/neovim/langs/rust.nix
Normal file
38
homeManagerModules/neovim/langs/rust.nix
Normal file
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) attrValues mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
in
|
||||
mkIf cfg.enableIde {
|
||||
programs = {
|
||||
neovim = {
|
||||
extraPackages = attrValues {
|
||||
inherit
|
||||
(pkgs)
|
||||
cargo
|
||||
rustc
|
||||
rust-analyzer
|
||||
rustfmt
|
||||
;
|
||||
};
|
||||
|
||||
extraLuaConfig =
|
||||
# lua
|
||||
''
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = { 'rust' },
|
||||
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
||||
});
|
||||
|
||||
require('lspconfig').rust_analyzer.setup({
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
});
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
204
homeManagerModules/neovim/langs/web.nix
Normal file
204
homeManagerModules/neovim/langs/web.nix
Normal file
|
@ -0,0 +1,204 @@
|
|||
self: {
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (self.inputs) vimplugin-ts-error-translator-src;
|
||||
inherit (self.lib.${pkgs.system}) buildPlugin;
|
||||
|
||||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
in {
|
||||
config = mkIf cfg.enableIde {
|
||||
programs = {
|
||||
neovim = {
|
||||
withNodeJs = true;
|
||||
|
||||
extraPackages = builtins.attrValues {
|
||||
inherit
|
||||
(pkgs)
|
||||
nodejs_latest
|
||||
vscode-langservers-extracted
|
||||
;
|
||||
|
||||
inherit
|
||||
(pkgs.nodePackages)
|
||||
npm
|
||||
neovim
|
||||
;
|
||||
|
||||
inherit
|
||||
(self.packages.${pkgs.system})
|
||||
some-sass-language-server
|
||||
;
|
||||
};
|
||||
|
||||
extraLuaConfig =
|
||||
# lua
|
||||
''
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = { 'javascript', 'javascriptreact', 'javascript.jsx', 'typescript', 'typescriptreact', 'typescript.tsx', 'css', 'scss' },
|
||||
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
||||
});
|
||||
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'html',
|
||||
command = 'setlocal ts=4 sw=4 expandtab',
|
||||
});
|
||||
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'scss',
|
||||
command = 'setlocal iskeyword+=@-@',
|
||||
});
|
||||
|
||||
local lsp = require('lspconfig');
|
||||
local tsserver = require('typescript-tools');
|
||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
||||
|
||||
tsserver.setup({
|
||||
capabilities = default_capabilities,
|
||||
|
||||
handlers = {
|
||||
-- format error code with better error message
|
||||
['textDocument/publishDiagnostics'] = function(err, result, ctx, config)
|
||||
require('ts-error-translator').translate_diagnostics(err, result, ctx, config)
|
||||
vim.lsp.diagnostic.on_publish_diagnostics(err, result, ctx, config)
|
||||
end,
|
||||
},
|
||||
});
|
||||
|
||||
lsp.eslint.setup({
|
||||
capabilities = default_capabilities,
|
||||
|
||||
-- auto-save
|
||||
on_attach = function(client, bufnr)
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
buffer = bufnr,
|
||||
command = 'EslintFixAll',
|
||||
});
|
||||
end,
|
||||
|
||||
settings = {
|
||||
validate = 'on',
|
||||
packageManager = 'npm',
|
||||
useESLintClass = true,
|
||||
useFlatConfig = true,
|
||||
experimental = {
|
||||
useFlatConfig = true,
|
||||
},
|
||||
codeAction = {
|
||||
disableRuleComment = {
|
||||
enable = true,
|
||||
location = 'separateLine'
|
||||
},
|
||||
showDocumentation = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
codeActionOnSave = {
|
||||
mode = 'all',
|
||||
rules = {},
|
||||
},
|
||||
format = true,
|
||||
quiet = false,
|
||||
onIgnoredFiles = 'off',
|
||||
rulesCustomizations = {},
|
||||
run = 'onType',
|
||||
problems = {
|
||||
shortenToSingleLine = false,
|
||||
},
|
||||
nodePath = "",
|
||||
workingDirectory = {
|
||||
mode = 'location',
|
||||
},
|
||||
options = {
|
||||
flags = {'unstable_ts_config'},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
lsp.cssls.setup({
|
||||
capabilities = default_capabilities,
|
||||
|
||||
settings = {
|
||||
css = {
|
||||
validate = false,
|
||||
},
|
||||
less = {
|
||||
validate = false,
|
||||
},
|
||||
scss = {
|
||||
validate = false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
lsp.somesass_ls.setup({
|
||||
capabilities = default_capabilities,
|
||||
});
|
||||
lsp.somesass_ls.manager.config.settings = {
|
||||
somesass = {
|
||||
scss = {
|
||||
completion = {
|
||||
suggestFromUseOnly = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
local html_caps = default_capabilities;
|
||||
html_caps.textDocument.completion.completionItem.snippetSupport = true;
|
||||
|
||||
lsp.html.setup({
|
||||
capabilities = html_caps,
|
||||
settings = {
|
||||
configurationSection = { "html", "css", "javascript" },
|
||||
embeddedLanguages = {
|
||||
css = true,
|
||||
javascript = true,
|
||||
},
|
||||
provideFormatter = true,
|
||||
tabSize = 4,
|
||||
insertSpaces = true,
|
||||
indentEmptyLines = false,
|
||||
wrapAttributes = 'auto',
|
||||
wrapAttributesIndentSize = 4,
|
||||
endWithNewline = true,
|
||||
},
|
||||
});
|
||||
'';
|
||||
|
||||
plugins = [
|
||||
pkgs.vimPlugins.typescript-tools-nvim
|
||||
(buildPlugin "ts-error-translator" vimplugin-ts-error-translator-src)
|
||||
|
||||
{
|
||||
plugin = pkgs.vimPlugins.package-info-nvim;
|
||||
type = "lua";
|
||||
config =
|
||||
# lua
|
||||
''
|
||||
local packageInfo = require('package-info');
|
||||
packageInfo.setup({
|
||||
hide_up_to_date = true,
|
||||
package_manager = 'npm',
|
||||
});
|
||||
|
||||
vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
|
||||
pattern = { 'package.json' },
|
||||
callback = function()
|
||||
packageInfo.show({ force = true });
|
||||
end,
|
||||
});
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# For accurate stack trace
|
||||
_file = ./web.nix;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue