aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorsus-domesticus <134197728+sus-domesticus@users.noreply.github.com>2024-06-06 17:16:43 +0300
committerGitHub <noreply@github.com>2024-06-06 09:16:43 -0500
commitcb6c0fda718e4503fc1bfc49a9fe92411f5f9005 (patch)
tree8213be77050e788060517c2830ab772356618492 /runtime
parent972374f4e91dfbfa4a42202abc6e070dad6cdf02 (diff)
downloadrneovim-cb6c0fda718e4503fc1bfc49a9fe92411f5f9005.tar.gz
rneovim-cb6c0fda718e4503fc1bfc49a9fe92411f5f9005.tar.bz2
rneovim-cb6c0fda718e4503fc1bfc49a9fe92411f5f9005.zip
feat(editorconfig): add support for spelling_language (#28638)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/editorconfig.txt4
-rw-r--r--runtime/doc/news.txt3
-rw-r--r--runtime/lua/editorconfig.lua21
3 files changed, 27 insertions, 1 deletions
diff --git a/runtime/doc/editorconfig.txt b/runtime/doc/editorconfig.txt
index 0b20c77801..eef14ed51c 100644
--- a/runtime/doc/editorconfig.txt
+++ b/runtime/doc/editorconfig.txt
@@ -78,6 +78,10 @@ root *editorconfig.root*
directories. This property must be at the top-level of the `.editorconfig`
file (i.e. it must not be within a glob section).
+spelling_language *editorconfig.spelling_language*
+ 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.
+
tab_width *editorconfig.tab_width*
The display size of a single tab character. Sets the 'tabstop' option.
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 13e4b23ea1..2fed1b6b29 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -128,7 +128,8 @@ PERFORMANCE
PLUGINS
-• TODO
+• EditorConfig
+ • spelling_language property is now supported.
STARTUP
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 `*`.
---