mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-11 07:55:31 +00:00
Added support for setting the g:tex_flavor option
This commit is contained in:
parent
5883c09366
commit
c191420912
1 changed files with 52 additions and 13 deletions
|
|
@ -11,7 +11,6 @@
|
||||||
# - completion
|
# - completion
|
||||||
# - inlayHints
|
# - inlayHints
|
||||||
# - experimental
|
# - experimental
|
||||||
|
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
|
@ -22,13 +21,20 @@ let
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types)
|
inherit (lib.types)
|
||||||
package
|
|
||||||
str
|
|
||||||
bool
|
bool
|
||||||
listOf
|
listOf
|
||||||
|
package
|
||||||
|
str
|
||||||
;
|
;
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
inherit (builtins) any attrValues;
|
inherit (builtins)
|
||||||
|
any
|
||||||
|
attrValues
|
||||||
|
concatStringsSep
|
||||||
|
length
|
||||||
|
map
|
||||||
|
toString
|
||||||
|
;
|
||||||
|
|
||||||
cfg = config.vim.languages.tex;
|
cfg = config.vim.languages.tex;
|
||||||
in
|
in
|
||||||
|
|
@ -204,7 +210,6 @@ in
|
||||||
- %l: The current line number.
|
- %l: The current line number.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extraLuaSettings = mkOption {
|
extraLuaSettings = mkOption {
|
||||||
|
|
@ -235,12 +240,49 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
# Add other LSPs here
|
# Add other LSPs here
|
||||||
|
};
|
||||||
|
|
||||||
|
extraOpts = {
|
||||||
|
texFlavor = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
example = true;
|
||||||
|
description = ''
|
||||||
|
Whether to set the vim.g.tex_flavor (g:tex_flavor) option in your lua config.
|
||||||
|
|
||||||
|
When opening a .tex file vim will try to automatically try to determine the file type from
|
||||||
|
the three options: plaintex (for plain TeX), context (for ConTeXt), or tex (for LaTeX).
|
||||||
|
This can either be done by a indicator line of the form `%&<format>` on the first line or
|
||||||
|
if absent vim will search the file for keywords to try and determine the filetype.
|
||||||
|
If no filetype can be determined automatically then by default it will fallback to plaintex.
|
||||||
|
|
||||||
|
This option will enable setting the tex flavor in your lua config and you can set its value
|
||||||
|
useing the `vim.languages.tex.lsp.extraOpts.texFlavor.flavor = <flavor>` in your nvf config.
|
||||||
|
|
||||||
|
Setting this option to `false` will omit the `vim.g.tex_flavor = <flavor>` line from your lua
|
||||||
|
config entirely (unless you manually set it elsewhere of course).
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
flavor = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "plaintex";
|
||||||
|
example = "tex";
|
||||||
|
description = ''
|
||||||
|
The flavor to set as a fallback for when vim cannot automatically determine the tex flavor when
|
||||||
|
opening a .tex document.
|
||||||
|
|
||||||
|
The options are: plaintex (for plain TeX), context (for ConTeXt), or tex (for LaTeX).
|
||||||
|
|
||||||
|
This can be particularly useful for when using `vim.utility.new-file-template` options for
|
||||||
|
creating templates when no context has yet been added to a new file.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
|
|
||||||
# Treesitter
|
# Treesitter
|
||||||
(mkIf cfg.treesitter.latex.enable {
|
(mkIf cfg.treesitter.latex.enable {
|
||||||
vim.treesitter.enable = true;
|
vim.treesitter.enable = true;
|
||||||
|
|
@ -257,16 +299,9 @@ in
|
||||||
vim.lsp.lspconfig.enable = true; # Enable lspconfig when any of the lsps are enabled
|
vim.lsp.lspconfig.enable = true; # Enable lspconfig when any of the lsps are enabled
|
||||||
}
|
}
|
||||||
// (mkMerge [
|
// (mkMerge [
|
||||||
|
|
||||||
# Texlab
|
# Texlab
|
||||||
(
|
(
|
||||||
let
|
let
|
||||||
inherit (builtins)
|
|
||||||
length
|
|
||||||
concatStringsSep
|
|
||||||
map
|
|
||||||
toString
|
|
||||||
;
|
|
||||||
tl = cfg.lsp.texlab;
|
tl = cfg.lsp.texlab;
|
||||||
build = tl.build;
|
build = tl.build;
|
||||||
|
|
||||||
|
|
@ -315,5 +350,9 @@ in
|
||||||
])
|
])
|
||||||
))
|
))
|
||||||
|
|
||||||
|
# Extra Lua config options
|
||||||
|
(mkIf cfg.extraOpts.texFlavor.enable {
|
||||||
|
vim.globals.tex_flavor = "${cfg.extraOpts.texFlavor.flavor}";
|
||||||
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue