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 credo-language-server support #4068

Merged
merged 6 commits into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
* Changelog
** Unreleased 8.0.1
* Add [[https://github.com/elixir-tools/credo-language-server][credo-language-server]]
* Add support for clojure-ts-mode in clojure-lsp client
* terraform-ls now supports prefill requied fields and the ability to validate on save.
* Ignore =.terraform= and =.terragrunt-cache= directories
Expand Down
97 changes: 97 additions & 0 deletions clients/lsp-credo.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
;;; lsp-credo.el --- lsp-mode Credo integration -*- lexical-binding: t; -*-

;; Copyright (C) 2023 Wilhelm H Kirschbaum

;; Author: Wilhelm H Kirschbaum
;; Keywords: lsp, elixir, credo

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; LSP Client for Elixir Credo

;;; Code:

(require 'lsp-mode)

(defgroup lsp-credo nil
"Settings for credo language server."
:group 'lsp-mode
:link '(url-link "https://github.com/elixir-tools/credo-language-server")
:package-version '(lsp-mode . "8.0.1"))

(defcustom lsp-credo-command '("credo-language-server" "--stdio=true")
"The command that starts credo-language-server."
:type '(repeat :tag "List of string values" string)
:group 'lsp-credo
:package-version '(lsp-mode . "8.0.1"))

(defcustom lsp-credo-version "0.1.2"
"Credo language server version to download.
It has to be set before `lsp-credo.el' is loaded and it has to
be available here: https://github.com/elixir-tools/credo-language-server/releases."
:type 'string
:group 'lsp-credo
:package-version '(lsp-mode . "8.0.1"))

(defcustom lsp-credo-download-url
(format (concat "https://github.com/elixir-tools/credo-language-server"

Choose a reason for hiding this comment

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

Will it be easier for you if i make sure the bin/credo-language-server script is always uploaded as an asset on the github release?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, i updated the PR to use the new release file structure.

"/releases/download/v%s/credo-language-server")
lsp-credo-version)
"Automatic download url for credo-language-server."
:type 'string
:group 'lsp-credo
:package-version '(lsp-mode . "8.0.1"))

(defcustom lsp-credo-binary-path
(f-join lsp-server-install-dir
"credo-language-server"
"credo-language-server")
"The path to `credo-language-server' binary."
:type 'file
:group 'lsp-credo
:package-version '(lsp-mode . "8.0.1"))

(lsp-dependency
'credo-language-server
`(:download :url lsp-credo-download-url
:store-path ,(f-join lsp-server-install-dir
"credo-language-server"
"credo-language-server")
:binary-path lsp-credo-binary-path
:set-executable? t))

(lsp-register-client
(make-lsp-client
:new-connection
(lsp-stdio-connection
(lambda ()
`(,(or (executable-find (cl-first lsp-credo-command))
(lsp-package-path 'credo-language-server))
,@(cl-rest lsp-credo-command))))
:activation-fn (lsp-activate-on "elixir")
:priority -1
:add-on? t
:multi-root nil
:server-id 'credo-language-server
:download-server-fn
(lambda (_client callback error-callback _update?)
(lsp-package-ensure 'credo-language-server callback error-callback))))

(lsp-consistency-check lsp-credo)

(provide 'lsp-credo)

;;; lsp-credo.el ends here
8 changes: 8 additions & 0 deletions docs/lsp-clients.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@
"lsp-install-server": "camells",
"debugger": "Not available"
},
{
"name": "credo",
"full-name": "Credo",
"server-name": "credo-ls",
"server-url": "https://github.com/elixir-tools/credo-language-server",
"installation-url": "https://github.com/elixir-tools/credo-language-server#installation",
"debugger": "Not available"
},
{
"name": "csharp-ls",
"common-group-name": "csharp",
Expand Down
4 changes: 3 additions & 1 deletion lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ As defined by the Language Server Protocol 3.16."

(defcustom lsp-client-packages
'( ccls lsp-actionscript lsp-ada lsp-angular lsp-ansible lsp-astro lsp-bash
lsp-beancount lsp-clangd lsp-clojure lsp-cmake lsp-crystal lsp-csharp lsp-css
lsp-beancount lsp-clangd lsp-clojure lsp-cmake lsp-credo lsp-crystal lsp-csharp lsp-css
lsp-d lsp-dart lsp-dhall lsp-docker lsp-dockerfile lsp-elm lsp-elixir lsp-emmet
lsp-erlang lsp-eslint lsp-fortran lsp-fsharp lsp-gdscript lsp-go lsp-gleam
lsp-glsl lsp-graphql lsp-hack lsp-grammarly lsp-groovy lsp-haskell lsp-haxe
Expand Down Expand Up @@ -400,6 +400,8 @@ the server has requested that."
"[/\\\\]_build\\'"
;; Elixir
"[/\\\\]\\.elixir_ls\\'"
;; Elixir Credo
"[/\\\\]\\.elixir-tools\\'"
;; terraform and terragrunt
"[/\\\\]\\.terraform\\'"
"[/\\\\]\\.terragrunt-cache\\'"
Expand Down