[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 25bf8d3cdc6 4/4: Merge from origin/emacs-29
From: |
Eli Zaretskii |
Subject: |
master 25bf8d3cdc6 4/4: Merge from origin/emacs-29 |
Date: |
Sat, 3 Feb 2024 06:52:13 -0500 (EST) |
branch: master
commit 25bf8d3cdc6ce31e97b124a27be8c550d5525a55
Merge: 8080c7895b8 b91f0ee2fcc
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Merge from origin/emacs-29
b91f0ee2fcc ; Fix last change
2f69353e4a7 Fix incompatibility with tree-sitter-javascript >= 0.20.2
d49124fc14b Avoid signaling errors from 'pixel-fill-region'
a3987127618 eglot: Add nushell language server
5f56bc1cdfc eglot: Add php-ts-mode to eglot-server-programs
c14c978e3b1 Support kotlin-ts-mode in Eglot
---
lisp/progmodes/eglot.el | 5 ++--
lisp/progmodes/js.el | 27 ++++++++++++++----
lisp/textmodes/pixel-fill.el | 68 +++++++++++++++++++++++---------------------
3 files changed, 59 insertions(+), 41 deletions(-)
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index beba268f923..df8a287b4f2 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -243,7 +243,7 @@ automatically)."
(typescript-mode :language-id "typescript"))
. ("typescript-language-server" "--stdio"))
((bash-ts-mode sh-mode) .
("bash-language-server" "start"))
- ((php-mode phps-mode)
+ ((php-mode phps-mode php-ts-mode)
. ,(eglot-alternatives
'(("phpactor" "language-server")
("php"
"vendor/felixfbecker/language-server/bin/php-language-server.php"))))
@@ -259,7 +259,7 @@ automatically)."
. ("haskell-language-server-wrapper" "--lsp"))
(elm-mode . ("elm-language-server"))
(mint-mode . ("mint" "ls"))
- (kotlin-mode . ("kotlin-language-server"))
+ ((kotlin-mode kotlin-ts-mode) .
("kotlin-language-server"))
((go-mode go-dot-mod-mode go-dot-work-mode
go-ts-mode go-mod-ts-mode)
. ("gopls"))
((R-mode ess-r-mode) . ("R" "--slave" "-e"
@@ -284,6 +284,7 @@ automatically)."
((yaml-ts-mode yaml-mode) .
("yaml-language-server" "--stdio"))
(nix-mode . ,(eglot-alternatives '("nil"
"rnix-lsp" "nixd")))
(nickel-mode . ("nls"))
+ ((nushell-mode nushell-ts-mode) . ("nu"
"--lsp"))
(gdscript-mode . ("localhost" 6008))
((fortran-mode f90-mode) . ("fortls"))
(futhark-mode . ("futhark" "lsp"))
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 947d91c9b1a..ebc098e6a75 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3418,6 +3418,26 @@ This function is intended for use in
`after-change-functions'."
;;; Tree sitter integration
+(defun js--treesit-font-lock-compatibility-definition-feature ()
+ "Font lock helper, to handle different releases of tree-sitter-javascript.
+Check if a node type is available, then return the right font lock rules
+for \"definition\" feature."
+ (condition-case nil
+ (progn (treesit-query-capture 'javascript '((function_expression) @cap))
+ ;; Starting from version 0.20.2 of the grammar.
+ '((function_expression
+ name: (identifier) @font-lock-function-name-face)
+ (variable_declarator
+ name: (identifier) @font-lock-function-name-face
+ value: [(function_expression) (arrow_function)])))
+ (error
+ ;; An older version of the grammar.
+ '((function
+ name: (identifier) @font-lock-function-name-face)
+ (variable_declarator
+ name: (identifier) @font-lock-function-name-face
+ value: [(function) (arrow_function)])))))
+
(defun js-jsx--treesit-indent-compatibility-bb1f97b ()
"Indent rules helper, to handle different releases of tree-sitter-javascript.
Check if a node type is available, then return the right indent rules."
@@ -3529,8 +3549,7 @@ Check if a node type is available, then return the right
indent rules."
:language 'javascript
:feature 'definition
- '((function
- name: (identifier) @font-lock-function-name-face)
+ `(,@(js--treesit-font-lock-compatibility-definition-feature)
(class_declaration
name: (identifier) @font-lock-type-face)
@@ -3549,10 +3568,6 @@ Check if a node type is available, then return the right
indent rules."
(variable_declarator
name: (identifier) @font-lock-variable-name-face)
- (variable_declarator
- name: (identifier) @font-lock-function-name-face
- value: [(function) (arrow_function)])
-
(variable_declarator
name: [(array_pattern (identifier) @font-lock-variable-name-face)
(object_pattern
diff --git a/lisp/textmodes/pixel-fill.el b/lisp/textmodes/pixel-fill.el
index 25c0b46cee9..d26eaec2111 100644
--- a/lisp/textmodes/pixel-fill.el
+++ b/lisp/textmodes/pixel-fill.el
@@ -73,39 +73,41 @@ lines that are visually wider than PIXEL-WIDTH.
If START isn't at the start of a line, the horizontal position of
START, converted to pixel units, will be used as the indentation
prefix on subsequent lines."
- (save-excursion
- (goto-char start)
- (let ((indentation
- (car (window-text-pixel-size nil (line-beginning-position)
- (point))))
- (newline-end nil))
- (when (> indentation pixel-width)
- (error "The indentation (%s) is wider than the fill width (%s)"
- indentation pixel-width))
- (save-restriction
- (narrow-to-region start end)
- (goto-char (point-max))
- (when (looking-back "\n[ \t]*" (point-min))
- (setq newline-end t))
- (goto-char (point-min))
- ;; First replace all whitespace with space.
- (while (re-search-forward "[ \t\n]+" nil t)
- (cond
- ((or (= (match-beginning 0) start)
- (= (match-end 0) end))
- (delete-region (match-beginning 0) (match-end 0)))
- ;; If there's just a single space here, don't replace.
- ((not (and (= (- (match-end 0) (match-beginning 0)) 1)
- (= (char-after (match-beginning 0)) ?\s)))
- (replace-match
- ;; We need to use a space that has an appropriate width.
- (propertize " " 'face
- (get-text-property (match-beginning 0) 'face))))))
- (goto-char start)
- (pixel-fill--fill-line pixel-width indentation)
- (goto-char (point-max))
- (when newline-end
- (insert "\n"))))))
+ (save-window-excursion
+ (set-window-buffer nil (current-buffer))
+ (save-excursion
+ (goto-char start)
+ (let ((indentation
+ (car (window-text-pixel-size nil (line-beginning-position)
+ (point))))
+ (newline-end nil))
+ (when (> indentation pixel-width)
+ (error "The indentation (%s) is wider than the fill width (%s)"
+ indentation pixel-width))
+ (save-restriction
+ (narrow-to-region start end)
+ (goto-char (point-max))
+ (when (looking-back "\n[ \t]*" (point-min))
+ (setq newline-end t))
+ (goto-char (point-min))
+ ;; First replace all whitespace with space.
+ (while (re-search-forward "[ \t\n]+" nil t)
+ (cond
+ ((or (= (match-beginning 0) start)
+ (= (match-end 0) end))
+ (delete-region (match-beginning 0) (match-end 0)))
+ ;; If there's just a single space here, don't replace.
+ ((not (and (= (- (match-end 0) (match-beginning 0)) 1)
+ (= (char-after (match-beginning 0)) ?\s)))
+ (replace-match
+ ;; We need to use a space that has an appropriate width.
+ (propertize " " 'face
+ (get-text-property (match-beginning 0) 'face))))))
+ (goto-char start)
+ (pixel-fill--fill-line pixel-width indentation)
+ (goto-char (point-max))
+ (when newline-end
+ (insert "\n")))))))
(defun pixel-fill--goto-pixel (width)
(vertical-motion (cons (/ width (frame-char-width)) 0)))