Restructure kakoune configuration
This commit is contained in:
parent
801622b7be
commit
d5989c525c
5 changed files with 135 additions and 82 deletions
67
home/modules/programs/my-kakoune/default.nix
Normal file
67
home/modules/programs/my-kakoune/default.nix
Normal file
|
@ -0,0 +1,67 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.programs.my-kakoune;
|
||||
|
||||
autoloadModule = types.submodule {
|
||||
options = {
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
description = "Name of the autoload script/folder. It might affect kakoune's load order.";
|
||||
};
|
||||
src = mkOption {
|
||||
type = types.path;
|
||||
description = "Path to the autoload script/folder.";
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ ./kak-lsp.nix ];
|
||||
|
||||
options.programs.my-kakoune = {
|
||||
enable = mkEnableOption "My version of the kakoune configuration";
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.kakoune;
|
||||
description = "The kakoune package to be installed";
|
||||
};
|
||||
rc = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = "Content of the kakrc file. A line-concatenated string";
|
||||
};
|
||||
autoload = mkOption {
|
||||
type = types.listOf autoloadModule;
|
||||
default = [ ];
|
||||
description = "Sources to autoload";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
home.file =
|
||||
let
|
||||
kakouneAutoload = { name, src }: {
|
||||
name = "kakoune/autoload/${name}";
|
||||
value = {
|
||||
source = src;
|
||||
target = ".config/kak/autoload/${name}";
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
# kakrc
|
||||
".config/kak/kakrc".text = cfg.rc;
|
||||
} //
|
||||
(builtins.listToAttrs (map kakouneAutoload ([
|
||||
# include the original autoload files
|
||||
{
|
||||
name = "rc";
|
||||
src = "${cfg.package}/share/kak/autoload";
|
||||
}
|
||||
] ++ cfg.autoload)));
|
||||
};
|
||||
}
|
288
home/modules/programs/my-kakoune/kak-lsp.nix
Normal file
288
home/modules/programs/my-kakoune/kak-lsp.nix
Normal file
|
@ -0,0 +1,288 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
rev = "744a1981b8cf669a96e329bc255d31e0c2bdcb14";
|
||||
version = "r${builtins.substring 0 6 rev}";
|
||||
|
||||
kak-lsp = pkgs.kak-lsp.overrideAttrs (drv: rec {
|
||||
inherit rev version;
|
||||
buildInputs = drv.buildInputs ++
|
||||
(with pkgs; lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.SystemConfiguration);
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "kak-lsp";
|
||||
repo = "kak-lsp";
|
||||
rev = rev;
|
||||
sha256 = "sha256-eeONynT1oJafgJbfl8u/h4OJuORjropDrEUK0Raj8Jg=";
|
||||
# sha256 = lib.fakeSha256;
|
||||
};
|
||||
|
||||
cargoDeps = drv.cargoDeps.overrideAttrs (lib.const {
|
||||
inherit src;
|
||||
outputHash = "sha256-LqsCM4P6aJFZRGOxZtxXvSEbBSeQcC+4WbIwtlrO3e4=";
|
||||
# outputHash = lib.fakeSha256;
|
||||
});
|
||||
});
|
||||
|
||||
lspConfig =
|
||||
{
|
||||
language = {
|
||||
bash = {
|
||||
args = [ "start" ];
|
||||
command = "bash-language-server";
|
||||
filetypes = [ "sh" ];
|
||||
roots = [ ".git" ".hg" ];
|
||||
};
|
||||
c_cpp = {
|
||||
args = [ "-v=2" "-log-file=/tmp/ccls.log" ];
|
||||
command = "ccls";
|
||||
filetypes = [ "c" "cpp" ];
|
||||
roots = [ "compile_commands.json" ".cquery" ".git" ];
|
||||
};
|
||||
crystal = {
|
||||
command = "scry";
|
||||
filetypes = [ "crystal" ];
|
||||
roots = [ "shard.yml" ];
|
||||
};
|
||||
css = {
|
||||
args = [ "--stdio" ];
|
||||
command = "css-languageserver";
|
||||
filetypes = [ "css" ];
|
||||
roots = [ "package.json" ];
|
||||
};
|
||||
d = {
|
||||
command = "dls";
|
||||
filetypes = [ "d" "di" ];
|
||||
roots = [ ".git" "dub.sdl" "dub.json" ];
|
||||
};
|
||||
dart = {
|
||||
command = "dart_language_server";
|
||||
filetypes = [ "dart" ];
|
||||
roots = [ "pubspec.yaml" ".git" ];
|
||||
};
|
||||
elm = {
|
||||
args = [ "--stdio" ];
|
||||
command = "elm-language-server";
|
||||
filetypes = [ "elm" ];
|
||||
roots = [ "elm.json" ];
|
||||
};
|
||||
fsharp = {
|
||||
command = "FSharpLanguageServer";
|
||||
filetypes = [ "fsharp" ];
|
||||
roots = [ ".git" "*.fsx" ];
|
||||
};
|
||||
go = {
|
||||
command = "gopls";
|
||||
filetypes = [ "go" ];
|
||||
offset_encoding = "utf-8";
|
||||
roots = [ "Gopkg.toml" "go.mod" ".git" ".hg" ];
|
||||
settings = { gopls = { hoverKind = "SynopsisDocumentation"; semanticTokens = true; }; };
|
||||
settings_section = "gopls";
|
||||
};
|
||||
haskell = {
|
||||
args = [ "--lsp" ];
|
||||
command = "haskell-language-server-wrapper";
|
||||
filetypes = [ "haskell" ];
|
||||
roots = [ "Setup.hs" "stack.yaml" "*.cabal" "package.yaml" ];
|
||||
};
|
||||
html = {
|
||||
args = [ "--stdio" ];
|
||||
command = "html-languageserver";
|
||||
filetypes = [ "html" ];
|
||||
roots = [ "package.json" ];
|
||||
};
|
||||
javascript = {
|
||||
args = [ "lsp" ];
|
||||
command = "flow";
|
||||
filetypes = [ "javascript" ];
|
||||
roots = [ ".flowconfig" ];
|
||||
};
|
||||
json = {
|
||||
args = [ "--stdio" ];
|
||||
command = "json-languageserver";
|
||||
filetypes = [ "json" ];
|
||||
roots = [ "package.json" ];
|
||||
};
|
||||
latex = {
|
||||
command = "texlab";
|
||||
filetypes = [ "latex" ];
|
||||
roots = [ ".git" "main.tex" "all.tex" ];
|
||||
settings_section = "texlab";
|
||||
settings.texlab = {
|
||||
build.executable = "latexmk";
|
||||
build.args = [ "-pdf" "-shell-escape" "-interaction=nonstopmode" "-synctex=1" "%f" ];
|
||||
|
||||
build.forwardSearchAfter = true;
|
||||
build.onSave = true;
|
||||
|
||||
forwardSearch = {
|
||||
executable = "/Applications/Skim.app/Contents/SharedSupport/displayline";
|
||||
args = [ "-r" "-g" "%l" "%p" "%f" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
nim = {
|
||||
command = "nimlsp";
|
||||
filetypes = [ "nim" ];
|
||||
roots = [ "*.nimble" ".git" ];
|
||||
};
|
||||
nix = {
|
||||
command = "rnix-lsp";
|
||||
filetypes = [ "nix" ];
|
||||
roots = [ "flake.nix" "shell.nix" ".git" ];
|
||||
};
|
||||
ocaml = {
|
||||
args = [ ];
|
||||
command = "ocamllsp";
|
||||
filetypes = [ "ocaml" ];
|
||||
roots = [ "Makefile" "opam" "*.opam" "dune" ".merlin" ".ocamlformat" ];
|
||||
};
|
||||
php = {
|
||||
args = [ "--stdio" ];
|
||||
command = "intelephense";
|
||||
filetypes = [ "php" ];
|
||||
roots = [ ".htaccess" "composer.json" ];
|
||||
};
|
||||
python = {
|
||||
command = "pyls";
|
||||
filetypes = [ "python" ];
|
||||
offset_encoding = "utf-8";
|
||||
roots = [ "requirements.txt" "setup.py" ".git" ".hg" ];
|
||||
};
|
||||
racket = {
|
||||
args = [ "-l" "racket-langserver" ];
|
||||
command = "racket";
|
||||
filetypes = [ "racket" ];
|
||||
roots = [ ".git" ];
|
||||
};
|
||||
reason = {
|
||||
args = [ "--stdio" ];
|
||||
command = "ocaml-language-server";
|
||||
filetypes = [ "reason" ];
|
||||
roots = [ "package.json" "Makefile" ".git" ".hg" ];
|
||||
};
|
||||
ruby = {
|
||||
args = [ "stdio" ];
|
||||
command = "solargraph";
|
||||
filetypes = [ "ruby" ];
|
||||
roots = [ "Gemfile" ];
|
||||
};
|
||||
rust = {
|
||||
args = [ ];
|
||||
command = "rust-analyzer";
|
||||
filetypes = [ "rust" ];
|
||||
roots = [ "Cargo.toml" ];
|
||||
};
|
||||
};
|
||||
semantic_scopes = {
|
||||
entity_name_function = "function";
|
||||
entity_name_namespace = "module";
|
||||
entity_name_type = "type";
|
||||
variable = "variable";
|
||||
variable_other_enummember = "variable";
|
||||
};
|
||||
server = { timeout = 1800; };
|
||||
snippet_support = false;
|
||||
verbosity = 255;
|
||||
};
|
||||
|
||||
languageOption = types.submodule {
|
||||
options = {
|
||||
filetypes = mkOption {
|
||||
type = types.listOf types.str;
|
||||
description = "The list of filetypes to assign the language to";
|
||||
};
|
||||
roots = mkOption {
|
||||
type = types.listOf types.str;
|
||||
description = "The list of root filenames that are used to determine the project root";
|
||||
};
|
||||
command = mkOption {
|
||||
type = types.str;
|
||||
description = "The LSP server command to be called.";
|
||||
};
|
||||
args = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = "The arguments passed onto the LSP server.";
|
||||
};
|
||||
offset_encoding = mkOption {
|
||||
type = types.nullOr (types.enum [ "utf-8" ]);
|
||||
default = null;
|
||||
description = "The offset encoding used by the LSP server.";
|
||||
};
|
||||
settings_section = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "The settings section to be sent to LSP server.";
|
||||
};
|
||||
settings = mkOption {
|
||||
type = types.nullOr (types.attrsOf types.anything);
|
||||
default = null;
|
||||
description = "Additional settings to be passed to the LSP server.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
cfg = config.programs.kak-lsp;
|
||||
in
|
||||
{
|
||||
options.programs.kak-lsp = {
|
||||
enable = mkEnableOption "Enable kak-lsp support";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = kak-lsp;
|
||||
};
|
||||
|
||||
enableSnippets = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Enable snippet support";
|
||||
};
|
||||
|
||||
semanticScopes = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
default = lspConfig.semantic_scopes;
|
||||
description = "The semantic scopes mapping given to kak";
|
||||
};
|
||||
|
||||
serverTimeout = mkOption {
|
||||
type = types.int;
|
||||
default = 1000;
|
||||
description = "Server timeout";
|
||||
};
|
||||
|
||||
languages = mkOption {
|
||||
type = types.attrsOf languageOption;
|
||||
default = lspConfig.language;
|
||||
description = "The language options";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
# Configurations
|
||||
xdg.configFile."kak-lsp/kak-lsp.toml" = {
|
||||
source = pkgs.runCommand "config.toml"
|
||||
{
|
||||
buildInputs = [ pkgs.yj ];
|
||||
preferLocalBuild = true;
|
||||
} ''
|
||||
yj -jt -i \
|
||||
< ${
|
||||
pkgs.writeText "config.json" (builtins.toJSON {
|
||||
semantic_scopes = cfg.semanticScopes;
|
||||
server.timeout = cfg.serverTimeout;
|
||||
snippet_support = cfg.enableSnippets;
|
||||
verbosity = 255;
|
||||
language = cfg.languages;
|
||||
})
|
||||
} \
|
||||
> $out
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue