Skip to content

Don't use completions for cabal file codeactions #4357

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

Open
VeryMilkyJoe opened this issue Jul 11, 2024 · 6 comments
Open

Don't use completions for cabal file codeactions #4357

VeryMilkyJoe opened this issue Jul 11, 2024 · 6 comments
Labels
component: hls-cabal-plugin Issues related to the hls-cabal-plugin Hackathon This issue is suitable for hackathon sessions type: enhancement New feature or request

Comments

@VeryMilkyJoe
Copy link
Collaborator

VeryMilkyJoe commented Jul 11, 2024

At the moment, codeactions (PR: #3273) in cabal files put a cursor at the end of the misspelled word and then suggest any possible completions.
This is not ideal, since words that have a typo early on will not trigger the correct codeaction.
We should use a different algorithm for the fuzzy matching than completions to better support the semantics of the codeactions.

@VeryMilkyJoe VeryMilkyJoe added type: enhancement New feature or request status: needs triage component: hls-cabal-plugin Issues related to the hls-cabal-plugin labels Jul 11, 2024
@fendor fendor added Hackathon This issue is suitable for hackathon sessions and removed status: needs triage labels Aug 6, 2024
@JadarTheObscurity
Copy link

Hi! I’m very new to Haskell and to contributing to open source. I came across this issue and thought it would be a great opportunity to learn more about the ecosystem.

I’ve implemented a version of the Smith-Waterman algorithm for fuzzy matching under Text.Fuzzy.Parallel, and I’m interested in exploring how it could help improve code actions in cabal files, as suggested in this issue.

However, I’m not sure which part of the codebase is responsible for the in-editor highlighting of the matched string (as shown in the image below). Could someone point me to the relevant modules or files I should look into?

Since this is both my first time working with a functional language and contributing to a Haskell project, any advice or suggestions on how to approach this issue would be very much appreciated!

Image

@fendor
Copy link
Collaborator

fendor commented May 13, 2025

Hi, thank you for your interest!

However, I’m not sure which part of the codebase is responsible for the in-editor highlighting of the matched string (as shown in the image below). Could someone point me to the relevant modules or files I should look into?

I believe the highlighting is done automatically by VSCode, so it is not something you can control.
Or are you asking for the location where these strings are produced?

@JadarTheObscurity
Copy link

JadarTheObscurity commented May 13, 2025 via email

@fendor
Copy link
Collaborator

fendor commented May 13, 2025

This is the entry point for the completions https://github.com/haskell/haskell-language-server/blob/master/plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal.hs#L133 (which is what you see in the screenshot, which is not what this issue is about) and https://github.com/haskell/haskell-language-server/blob/master/plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal.hs#L135 is the entry point for code actions that correct typos in field names.

@JadarTheObscurity
Copy link

JadarTheObscurity commented May 13, 2025 via email

@fendor
Copy link
Collaborator

fendor commented May 13, 2025

The easiest way to debug is traceShowM and using the logger. You can enable DEBUG log messages by passing --debug to the serverExtraArgs in VSCode.

Another good way is to run a single test, for example cabal test hls-cabal-plugin-tests --test-options='-p "Code Actions - Can fix field names"' which runs the test here https://github.com/haskell/haskell-language-server/blob/master/plugins/hls-cabal-plugin/test/Main.hs#L189

That's often much faster than the manual testing. Same tips apply though, logging and trace* are the way to go to debug Haskell right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-cabal-plugin Issues related to the hls-cabal-plugin Hackathon This issue is suitable for hackathon sessions type: enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

3 participants