-
Notifications
You must be signed in to change notification settings - Fork 212
Known problem: accessing variables via meta accessors #69
Comments
Interestingly also using the other 2 methods ie with Maybe I am doing stuff completely wrong, but I also tried without |
If I understand correctly, I think there's a slight misunderstanding here: these are not links but different tags that point to the same section
I'm not sure the problem is related to Lua, it's hard to tell what's happening since I don't know where this code is being called. Is this from an autocommand? And there's a meaningful difference between the two snippets: |
Is this written in the neovim manual or in this guide that certain options are not available in all contexts? So there is neovim lua equivalent of |
No, I wanted to conditionally set options depending on the filetype/file extension in lua. |
I don't remember if it's documented in the manual off the top of my head, this is something I inferred from runtime/filetype.vim: the filetype for a buffer is set when the
I think for your particular use case it's better to create an vim.opt_local.shiftwidth = 4
vim.opt_local.tabstop = 4 |
[user@pc nvim]$ cat ftplugin/cpp.lua
vim.opt_local.shiftwidth = 4
vim.opt_local.tabstop = 4 did not work. Changing to When gets the folder |
When you set the filetype for a buffer IIRC. So opening a |
@matu3ba Have you found a solution to your problem? I created a |
I forgot to set symlinks for my dotfiles. -.-.
and how they work with the order of how neovim sets up things (load order of stuff)? |
Honest mistake :P
Hmm, I'm not sure I understand, what behavior specifically? If you mean runtime files, they're already well documented under |
when |
This is the closest Vimscript equivalent to the Lua snippet you posted I could come up with: if &l:filetype ==# 'cpp'
let &l:shiftwidth = 4
else
let &l:shiftwidth = 2
endif
if &l:filetype ==# 'cpp'
let &l:tabstop = 4
else
let &l:tabstop = 2
endif This should behave the same as your original Lua code so I'm not sure the behavior you describe is Lua-specific (unless I misunderstood) You're setting these options in your The usual mechanism for per-filetype configuration is either an autocommand ( |
Ok, I understand. Since this is not lua specific, but for per-project configurations a shortcoming: Closing. |
Is there a collection of "rough edges in neovim" that collects these kind of things? |
The user-manual contains a lot of useful information as well. |
:help lua-vim-options
showsand they are undocumented (dead links).
At least for me I have this issue that the filetype is set after everything is loaded, which makes
vim.bo.filetype
unusable to conditionally set options. see this issue.Using the metaaccessor
filetype
does not work, but it works withvimscript
:But
just works. I did not find yet lua methods to replace
expand
.The text was updated successfully, but these errors were encountered: