diff options
Diffstat (limited to 'dotfiles/vim')
-rw-r--r-- | dotfiles/vim/lua/vim-dev.lua | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/dotfiles/vim/lua/vim-dev.lua b/dotfiles/vim/lua/vim-dev.lua index ccbd923..9dc1e57 100644 --- a/dotfiles/vim/lua/vim-dev.lua +++ b/dotfiles/vim/lua/vim-dev.lua | |||
@@ -124,3 +124,63 @@ require("actions-preview").setup() | |||
124 | require("dapui").setup() | 124 | require("dapui").setup() |
125 | require("nvim-dap-virtual-text").setup() | 125 | require("nvim-dap-virtual-text").setup() |
126 | require('telescope').load_extension('dap') | 126 | require('telescope').load_extension('dap') |
127 | |||
128 | -- LTex | ||
129 | |||
130 | local function set_ltex_lang(lang) | ||
131 | local ltex = vim.lsp.get_active_clients({ name = "ltex" })[1] | ||
132 | if ltex == nil then | ||
133 | return | ||
134 | end | ||
135 | |||
136 | if lang == nil then | ||
137 | lang = vim.opt_local.spelllang:get()[1] | ||
138 | end | ||
139 | |||
140 | if lang == "en" then | ||
141 | lang = "en-US" | ||
142 | end | ||
143 | |||
144 | ltex.config.settings.ltex.language = lang | ||
145 | end | ||
146 | |||
147 | vim.api.nvim_create_user_command( | ||
148 | "LTeXSetLang", | ||
149 | function(opts) | ||
150 | local lang = opts.fargs[1] | ||
151 | set_ltex_lang(lang) | ||
152 | end, | ||
153 | { | ||
154 | nargs = 1, | ||
155 | complete = function() return { "en", "fr" } end, | ||
156 | } | ||
157 | ) | ||
158 | |||
159 | vim.api.nvim_create_autocmd("OptionSet", { | ||
160 | desc = "Set LTex language on spell change", | ||
161 | callback = function(ev) | ||
162 | if ev.match ~= "spelllang" then | ||
163 | return | ||
164 | end | ||
165 | set_ltex_lang() | ||
166 | end, | ||
167 | }) | ||
168 | |||
169 | vim.api.nvim_create_autocmd("LspAttach", { | ||
170 | desc = "Set LTex language on attach", | ||
171 | callback = function(ev) | ||
172 | local client = vim.lsp.get_client_by_id(ev.data.client_id) | ||
173 | if client.config.name ~= "ltex" then | ||
174 | return | ||
175 | end | ||
176 | set_ltex_lang() | ||
177 | end, | ||
178 | }) | ||
179 | |||
180 | -- TODO: implement custom client-side commands like: | ||
181 | -- | ||
182 | -- vim.lsp.commands["_ltex.addToDictionary"] = function(params) | ||
183 | -- print(vim.inspect(params)) | ||
184 | -- end | ||
185 | -- | ||
186 | -- See: https://valentjn.github.io/ltex/ltex-ls/server-usage.html#commands | ||