-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
lsp-mode with flycheck doesn't work. #9
Comments
Thanks, I added a repro and reported upstream: emacs-lsp/lsp-mode#1704 |
@jcs090218 looks like they closed it, see: emacs-lsp/lsp-mode#1704 (comment) I just played around with firing what's in the after-change in a timer, which works, but it makes more sense to do it as a post-command hook, I think. |
Here's what I got working, I had to disable the before change hook while the timer is running: (defvar auto-rename-tag--after-change-active nil)
(defun auto-rename-tag--before-change-functions (_begin _end)
"Do stuff before buffer is changed.
BEGIN : beginning of the changes.
END : end of the changes."
(unless auto-rename-tag--after-change-active
;; Reset record.
(setq auto-rename-tag--record-prev-word "")
;; Reset flag.
(setq auto-rename-tag--pre-command-actived nil)
(when (and (not undo-in-progress)
(auto-rename-tag--inside-tag-p)
(not (auto-rename-tag--self-tag-p)))
(save-excursion
;; Set active flag.
(setq auto-rename-tag--pre-command-actived t)
(setq auto-rename-tag--record-prev-word (auto-rename-tag--get-tag-name-at-point))
(when (string= auto-rename-tag--record-prev-word "/")
(setq auto-rename-tag--record-prev-word ""))
;; Ensure `auto-rename-tag--record-prev-word' is something other than nil.
(unless auto-rename-tag--record-prev-word
(setq auto-rename-tag--record-prev-word ""))))))
(defun auto-rename-tag--after-change-function (_begin _end _length)
"Do stuff after buffer is changed.
BEGIN : beginning of the changes.
END : end of the changes.
LENGTH : deletion length."
(when auto-rename-tag--pre-command-actived
(run-at-time 0 nil (lambda ()
(save-excursion
(let ((is-end-tag nil)
(current-word "") (pair-tag-word "")
(auto-rename-tag--after-change-active nil))
;; Goto the first character inside the tag.
(auto-rename-tag--goto-the-start-of-tag-name)
(setq is-end-tag (auto-rename-tag--is-closing-tag-p))
(setq current-word (auto-rename-tag--get-tag-name-at-point))
(unless (string= current-word auto-rename-tag--record-prev-word)
;; NOTE: Is closing tag.
(when is-end-tag
(auto-rename-tag--resolve-nested 'backward)
;; Get the tag name and ready to be compare.
(setq pair-tag-word (auto-rename-tag--get-tag-name-at-point))
;; Ensure `pair-tag-word' is something other than nil.
(unless pair-tag-word (setq pair-tag-word ""))
(when (string= auto-rename-tag--record-prev-word pair-tag-word)
;; Delete the pair word.
(unless (string= pair-tag-word "")
(auto-rename-tag--delete-tag-name))
;; Insert new word.
(insert current-word)))
;; NOTE: Is opening tag.
(unless is-end-tag
(auto-rename-tag--resolve-nested 'forward)
(setq is-end-tag (auto-rename-tag--is-closing-tag-p))
;; Get the tag name and ready to be compare.
(setq pair-tag-word (auto-rename-tag--get-tag-name-at-point))
;; Ensure `pair-tag-word' is something other than nil.
(unless pair-tag-word (setq pair-tag-word ""))
(when (string= auto-rename-tag--record-prev-word pair-tag-word)
;; Delete the pair word.
(unless (string= pair-tag-word "")
(auto-rename-tag--delete-tag-name))
;; Insert new word.
(insert current-word)))))))))) |
Interesting, not sure if there is more elegant way to solve this. Would you mind to make a PR? Cuz I can't really tell what changes and what doesn't. 😕 In my understanding, we have a |
Refer to #10. |
Okay, so |
Yeah, unfortunately this has the same problem. What was the issue you had with |
I think the tag wasn't update properly. If I tried delete the whole word, then it seems to be not working. But it will work when I modified by adding/deleting the character one by one. I haven't figure out the solution yet. 😕 |
Refer to #3 (comment)
The text was updated successfully, but these errors were encountered: