How to complete words that contains special chars like `-` or `>`

Hi, I am experimenting kakoune with racket.

One problem troubles me, racket (and scheme) has a lot of functions that look like string->list or int->string.

However, the completion candidates disappear if I type beyond - or >.
How can I keep narrowing completion list that contains special chars like - or >?


I tried

set-option buffer extra_word_chars '>' '-'

but doesn’t work.

If you’re using Kakoune’s “scheme” plugin (i.e. :info %opt{filetype} displays “scheme”) then extra_word_chars should be set correctly:

If I launch Kakoune as kak test.scm (to create a buffer with the Scheme filetype), I can type string->list (one of the Scheme built-ins hard-coded into the Scheme plugin) and the completion works as expected. However, some of the completions mentioned in your screen-recording (like list->bytes) aren’t built-in to the scheme plugin, and there doesn’t appear to be a specific Racket plugin. Where do they come from?

1 Like

I removed all static_words and use completions from kak-lsp. The static_words and words from current file can do complete perfectly, but this is not the case for kak-lsp.

I suspect there is a bug somewhere, which may be:

  • on kak’s side that cannot handle extra_word_chars for other completion sources

  • on kak-lsp’s side that extra_word_chars got ignored, and will re-query completion without consider extra_word_chars

Sorry, i don’t know any further and my guess might be wrong.

My minimalist racket.kak(which is missing in current kak)

hook global BufCreate .*[.](rkt|rktd|rktl|rkts) %{
  set-option buffer filetype racket

hook global WinSetOption filetype=racket %{
  require-module racket

  set-option buffer extra_word_chars '!' '$' '%' '&' '*' '+' '-' '.' '/' ':' '<' '=' '>' '?' '@' '^' '_' '~'
  set-option buffer comment_line ';'
  set-option buffer comment_block_begin '#|'
  set-option buffer comment_block_end '|#'

  hook -once -always window WinSetOption filetype=.* %{ remove-hooks window racket-.+ }

hook -group racket-highlight global WinSetOption filetype=racket %{
  add-highlighter -override window/racket ref racket
  hook -once -always window WinSetOption filetype=.* %{
    remove-highlighter window/racket


# --------------------------------------------------------------------------------------------------- #
provide-module -override racket %§
add-highlighter -override shared/racket regions
add-highlighter -override shared/racket/code default-region group
add-highlighter -override shared/racket/comment       region ';' '$' fill comment
add-highlighter -override shared/racket/comment-form  region -recurse "\(" "#;\(" "\)" fill comment
add-highlighter -override shared/racket/comment-block region "#\|" "\|#" fill comment

Also try this plugin: Bitbucket

I suspect this is a bug in kak-lsp. Kakoune’s built-in completions all respect extra_word_chars, but for various reasons it’s awkward to support in plugins. Supporting only “traditional” C-style identifiers the 20% effort that provides 80% of the results, so I’d imagine most general-purpose plugins start there and only bother to support extra_word_chars once they become popular enough that somebody notices the omission.