aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/editorconfig.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-19 22:57:13 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-11-19 22:57:13 +0000
commit9be89f131f87608f224f0ee06d199fcd09d32176 (patch)
tree11022dcfa9e08cb4ac5581b16734196128688d48 /runtime/lua/editorconfig.lua
parentff7ed8f586589d620a806c3758fac4a47a8e7e15 (diff)
parent88085c2e80a7e3ac29aabb6b5420377eed99b8b6 (diff)
downloadrneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.gz
rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.bz2
rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'runtime/lua/editorconfig.lua')
-rw-r--r--runtime/lua/editorconfig.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/runtime/lua/editorconfig.lua b/runtime/lua/editorconfig.lua
index dcd7425c29..e65d267a70 100644
--- a/runtime/lua/editorconfig.lua
+++ b/runtime/lua/editorconfig.lua
@@ -190,6 +190,27 @@ function properties.insert_final_newline(bufnr, val)
end
end
+--- A code of the format ss or ss-TT, where ss is an ISO 639 language code and TT is an ISO 3166 territory identifier.
+--- Sets the 'spelllang' option.
+function properties.spelling_language(bufnr, val)
+ local error_msg =
+ 'spelling_language must be of the format ss or ss-TT, where ss is an ISO 639 language code and TT is an ISO 3166 territory identifier.'
+
+ assert(val:len() == 2 or val:len() == 5, error_msg)
+
+ local language_code = val:sub(1, 2):lower()
+ assert(language_code:match('%l%l'), error_msg)
+ if val:len() == 2 then
+ vim.bo[bufnr].spelllang = language_code
+ else
+ assert(val:sub(3, 3) == '-', error_msg)
+
+ local territory_code = val:sub(4, 5):lower()
+ assert(territory_code:match('%l%l'), error_msg)
+ vim.bo[bufnr].spelllang = language_code .. '_' .. territory_code
+ end
+end
+
--- @private
--- Modified version of [glob2regpat()] that does not match path separators on `*`.
---