fwcd / kotlin-language-server

Kotlin code completion, diagnostics and more for any editor/IDE using the Language Server Protocol
MIT License
1.58k stars 202 forks source link

Allow user specified exclusion patterns #574

Open stevenrchun opened 2 months ago

stevenrchun commented 2 months ago

Reads initialization options for additional patterns to exclude from source files.

https://github.com/fwcd/kotlin-language-server/pull/560 demonstrated that users need to be able to specify patterns to exclude and that hardcoding it forever probably wasn't sustainable. So this makes it configureable.

It seems to me the initialization options is the most natural place to do this (rather than the settings configuration, for example). Similar to adding workspace roots, the user provided exclusions are provided to SourceFiles at initialization time.

This probably merits updating the documentation, but since I'd also like to improve the neovim documentation anyway I'll probably do that in another PR (mainly, there's no documentation that you need to have a "kotlin" object under settings, since the configuration parser is tailored to the configuration response that VSCode gives).

For example, in my neovim init.lua I'd write

vim.lsp.start({
    name = "kotlin-language-server",
    cmd = {
        ...
    },
    filetypes = ....
    root_dir = ...
    init_options = {
        storagePath = ....,
        additionalSourceExclusions = { "new", "source", "exclusions*" },
    },
    settings = {
        kotlin = {
            scripts = {
                ...
            },
            completion = {
                ...
            },
        },
    },
})