Skip to content

Conversation

@Numkil
Copy link
Contributor

@Numkil Numkil commented Jul 24, 2023

Hi,

For some language servers it makes sense to override the default filetypes that they attach too. For example when editing a twig file it is nice to have the html language server attached to the buffer.

With this little addition to the setup_handlers function you can just put the filetypes configuration in the server configuration defined above and it will work. If you don't specify filetypes on your lsp config the value set will be nil and the default behavior will occur.

@feoh
Copy link
Collaborator

feoh commented Jul 24, 2023

This looks good to me, would you please add an example use case to the README under Configuration And Extension
?

Thanks a bunch!

init.lua Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry to be a pest, but you want 'attach to' not 'attach to' otherwise looks great!

@feoh
Copy link
Collaborator

feoh commented Jul 24, 2023

Hi I'm sorry but rather than correcting the spelling error you removed the docs entirely.

@Numkil
Copy link
Contributor Author

Numkil commented Jul 24, 2023

Hi @feoh Sorry its late in the evening for me and I accidentally rebased my PR on the wrong branch because i was not paying attention :) I fixed it now!

@feoh
Copy link
Collaborator

feoh commented Jul 24, 2023

No worries! Thanks for your patience and thanks for the contribution! I've actually got a couple use cases for this myself :)

@feoh feoh merged commit ea028fe into nvim-lua:master Jul 24, 2023
@Numkil Numkil deleted the patch-1 branch July 24, 2023 20:03
@feoh
Copy link
Collaborator

feoh commented Jul 25, 2023

Hi.

Unfortunately after laboriously merging down your PR into my fork, I discovered it breaks if you don't do any of these overrides. I now get:

Error detected while processing /Users/cpatti/.config/nvim/init.lua:
/Users/cpatti/.config/nvim/init.lua:467: attempt to index a nil value
/Users/cpatti/.config/nvim/init.lua:467: attempt to index a nil value
/Users/cpatti/.config/nvim/init.lua:467: attempt to index a nil value
/Users/cpatti/.config/nvim/init.lua:467: attempt to index a nil value

On startup, which isn't great :(

Unless you make a new PR with a fix in a few hours, I'll revert your commit this evening.

Thanks and apoligies to anyone who gets this broken kickstart. My bad for not testing it thoroughly outside my fork.

@feoh
Copy link
Collaborator

feoh commented Jul 25, 2023

I filed #375 to track this issue. Please resolve it with details if you make the fix, or I'll include reversion details if I end up doing that this evening.

qiuye2015 pushed a commit to qiuye2015/fjp.nvim that referenced this pull request Dec 10, 2023
Allow easier overriding of default filetypes for LSP
s-frick pushed a commit to s-frick/kickstart.nvim that referenced this pull request Jul 29, 2024
Allow easier overriding of default filetypes for LSP
melobern added a commit to melobern/kickstart.nvim that referenced this pull request Oct 30, 2024
Allow easier overriding of default filetypes for LSP
smrznuti1 pushed a commit to smrznuti1/nvc that referenced this pull request Dec 17, 2024
smrznuti1 pushed a commit to smrznuti1/nvc that referenced this pull request Dec 17, 2024
felixhummel added a commit to felixhummel/nvim that referenced this pull request Dec 19, 2024
Allow easier overriding of default filetypes for LSP
restray added a commit to restray/kickstart.nvim that referenced this pull request Mar 16, 2025
Allow easier overriding of default filetypes for LSP
invalidoperation pushed a commit to invalidoperation/kickstart.nvim that referenced this pull request Jun 14, 2025
Allow easier overriding of default filetypes for LSP
apriljarosz pushed a commit to apriljarosz/kickstart.nvim that referenced this pull request Jun 19, 2025
Allow easier overriding of default filetypes for LSP
eduardofuncao pushed a commit to eduardofuncao/config.nvim that referenced this pull request Aug 5, 2025
Allow easier overriding of default filetypes for LSP
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