From a06faa9507edc541a1324295e063b66e7c96525b Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Thu, 20 Jan 2022 13:41:11 +0100 Subject: [PATCH] More latex stuff --- nvim/.config/nvim/fnl/dots/plugins.fnl | 4 +- nvim/.config/nvim/fnl/dots/plugins/cmp.fnl | 1 + nvim/.config/nvim/fnl/dots/plugins/lsp.fnl | 17 ++- .../.config/nvim/fnl/dots/plugins/ltex-ls.fnl | 141 ++++++++++++++++++ nvim/.config/nvim/fnl/dots/plugins/vimtex.fnl | 22 ++- xmonad/.xmonad/lib/Config.hs | 1 + zathura/.config/zathura/zathurarc | 9 ++ 7 files changed, 187 insertions(+), 8 deletions(-) create mode 100644 nvim/.config/nvim/fnl/dots/plugins/ltex-ls.fnl create mode 100644 zathura/.config/zathura/zathurarc diff --git a/nvim/.config/nvim/fnl/dots/plugins.fnl b/nvim/.config/nvim/fnl/dots/plugins.fnl index 08b73a6..be7b0a9 100644 --- a/nvim/.config/nvim/fnl/dots/plugins.fnl +++ b/nvim/.config/nvim/fnl/dots/plugins.fnl @@ -150,6 +150,7 @@ :hrsh7th/vim-vsnip-integ {} :rafamadriz/friendly-snippets {} + :hrsh7th/cmp-omni {} :hrsh7th/cmp-vsnip {} :hrsh7th/cmp-nvim-lsp {} :hrsh7th/cmp-buffer {} @@ -163,7 +164,8 @@ :hrsh7th/cmp-vsnip :hrsh7th/cmp-nvim-lua :hrsh7th/cmp-calc - :hrsh7th/cmp-path] + :hrsh7th/cmp-path + :hrsh7th/cmp-omni] :config #(require "dots.plugins.cmp")} ; >>> diff --git a/nvim/.config/nvim/fnl/dots/plugins/cmp.fnl b/nvim/.config/nvim/fnl/dots/plugins/cmp.fnl index e6ab994..d05112b 100644 --- a/nvim/.config/nvim/fnl/dots/plugins/cmp.fnl +++ b/nvim/.config/nvim/fnl/dots/plugins/cmp.fnl @@ -27,6 +27,7 @@ :sources [{:name "nvim_lsp" :priority 5} {:name "vsnip" :priority 3} + {:name "omni"} {:name "nvim_lua"} {:name "calc"} {:name "path"} diff --git a/nvim/.config/nvim/fnl/dots/plugins/lsp.fnl b/nvim/.config/nvim/fnl/dots/plugins/lsp.fnl index d0b2d8a..a885a40 100644 --- a/nvim/.config/nvim/fnl/dots/plugins/lsp.fnl +++ b/nvim/.config/nvim/fnl/dots/plugins/lsp.fnl @@ -8,6 +8,8 @@ require-macros [macros]}) +(require dots.plugins.ltex-ls) + ; TODO check https://github.com/neovim/nvim-lspconfig/blob/master/ADVANCED_README.md for default config for all of them (tset vim.lsp.handlers :textDocument/publishDiagnostics @@ -60,7 +62,7 @@ ((. lsp lsp-name :setup) merged-opts))) (init-lsp :jsonls {:commands {:Format [ #(vim.lsp.buf.range_formatting [] [0 0] [(vim.fn.line "$") 0])]}}) -(init-lsp :denols {:root_dir (better_root_pattern [".git"] ["package.json"])}) +;(init-lsp :denols {:root_dir (better_root_pattern [".git"] ["package.json"])}) (init-lsp :hls {:settings {:languageServerHaskell {:formattingProvider "stylish-haskell"}}}) (init-lsp :ocamllsp) (init-lsp :vimls) @@ -72,6 +74,11 @@ (init-lsp :svelte) (init-lsp :elmls) (init-lsp :texlab) +;(init-lsp :ltex {:settings {:ltex {:dictionary {:de-DE [":~/.config/ltex-ls/dictionary.txt"]} + ;:disabledRules {:de-DE [":~/.config/ltex-ls/disabledRules.txt"]} + ;:hiddenFalsePositives {:de-DE [":~/.config/ltex-ls/hiddenFalsePositives.txt"]} + ;:additionalRules {:motherTongue "de-DE"}}}}) + (init-lsp :powershell_es {:bundle_path "/home/leon/powershell"}) @@ -85,10 +92,10 @@ -((. (require "grammar-guard") :init)) -(init-lsp :grammar_guard {:cmd "~/.local/share/nvim/lsp_servers/ltex/ltex-ls/bin/ltex-ls" - :settings {:ltex {:language "de" - :enabled ["latex" "tex"]}}}) +;((. (require "grammar-guard") :init)) +;(init-lsp :grammar_guard {:cmd "~/.local/share/nvim/lsp_servers/ltex/ltex-ls/bin/ltex-ls" + ;:settings {:ltex {:enabled ["latex" "tex"] + ;:additionalRules {:motherTongue "de-DE"}}}}) diff --git a/nvim/.config/nvim/fnl/dots/plugins/ltex-ls.fnl b/nvim/.config/nvim/fnl/dots/plugins/ltex-ls.fnl new file mode 100644 index 0000000..fec6d40 --- /dev/null +++ b/nvim/.config/nvim/fnl/dots/plugins/ltex-ls.fnl @@ -0,0 +1,141 @@ +(module dots.plugins.ltex-ls + {autoload {a aniseed.core + str aniseed.string + lsp lspconfig + configs lspconfig/configs + lsputil lspconfig/util + utils dots.utils + cmp_nvim_lsp cmp_nvim_lsp}}) + + +(local Dictionary-file {:de-DE [(.. (vim.fn.getenv "HOME") "/.config/ltex-ls/dictionary.txt")]}) +(local Disabled-rules-file {:de-DE [(.. (vim.fn.getenv "HOME") "/.config/ltex-ls/disable.txt")]}) +(local False-positives-file {:de-DE [(.. (vim.fn.getenv "HOME") "/.config/ltex-ls/false.txt")]}) + +(fn read-files [files] + (let [dict {}] + (each [_ file (ipairs files)] + (local f (io.open file :r)) + (when (~= nil f) + (each [l (f:lines)] + (table.insert dict l)))) + dict)) + +(fn find-ltex-lang [] + (let [buf-clients (vim.lsp.buf_get_clients)] + (each [_ client (ipairs buf-clients)] + (when (= client.name :ltex) + (let [___antifnl_rtn_1___ client.config.settings.ltex.language] + (lua "return ___antifnl_rtn_1___")))))) + +(fn find-ltex-files [filetype value] + (if (= filetype :dictionary) + (. Dictionary-file (or value (find-ltex-lang))) + (= filetype :disable) + (. Disabled-rules-file (or value (find-ltex-lang))) + (= filetype :falsePositive) + (. False-positives-file (or value (find-ltex-lang))))) + +(fn update-config [lang configtype] + (let [buf-clients (vim.lsp.buf_get_clients)] + (var client nil) + (each [_ lsp (ipairs buf-clients)] + (when (= lsp.name :ltex) + (set client lsp))) + (if client + (if (= configtype :dictionary) + (if client.config.settings.ltex.dictionary + (do + (set client.config.settings.ltex.dictionary + {lang (read-files (. Dictionary-file lang))}) + (client.notify :workspace/didChangeConfiguration + client.config.settings)) + (vim.notify "Error when reading dictionary config, check it")) + (= configtype :disable) + (if client.config.settings.ltex.disabledRules + (do + (set client.config.settings.ltex.disabledRules + {lang (read-files (. Disabled-rules-file lang))}) + (client.notify :workspace/didChangeConfiguration + client.config.settings)) + (vim.notify "Error when reading disabledRules config, check it")) + (= configtype :falsePositive) + (if client.config.settings.ltex.hiddenFalsePositives + (do + (set client.config.settings.ltex.hiddenFalsePositives + {lang (read-files (. False-positives-file lang))}) + (client.notify :workspace/didChangeConfiguration + client.config.settings)) + (vim.notify "Error when reading hiddenFalsePositives config, check it"))) + nil))) + +(fn add-to-file [filetype lang file value] + (set-forcibly! file (io.open (. file (- (length file) 0)) :a+)) + (if file (do + (file:write (.. value "\n")) + (file:close)) + (let [___antifnl_rtns_1___ [(print "Failed insert %q" value)]] + (lua "return (table.unpack or _G.unpack)(___antifnl_rtns_1___)"))) + (if (= filetype :dictionary) (update-config lang :dictionary) + (= filetype :disable) (update-config lang :disable) + (= filetype :falsePositive) (update-config lang :disable))) + +(fn add-to [filetype lang file value] + (let [dict (read-files file)] + (each [_ v (ipairs dict)] + (when (= v value) + (lua "return nil"))) + (add-to-file filetype lang file value))) + +(set configs.ltex + {:default_config {:cmd [:ltex-ls] + :filetypes [:tex :bib :md] + :root_dir (fn [filename] (lsputil.path.dirname filename)) + :settings {:ltex {:enabled [:latex :tex :bib :md] + :language "de-DE" + :checkFrequency "save" + :diagnosticSeverity "information" + :setenceCacheSize 5000 + :additionalRules {:enablePickyRules true + :motherTongue "de-DE"} + :dictionary {:de-DE (read-files (. Dictionary-file :de-DE))} + :disabledRules {:de-DE (read-files (. Disabled-rules-file :de-DE))} + :hiddenFalsePositives {:de-DE (read-files (. False-positives-file :de-DE))}}}}}) + +(lsp.ltex.setup {:settings {:ltex {:enabled [:latex :tex :bib :md] + :language "de-DE" + :checkFrequency "save" + :diagnosticSeverity "information" + :setenceCacheSize 5000 + :additionalRules {:enablePickyRules true + :motherTongue "de-DE"} + :dictionary {:de-DE (read-files (. Dictionary-file :de-DE))} + :disabledRules {:de-DE (read-files (. Disabled-rules-file :de-DE))} + :hiddenFalsePositives {:de-DE (read-files (. False-positives-file :de-DE))}}}}) + +(set lsp.ltex.dictionary_file Dictionary-file) +(set lsp.ltex.disabledrules_file Disabled-rules-file) +(set lsp.ltex.falsepostivies_file False-positives-file) +(local orig-execute-command vim.lsp.buf.execute_command) + +(set vim.lsp.buf.execute_command + (fn [command] + (if (= command.command :_ltex.addToDictionary) + (let [arg (. (. command.arguments 1) :words)] + (each [lang words (pairs arg)] + (each [_ word (ipairs words)] + (local filetype :dictionary) + (add-to filetype lang (find-ltex-files filetype lang) word)))) + (= command.command :_ltex.disableRules) + (let [arg (. (. command.arguments 1) :ruleIds)] + (each [lang rules (pairs arg)] + (each [_ rule (ipairs rules)] + (local filetype :disable) + (add-to filetype lang (find-ltex-files filetype lang) rule)))) + (= command.command :_ltex.hideFalsePositives) + (let [arg (. (. command.arguments 1) :falsePositives)] + (each [lang rules (pairs arg)] + (each [_ rule (ipairs rules)] + (local filetype :falsePositive) + (add-to filetype lang (find-ltex-files filetype lang) rule)))) + (orig-execute-command command)))) diff --git a/nvim/.config/nvim/fnl/dots/plugins/vimtex.fnl b/nvim/.config/nvim/fnl/dots/plugins/vimtex.fnl index 350019c..6d88dee 100644 --- a/nvim/.config/nvim/fnl/dots/plugins/vimtex.fnl +++ b/nvim/.config/nvim/fnl/dots/plugins/vimtex.fnl @@ -4,8 +4,26 @@ ;(set vim.g.vimtex_quickfix_enabled 0) (set vim.g.vimtex_view_method "general") -(set vim.g.vimtex_view_general_viewer "okular") -(set vim.g.vimtex_view_general_options "--unique file:@pdf#src:@line@tex") +;(set vim.g.vimtex_view_general_viewer "okular") +(set vim.g.vimtex_view_general_viewer "zathura") +;(set vim.g.vimtex_view_general_options "--unique file:@pdf#src:@line@tex") +(set vim.g.vimtex_quickfix_method "pplatex") +(set vim.g.vimtex_quickfix_mode 2) +(set vim.g.vimtex_quickfix_open_on_warning 0) + +(set vim.g.vimtex_compiler_latexmk {:build_dir "" + :callback 1 + :continuous 1 + :executable "latexmk" + :hooks [] + :options ["-verbose" + "-file-line-error" + "-synctex=1" + "-interaction=nonstopmode" + "-shell-escape"]}) + +(set vim.g.vimtex_syntax_custom_cmds + [{:name "scripture" :argstyle "ital"}]) (set vim.g.vimtex_syntax_conceal {:accents 1 :cites 1 diff --git a/xmonad/.xmonad/lib/Config.hs b/xmonad/.xmonad/lib/Config.hs index 3bdcdcc..9529e1a 100644 --- a/xmonad/.xmonad/lib/Config.hs +++ b/xmonad/.xmonad/lib/Config.hs @@ -594,6 +594,7 @@ mySwallowEventHook = WindowSwallowing.swallowEventHook (not <$> foldl1 (<||>) [ className =* "eww" , className =? "Dragon" , className =? "okular" + , className =? "Zathura" , className =? "noswallow" ]) diff --git a/zathura/.config/zathura/zathurarc b/zathura/.config/zathura/zathurarc new file mode 100644 index 0000000..55c8c8b --- /dev/null +++ b/zathura/.config/zathura/zathurarc @@ -0,0 +1,9 @@ +set default-bg "#282828" +set recolor true +set recolor-lightcolor "#282828" +set recolor-darkcolor "#ebdbb2" +set recolor-keephue +set inputbar-bg "#1d2021" +set inputbar-fg "#ebdbb2" +set statusbar-bg "#1d2021" +set statusbar-fg "#ebdbb2"