Account: VenInf on GitHub
The goal of my Google Summer of Code project was to introduce multiple features and changes to the Cabal Plugin of the Haskell Language Server (HLS for short).
Cabal is a system for building and packaging Haskell libraries and programs, and the Cabal Plugin helps users interact with it from a code editor. For example, it can correct a field in a cabal file, if it was written with typos in them, or even autocomplete it.
Originally I planned to add the following features:
Cabal-add
integration- Completion of local and non-local package names
- Prompt to add unknown modules to
exposed-modules
andother-modules
sections
We have decided to leave the last two points and focus on other possible features.
For example, the last feature entailed considerable complexity, and
to implement it, it will be necessary to add
functionality of adding modules to the Cabal-add
tool, since the task of adding
a new module without altering formatting is not trivial.
In the end, we have decided to focus our attention on the following tasks:
- Fix an issue with completion for shorter file names
- Add an outline view for cabal files
- Integrate the
Cabal-add
tool as a code action - Add a go-to definition for modules from
exposed-modules
andother-modules
sections - Add a hover with links to documentation for
build-depends
Everything is implemented, tested, reviewed, and merged (except for hover, which will be merged on the final day of the program). To see more about the implementation details or see what these additions do "in motion", feel free to follow the provided links above.
Some aspects of the solutions above aren't perfect due to lack of time or currently available tooling.
The current implementation of go-to definition returns the definition file without highlighting the name of the module. Since parsing the Haskell file will be necessary to find it, I have decided it will be clunky in the implementation, and the highlight is not strictly necessary. But if other contributors find this tradeoff unacceptable, it will be easy to add.
I think that my contribution opens up a lot of ways to improve the plugin further:
- documentation on hover can pick up the required version and provide the link to specific versions of a package
- documentation on hover for other parts like
default-extensions
,ghc-options
and others Cabal-add
can be integrated for other error messages like "missing module" (currently it works only on a "hidden module" error)