-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Draft version of basic superbol-mode for GNU/Emacs
Also fix code for launching the LSP in VSCode platform
- Loading branch information
Showing
10 changed files
with
304 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,6 @@ ATTIC | |
!.vscode/launch.json | ||
*.vsix | ||
*.opam.locked | ||
/emacs/lsp-superbol-customs.el | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
;;; lsp-superbol.el --- Eglot LSP client for Superbol COBOL -*- lexical-binding: t; -*- | ||
;; | ||
;; Copyright (c) 2023 OCamlPro SAS | ||
;; | ||
;; All rights reserved. | ||
;; This source code is licensed under the MIT license found in the | ||
;; LICENSE.md file in the root directory of this source tree. | ||
|
||
;;; Commentary: | ||
|
||
;; Eglot LSP client for Superbol COBOL | ||
|
||
;;; Code: | ||
|
||
(unless (fboundp 'eglot) | ||
(load "eglot-autoloads")) | ||
|
||
(require 'eglot) | ||
(require 'superbol-mode) | ||
|
||
(defun eglot-superbol--start () | ||
"Superbol LSP startup function for Eglot" | ||
|
||
;; Actually start the LSP server | ||
(eglot-ensure) | ||
|
||
;; Turn on fontification (even if minimal) | ||
(funcall font-lock-fontify-buffer-function)) | ||
|
||
(add-to-list 'eglot-server-programs '(superbol-mode . ("superbol-free" "lsp"))) | ||
(add-to-list 'eglot-server-programs '(cobol-mode . ("superbol-free" "lsp"))) | ||
|
||
;; Autostart the LSP when entering superbol-mode | ||
(add-hook 'superbol-mode-hook #'eglot-superbol--start) | ||
|
||
;; Also load on cobol-mode | ||
(with-eval-after-load 'cobol-mode | ||
(add-hook 'cobol-mode-hook #'eglot-superbol--start)) | ||
|
||
(provide 'eglot-superbol) | ||
|
||
;;; eglot-superbol.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
;;; lsp-superbol.el --- lsp-mode LSP client for Superbol COBOL -*- lexical-binding: t; -*- | ||
;; | ||
;; Copyright (c) 2023 OCamlPro SAS | ||
;; | ||
;; All rights reserved. | ||
;; This source code is licensed under the MIT license found in the | ||
;; LICENSE.md file in the root directory of this source tree. | ||
|
||
;;; Commentary: | ||
|
||
;; lsp-mode.el LSP client for Superbol COBOL | ||
|
||
;;; Code: | ||
|
||
(unless (fboundp 'lsp-mode) | ||
(load "lsp-mode-autoloads")) | ||
|
||
(require 'lsp-mode) | ||
(require 'superbol-mode) | ||
|
||
;; --- | ||
|
||
(defgroup lsp-superbol nil | ||
"Settings for the Superbol Language Server for COBOL (lsp-mode)." | ||
:group 'lsp-mode | ||
:link '(url-link "https://github.com/OCamlPro/superbol-vscode-extension") | ||
:package-version '(lsp-mode . "8.0.1")) | ||
|
||
(load (expand-file-name "lsp-superbol-customs.el" | ||
(file-name-directory load-file-name))) | ||
|
||
;; --- | ||
|
||
(defun lsp-superbol--server-command () | ||
"Startup command for the Superbol LSP language server." | ||
;; (list (lsp-package-path 'superbol-language-server) "lsp")) | ||
(list (expand-file-name "superbol-free" lsp-superbol-path) "lsp")) | ||
|
||
;; (lsp-dependency 'superbol-language-server | ||
;; `(:system ,(executable-find (lsp-package-path 'superbol-language-server)))) | ||
;; '(:system "superbol-language-server")) | ||
|
||
(lsp-register-client | ||
(make-lsp-client | ||
:new-connection (lsp-stdio-connection #'lsp-superbol--server-command) | ||
:priority 0 | ||
:activation-fn (lsp-activate-on "superbol" "cobol" "COBOL") | ||
:server-id 'superbol-ls | ||
)) | ||
|
||
;; --- | ||
|
||
;; (with-eval-after-load 'superbol-mode | ||
(add-to-list 'lsp-language-id-configuration '(superbol-mode . "cobol")) | ||
(add-to-list 'lsp-language-id-configuration '(cobol-mode . "cobol")) | ||
|
||
(defun lsp-superbol--start () | ||
"Superbol LSP startup function for lsp-mode" | ||
|
||
;; Enable semantic tokens | ||
(set (make-local-variable 'lsp-semantic-tokens-enable) t) | ||
|
||
;; Actually start the LSP server | ||
(lsp) | ||
|
||
;; Turn on fontification | ||
(funcall font-lock-fontify-buffer-function)) | ||
|
||
;; Autostart the LSP when entering superbol-mode | ||
(add-hook 'superbol-mode-hook #'lsp-superbol--start) | ||
|
||
;; Also load on cobol-mode | ||
(with-eval-after-load 'cobol-mode | ||
(add-hook 'cobol-mode-hook #'lsp-superbol--start)) | ||
|
||
;; --- | ||
|
||
(lsp-consistency-check lsp-superbol) | ||
|
||
(provide 'lsp-superbol) | ||
|
||
;;; lsp-superbol.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
;;; superbol-mode.el --- Superbol COBOL major mode -*- lexical-binding: t; -*- | ||
;; | ||
;; Copyright (c) 2023 OCamlPro SAS | ||
;; | ||
;; All rights reserved. | ||
;; This source code is licensed under the MIT license found in the | ||
;; LICENSE.md file in the root directory of this source tree. | ||
|
||
;;; Commentary: | ||
|
||
;; Major mode for editing COBOL files using Superbol as a LSP server | ||
|
||
;;; Code: | ||
|
||
;; CHECKME: Force association right here? | ||
(defun superbol-mode-enable-for-default-extensions () | ||
"Automatically associate `superbol-mode` with a few common COBOL file | ||
extensions." | ||
(dolist (regex '("\\.[cC][oO][bB]\\'" | ||
"\\.[cC][bB][lL]\\'" | ||
"\\.[cC][pP][yY]\\'")) | ||
(add-to-list 'auto-mode-alist `(,regex . superbol-mode)))) | ||
|
||
;;;###autoload | ||
(define-derived-mode superbol-mode prog-mode | ||
"Superbol" | ||
"SUPERBOL mode is a major mode for handling COBOL files. It is mostly intended | ||
to be backed by an LSP." | ||
;; XXX: could actually derive from cobol-mode, if available. | ||
|
||
;; Straight from cobol-mode | ||
(set (make-local-variable 'comment-start-skip) | ||
"\\(^.\\{6\\}\\*\\|\\*>\\)\\s-* *") | ||
(set (make-local-variable 'comment-start) "*>") | ||
(set (make-local-variable 'comment-end) "")) | ||
|
||
;; --- | ||
|
||
(provide 'superbol-mode) | ||
;;; superbol-mode.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.