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

eglot sees the whole outer buffer content #331

Open
uqix opened this issue Dec 24, 2023 · 4 comments
Open

eglot sees the whole outer buffer content #331

uqix opened this issue Dec 24, 2023 · 4 comments

Comments

@uqix
Copy link

uqix commented Dec 24, 2023

image
  • Hostmode: yaml-ts-mode
  • Innermode: bash-ts-mode + eglot

As shown in the screenshot, ShellCheck/flymake gives warnings for yaml content as well.

@s-kostyaev
Copy link

Same problem with flymake, markdown and emacs lisp with both poly-markdown-mode and poly-gfm-mode without eglot.

@uqix
Copy link
Author

uqix commented Dec 26, 2023

As a workaround, I have to edit innermode content in another buffer by edit-indirect, here's my config:

(define-innermode poly-bash-innermode
  :mode 'bash-ts-mode
  :head-matcher "^ *#!/usr/bin/env \\(sh\\|bash\\)\n"
  :tail-matcher "^ *# </bash>$"
  :head-mode 'body
  :tail-mode 'body)

(define-hostmode poly-yaml-ts-hostmode
  :mode 'yaml-ts-mode)
(define-polymode poly-yaml-ts-mode
  :hostmode 'poly-yaml-ts-hostmode
  :innermodes '(poly-bash-innermode))
(add-hook 'yaml-ts-mode-hook 'poly-yaml-ts-mode)

(setq polymode-prefix-key (kbd "s-,"))

(defun my/polymode/edit-chunk ()
  (interactive)
  (call-interactively 'polymode-mark-or-extend-chunk)
  (call-interactively 'edit-indirect-region))
  
(define-key polymode-mode-map (kbd "s-, e") 'my/polymode/edit-chunk)          ; [e]dit by edit-indirect

;; eglot/lsp needs "workspace/file" view, so we set buffer-file-name to a fake path in the same dir as the visiting file
(defun edit-indirect-guess-mode (_parent-buffer _beg _end)
  (setq-local buffer-file-name (format "%s.-ei-" (buffer-file-name _parent-buffer)))
  (funcall (buffer-local-value 'major-mode _parent-buffer)))
(setq edit-indirect-guess-mode-function #'edit-indirect-guess-mode)

@unhammer
Copy link

I see people are using polymode with lsp-mode in #305 – is this an issue with polymode or with eglot?

@threddast
Copy link

I seem to have the same issue with lsp-mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants