Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try all parts of a compound filetype #59

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

taw10
Copy link
Contributor

@taw10 taw10 commented Mar 18, 2024

My Neovim setup uses a compound filetype such as scheme.guile, which is documented in :h 'filetype' as follows:

	|FileType| |filetypes|
	When a dot appears in the value then this separates two filetype
	names.  Example:
		/* vim: set filetype=c.doxygen : */
	This will use the "c" filetype first, then the "doxygen" filetype.
	This works both for filetype plugins and for syntax files.  More than
	one dot may appear.

This distinction is important, amongst other things, so that Conjure select the correct client for the particular dialect of Scheme. However, currently, nvim-paredit chokes on this, even though a valid configuration for scheme is available (I am using nvim-paredit-scheme), because get_language_api cannot find the right entry in langs. A nil value is returned, which trips up the other procedures like this:

E5108: Error executing lua ...ck/paqs/start/nvim-paredit/lua/nvim-paredit/api/wrap.lua:15: attempt to index local 'lang' (a nil value)                
stack traceback:
        ...ck/paqs/start/nvim-paredit/lua/nvim-paredit/api/wrap.lua:15: in function 'find_element_under_cursor'
        ...ck/paqs/start/nvim-paredit/lua/nvim-paredit/api/wrap.lua:65: in function 'wrap_element_under_cursor'
        /home/taw/dotfiles/config/nvim/init.lua:190: in function 'fn'
        ...tart/nvim-paredit/lua/nvim-paredit/utils/keybindings.lua:13: in function <...tart/nvim-paredit/lua/nvim-paredit/utils/keybindings.lua:12>

This change splits the filetype on ., and tries every component until it finds one with a valid configuration. For me, this fixes the problem and allows the scheme configuration to work with scheme.guile as the filetype.

Copy link
Owner

@julienvincent julienvincent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for the contribution!

@julienvincent julienvincent merged commit 844b032 into julienvincent:master Mar 19, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants