devShell:kakoune autocompile and forward search working

This commit is contained in:
Dennis Frieberg 2022-06-19 14:53:07 +02:00
parent 1e029c2f73
commit ba18e97277
2 changed files with 35 additions and 19 deletions

View file

@ -10,6 +10,8 @@
outputs = {self, nixpkgs} : outputs = {self, nixpkgs} :
let let
# name to be used as identifier for editor environments and such
name = "Name";
#Generate a user-friendly version number. #Generate a user-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate; version = builtins.substring 0 8 self.lastModifiedDate;
@ -22,6 +24,7 @@
# Nixpkgs instantiated for supported system types. # Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in { in {
packages = forAllSystems (system: packages = forAllSystems (system:
let let
@ -33,7 +36,7 @@
in { in {
default = pkgs.stdenvNoCC.mkDerivation { default = pkgs.stdenvNoCC.mkDerivation {
name = "output.pdf"; name = "output.pdf";
buildInputs = [latex latexrun]; buildInputs = [latex latexrun pkgs.biber];
src = self; src = self;
buildPhase = '' buildPhase = ''
latexrun -o output.pdf src/Main.tex latexrun -o output.pdf src/Main.tex
@ -48,19 +51,12 @@
devShells = forAllSystems (system: devShells = forAllSystems (system:
let let
pkgs = nixpkgsFor.${system}; pkgs = nixpkgsFor.${system};
# Needs to be in sync with latex dependencie above, Don't
# know how to fix this as we need to now the system to get
# the packages. The plus side is you can have different packages in your
# development environment than in your build one.
latexdeps = {inherit (pkgs.texlive) scheme-small;};
latex = pkgs.texlive.combine latexdeps;
latexrun = pkgs.latexrun;
in ( rec { in ( rec {
default = kakoune; default = kakoune;
kakoune = kakoune =
let let
texlab = pkgs.texlab; texlab = pkgs.texlab;
latexTmpDir = "src/latex.out/";
myKakoune = myKakoune =
let let
# this could also be done by generating toml with the # this could also be done by generating toml with the
@ -72,6 +68,18 @@
filetypes = ["latex"] filetypes = ["latex"]
roots = [".git"] roots = [".git"]
command = "texlab" command = "texlab"
# args = ["-vvvv", "--log-file", "/tmp/texlabLog"]
settings_section = "texlab"
[language.latex.settings.texlab.build]
onSave = true
executable = "latexrun"
args = ["--bibtex-cmd", "biber", "--latex-args", "'-synctex=1'","%f"]
forwardSearchAfter = true
[language.latex.settings.texlab.forwardSearch]
executable = "zathura"
args = ["--synctex-forward", "%l:1:%f", "%p"]
[language.latex.settings.texlab]
auxDirectory = "${latexTmpDir}"
''; '';
}; };
config = pkgs.writeTextFile (rec { config = pkgs.writeTextFile (rec {
@ -81,35 +89,43 @@
colorscheme solarized-dark colorscheme solarized-dark
set global tabstop 2 set global tabstop 2
set global indentwidth 2 set global indentwidth 2
# eval %sh{kak-lsp --kakoune --session $kak_session -c ${kak-lsp-config} --log /tmp/kak-lspLog -vvvv}
eval %sh{kak-lsp --kakoune --session $kak_session -c ${kak-lsp-config}} eval %sh{kak-lsp --kakoune --session $kak_session -c ${kak-lsp-config}}
hook global WinSetOption filetype=(latex) %{ hook global WinSetOption filetype=(latex) %{
lsp-auto-hover-enable lsp-auto-hover-enable
lsb-enable-window lsp-enable-window
} }
add-highlighter global/ number-lines
map global normal <c-p> ': fzf-mode<ret>'
''; '';
}); });
in in
pkgs.kakoune.override { pkgs.kakoune.override {
plugins = with pkgs.kakounePlugins; [kak-lsp config]; plugins = with pkgs.kakounePlugins; [fzf-kak kak-lsp config];
}; };
in in
pkgs.mkShellNoCC { pkgs.mkShellNoCC {
packages = [myKakoune texlab pkgs.git latex latexrun pkgs.zathura]; inputsFrom = [self.outputs.packages.${system}.default];
packages = [myKakoune texlab pkgs.git pkgs.zathura pkgs.fzf];
shellHook = '' shellHook = ''
alias ..="cd .." alias ..="cd .."
export KAKOUNE_CONFIG_DIR="/your/user/config/directory" mkdir -p ${latexTmpDir}
kak -d -s latexPackage & touch /tmp/texlabLog
alias vim="kak -c latexPackage" export KAKOUNE_CONFIG_DIR="/dev/null/"
kak -d -s ${name} &
alias vim="kak -c ${name}"
''; '';
}; };
texstudio = texstudio =
pkgs.mkShellNoCC { pkgs.mkShellNoCC {
packages = [pkgs.texstudio pkgs.git latex latexrun]; inputsFrom = [self.outputs.packages.${system}.default];
packages = [pkgs.texstudio pkgs.git];
}; };
texmaker = texmaker =
pkgs.mkShellNoCC { pkgs.mkShellNoCC {
packages = [pkgs.texmaker pkgs.git latex latexrun]; inputsFrom = [self.outputs.packages.${system}.default];
packages = [pkgs.texmaker pkgs.git];
}; };
}) })
); );

View file

@ -1,4 +1,4 @@
\documentclass{scrartcl} \documentclass{scrartcl}
\begin{document} \begin{document}
Hi Hallo Welt!
\end{document} \end{document}