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

Add support for Cabal configuration files #4419

Merged
merged 1 commit into from
Mar 2, 2019
Merged

Add support for Cabal configuration files #4419

merged 1 commit into from
Mar 2, 2019

Conversation

Alhadis
Copy link
Collaborator

@Alhadis Alhadis commented Feb 13, 2019

This PR adds support for Cabal config files, which are used to store metadata about Haskell projects (à la package.json in a JavaScript project).

Description

Lack of support for Cabal was brought to my attention by @phadej in haskell-CI/haskell-ci#223, when I was correcting the language of some misclassified files:

Technically they are Cabal configuration, so it's more like EDN or JSON than Clojure or JavaScript. I guess linguist doesn't know about Cabal files?

Syntax highlighting is already provided by our existing Haskell grammar.

Checklist:

  • I am adding a new language.
    • The extension of the new language is used in hundreds of repositories on GitHub.com.
    • I have included a real-world usage sample for all extensions added in this PR:

Footnotes

[1]cabal init output
λ linguist-sample: cabal init
-bash: cabal: command not found
λ linguist-sample: which cabal
λ linguist-sample: brew info $_
Error: No available formula with the name "cabal" 
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
λ linguist-sample: brew search $_
==> Formulae
cabal-install
λ linguist-sample: brew info cabal-install
cabal-install: stable 2.4.1.0 (bottled), HEAD
Command-line interface for Cabal and Hackage
https://www.haskell.org/cabal/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/cabal-install.rb
==> Dependencies
Required: ghc ✔
==> Options
--HEAD
        Install HEAD version
==> Analytics
install: 2,387 (30 days), 13,412 (90 days), 35,225 (365 days)
install_on_request: 972 (30 days), 4,476 (90 days), 14,917 (365 days)
build_error: 0 (30 days)
λ linguist-sample: brew install $_
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
No changes to formulae.

==> Downloading https://homebrew.bintray.com/bottles/cabal-install-2.4.1.0.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring cabal-install-2.4.1.0.high_sierra.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
🍺  /usr/local/Cellar/cabal-install/2.4.1.0: 7 files, 27.3MB
λ linguist-sample: cabal init
Config file path source is default config file.
Config file /Users/john/.cabal/config not found.
Writing default configuration to /Users/john/.cabal/config
Warning: Caught exception during _mirrors lookup:res_query: does not exist
(Connection refused)
Warning: No mirrors found for http://hackage.haskell.org/
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
Please choose version of the Cabal specification to use:
 * 1) 1.10   (legacy)
   2) 2.0    (+ support for Backpack, internal sub-libs, '^>=' operator)
   3) 2.2    (+ support for 'common', 'elif', redundant commas, SPDX)
   4) 2.4    (+ support for '**' globbing)
Your choice? [default: 1.10   (legacy)] 4
Package name? [default: linguist-sample] linguist-sample
Package version? [default: 0.1.0.0] v1.0.0
Couldn't parse v1.0.0, please try again!
Package version? [default: 0.1.0.0] 0.1.1.0 
Please choose a license:
   1) GPL-2.0-only
   2) GPL-3.0-only
   3) LGPL-2.1-only
   4) LGPL-3.0-only
   5) AGPL-3.0-only
   6) BSD-2-Clause
 * 7) BSD-3-Clause
   8) MIT
   9) ISC
  10) MPL-2.0
  11) Apache-2.0
  12) LicenseRef-PublicDomain
  13) NONE
  14) Other (specify)
Your choice? [default: BSD-3-Clause] 9
Author name? [default: Alhadis] 
Maintainer email? [default: gardnerjohng@gmail.com] 
Project homepage URL? https://github.com/github/linguist
Project synopsis? Example of a Cabal configuration file for GitHub Linguist
Project category:
 * 1) (none)
   2) Codec
   3) Concurrency
   4) Control
   5) Data
   6) Database
   7) Development
   8) Distribution
   9) Game
  10) Graphics
  11) Language
  12) Math
  13) Network
  14) Sound
  15) System
  16) Testing
  17) Text
  18) Web
  19) Other (specify)
Your choice? [default: (none)] 11
What does the package build:
   1) Library
   2) Executable
   3) Library and Executable
Your choice? 3
What is the main module of the executable:
 * 1) Main.hs (does not yet exist, but will be created)
   2) Main.lhs (does not yet exist, but will be created)
   3) Other (specify)
Your choice? [default: Main.hs (does not yet exist, but will be created)] 1
Source directory:
 * 1) (none)
   2) src
   3) Other (specify)
Your choice? [default: (none)] 2
What base language is the package written in:
 * 1) Haskell2010
   2) Haskell98
   3) Other (specify)
Your choice? [default: Haskell2010] 1
Add informative comments to each field in the cabal file (y/n)? [default: n] y

Guessing dependencies...

Generating LICENSE...
Generating Setup.hs...
Generating CHANGELOG.md...
Generating src/Main.hs...
Generating linguist-sample.cabal...

You may want to edit the .cabal file and add a Description field.
λ linguist-sample: 

@Alhadis
Copy link
Collaborator Author

Alhadis commented Feb 13, 2019

@pchaigno You might want to add cabal-ghcjs.project to the popularity monitoring list. There are currently 68 results (~40 unique users), and many of them are relatively recent — it might be worth adding this as a supported filename in future.

@phadej
Copy link

phadej commented Feb 13, 2019

You might want to add cabal-ghcjs.project to the popularity monitoring lis

people are quite free to have different project files, and the names are definitely not consistent.

e.g. I have used https://github.com/haskell-servant/servant/blob/master/cabal.ghcjs.project (note the dot, not a dash).

If linguist support prefix extensions cabal. or/and cabal-; it would cover more use cases. But I understand that our preference for prefix is quite peculiar, because the single *.cabal file in the directory has a special meaning, independent of the actual name,

@Alhadis
Copy link
Collaborator Author

Alhadis commented Feb 13, 2019

If linguist support prefix extensions cabal. or/and cabal-; it would cover more use cases.

Unfortunately, it doesn't. 😞 We're currently limited to matching complete filenames only (and only as fixed strings; e.g., no regex-aware matching). This is a known limitation of Linguist, I'm afraid.

people are quite free to have different project files, and the names are definitely not consistent.

Be that as it may, it's still worth keeping an eye on if over 40 users have used this particular filename to date. 👍

Alhadis added a commit to file-icons/atom that referenced this pull request Feb 14, 2019
Copy link
Contributor

@pchaigno pchaigno left a comment

Choose a reason for hiding this comment

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

LGTM!

@pchaigno
Copy link
Contributor

@pchaigno You might want to add cabal-ghcjs.project to the popularity monitoring list. There are currently 68 results (~40 unique users), and many of them are relatively recent — it might be worth adding this as a supported filename in future.

I'm tagging this PR as Pending Popularity to remember to add it to #4219.

@Alhadis Alhadis merged commit 6a22a41 into master Mar 2, 2019
@Alhadis Alhadis deleted the cabal branch March 2, 2019 05:41
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants