mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-02 08:22:22 +00:00
Merge from origin/emacs-29
b91f0ee2fc
; Fix last change2f69353e4a
Fix incompatibility with tree-sitter-javascript >= 0.20.2d49124fc14
Avoid signaling errors from 'pixel-fill-region'a398712761
eglot: Add nushell language server5f56bc1cdf
eglot: Add php-ts-mode to eglot-server-programsc14c978e3b
Support kotlin-ts-mode in Eglot
This commit is contained in:
commit
25bf8d3cdc
@ -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"))
|
||||
|
@ -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
|
||||
|
@ -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)))
|
||||
|
Loading…
Reference in New Issue
Block a user