Adding Special Characters to iskeyword

Hello everyone,

I have a quick question I wanted to ask. I use neovim for programming in a few languages, the main ones being python3, common-lisp, and POSIX shell script. I often set iskeyword for these languages so I can get better auto-completion (granted I recently started using nvim-compe which doesn’t support iskeyword), but have run into an issue.

In common-lisp , can be used for classes and I would like to add it to iskeyword so I can complete classes faster, but whenever I try to it:

opt.iskeyword:append({ '-' , ',' })

I get an error about an incorrect argument being passed. Having read the help page for iskeyword, :h iskeyword, I know this must be because it is a comma separated list of characters. Is there anyway to add , to iskeyword?

As an aside, while I don’t do much C I often have to deep dive into it to manage different projects. Is there anyway to add -> to iskeyword to help with completing structs?

Thank you for your time.

Hello, I’m doing exactly what your are doing there and It’s working as expected, added to iskeyword but I’m running nightly. I do get an error when I set iskeyboard for the second time appending said items.

-- Run
vim.opt.iskeyword:append({'-', ','})

-- Output
  _info = {
    allows_duplicates = false,
    commalist = true,
    default = "@,48-57,_,192-255",
    flaglist = false,
    global_local = false,
    last_set_chan = 0,
    last_set_linenr = 0,
    last_set_sid = 0,
    name = "iskeyword",
    scope = "buf",
    shortname = "isk",
    type = "string",
    was_set = false
  _name = "iskeyword",
  _value = "@,48-57,_,192-255,-,,",
  <metatable> = <1>{
    __add = <function 1>,
    __index = <table 1>,
    __pow = <function 2>,
    __sub = <function 3>,
    _set = <function 4>,
    append = <function 5>,
    get = <function 6>,
    prepend = <function 7>,
    remove = <function 8>

-- Run
vim.opt.iskeyword:append({'-', ','})
-- Output
/usr/share/nvim/runtime/lua/vim/_meta.lua:180: E474: Invalid argument
stack traceback:
	[C]: in function 'nvim_buf_set_option'
	/usr/share/nvim/runtime/lua/vim/_meta.lua:180: in function 'set_scoped_option'
	/usr/share/nvim/runtime/lua/vim/_meta.lua:682: in function </usr/share/nvim/runtime/lua/vim/_meta.lua:680>

So my recommendations would be to first use the “after” directory :h after and create a file for the languages you want python3.lua there put your vim.opt.iskey.... but make sure the things you are appending aren’t already there by first calling vim.opt.iskeyword:get() and doing your custom logic (to avoid errors). Also would recommend to use vim.opt_local insteadof opt to set the variables local to a buffer that has the filetype you want to avoid messing up with everything else.

Use opt_local and change just a specific filetype, in the sh files for example the dollar symbol matters most than in lua.

-- Filename: /home/sergio/.config/nvim/after/ftplugin/sh.lua
-- Last Change: Thu, 16 Jun 2022 - 12:38