Compare commits

...

13 Commits

Author SHA1 Message Date
sus-domesticus 5742a8fb2f
Merge af67eb275e into c18d7941ef 2024-05-09 18:25:19 +03:00
dundargoc c18d7941ef build: allow sccache as compiler cache
Also enable caching for dependencies.

Closes https://github.com/neovim/neovim/issues/28670
2024-05-09 16:39:45 +02:00
sus-domesticus af67eb275e test(editorconfig): change spelling_language properties
These were changed to use something other than the default values.
2024-05-07 13:12:43 +03:00
sus-domesticus ea85d651c1 test(editorconfig): check territory_code format 2024-05-07 12:24:55 +03:00
sus-domesticus 852bdda396 test(editorconfig): check spelling_language separator
A *GOOD* example of spelling_language is en-US. ('-' must be used as a
separator)

A *BAD* example of spelling_language is en/US or en_US.
2024-05-07 12:23:13 +03:00
sus-domesticus ff52025e8e test(editorconfig): add missing params 2024-05-07 12:07:13 +03:00
sus-domesticus 9963e85f93 test(editorconfig): use elseif not else and if 2024-05-07 11:51:15 +03:00
sus-domesticus 438593d7f3 test(editorconfig): handle opts with different scopes
The `test_case` method presumed that all options set by editorconfig
were *buffer-local* so it called `nvim_get_option_value` with `{ buf = 0
}` even for *window-local* options such as `spell`.

Now `nvim_get_option_info2` is used to get the scope of the option. This
scope can be: "global", "win" or "buf".
2024-05-07 11:36:04 +03:00
sus-domesticus 8372a48a35 chore: update news.txt 2024-05-07 09:59:44 +03:00
sus-domesticus 2a47a48d42 test(editorconfig): check spelling_language support 2024-05-07 09:59:25 +03:00
sus-domesticus dbf30e4cc7 style: use snake_case not camelCase 2024-05-04 18:43:27 +03:00
sus-domesticus 24fc129a80 docs(editorconfig): generate spelling_language docs 2024-05-04 11:43:57 +03:00
sus-domesticus 0df9d7ef1f feat(editorconfig): add spelling_language support 2024-05-04 11:43:57 +03:00
6 changed files with 59 additions and 7 deletions

View File

@ -50,11 +50,6 @@ file(GLOB DOCFILES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/runtime/doc/*.txt)
set_directory_properties(PROPERTIES
EP_PREFIX "${DEPS_BUILD_DIR}")
find_program(CCACHE_PRG ccache)
if(CCACHE_PRG)
set(CMAKE_C_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E env CCACHE_SLOPPINESS=pch_defines,time_macros ${CCACHE_PRG})
endif()
if(NOT CI_BUILD)
set(CMAKE_INSTALL_MESSAGE NEVER)
endif()

View File

@ -23,6 +23,12 @@ if(POLICY CMP0092)
list(APPEND DEPS_CMAKE_ARGS -D CMAKE_POLICY_DEFAULT_CMP0092=NEW)
endif()
find_program(CACHE_PRG NAMES ccache sccache)
if(CACHE_PRG)
set(CMAKE_C_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E env CCACHE_SLOPPINESS=pch_defines,time_macros ${CACHE_PRG})
list(APPEND DEPS_CMAKE_CACHE_ARGS -DCMAKE_C_COMPILER_LAUNCHER:STRING=${CMAKE_C_COMPILER_LAUNCHER})
endif()
# MAKE_PRG
if(UNIX)
find_program(MAKE_PRG NAMES gmake make)
@ -58,7 +64,8 @@ function(get_externalproject_options name DEPS_IGNORE_SHA)
set(EXTERNALPROJECT_OPTIONS
DOWNLOAD_NO_PROGRESS TRUE
EXTERNALPROJECT_OPTIONS URL ${${name_allcaps}_URL})
EXTERNALPROJECT_OPTIONS URL ${${name_allcaps}_URL}
CMAKE_CACHE_ARGS ${DEPS_CMAKE_CACHE_ARGS})
if(NOT ${DEPS_IGNORE_SHA})
list(APPEND EXTERNALPROJECT_OPTIONS URL_HASH SHA256=${${name_allcaps}_SHA256})

View File

@ -76,6 +76,11 @@ 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 'spell' and 'spelllang'
options.
tab_width *editorconfig.tab_width*
The display size of a single tab character. Sets the 'tabstop' option.

View File

@ -236,6 +236,9 @@ The following new APIs and features were added.
• Navigating the |jumplist| with CTRL+O, CTRL+I behaves more intuitively
when deleting buffers, and avoids "invalid buffer" cases. #25461
• Editorconfig
• spelling_language property is now supported.
• LSP
• LSP method names are available in |vim.lsp.protocol.Methods|.
• Implemented LSP inlay hints: |lsp-inlay_hint|

View File

@ -191,6 +191,29 @@ 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 'spell' and 'spelllang' options.
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
vim.o.spell = true
end
--- @private
--- Modified version of [glob2regpat()] that does not match path separators on `*`.
---

View File

@ -16,8 +16,16 @@ local testdir = 'Xtest-editorconfig'
local function test_case(name, expected)
local filename = testdir .. pathsep .. name
command('edit ' .. filename)
for opt, val in pairs(expected) do
eq(val, api.nvim_get_option_value(opt, { buf = 0 }), name)
local opt_info = api.nvim_get_option_info2(opt, {})
if opt_info.scope == 'win' then
eq(val, api.nvim_get_option_value(opt, { win = 0 }), name)
elseif opt_info.scope == 'buf' then
eq(val, api.nvim_get_option_value(opt, { buf = 0 }), name)
else
eq(val, api.nvim_get_option_value(opt, {}), name)
end
end
end
@ -93,6 +101,12 @@ setup(function()
[max_line_length.txt]
max_line_length = 42
[short_spelling_language.txt]
spelling_language = de
[long_spelling_language.txt]
spelling_language = en-NZ
]]
)
end)
@ -222,4 +236,9 @@ But not this one
eq(true, ok, err)
end)
it('sets spell, spelllang options', function()
test_case('short_spelling_language.txt', { spell = true, spelllang = 'de' })
test_case('long_spelling_language.txt', { spell = true, spelllang = 'en_nz' })
end)
end)