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

Allow easier overriding of default filetypes for LSP #373

Merged
merged 1 commit into from
Jul 24, 2023
Merged

Allow easier overriding of default filetypes for LSP #373

merged 1 commit into from
Jul 24, 2023

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
@@ -424,12 +424,16 @@ end
--
-- Add any additional override configuration in the following tables. They will be passed to
-- the `settings` field of the server config. You must look up that documentation yourself.
--
-- If you want to override the default filetypes that your language server will attach too you can
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
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