-
-
Notifications
You must be signed in to change notification settings - Fork 892
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
Improve session folder handling and added events for handling them #544
Conversation
I don't recommend advertising |
After this PR when you open a file which does not have corresponding language server it will print the following message(no errors): I will extend the readme section with: What do you think? |
More precisely: "You could either attach |
6733d74
to
564afb8
Compare
Fixes emacs-lsp#204 Requires: emacs-lsp/lsp-mode#544
Fixes emacs-lsp#204 Requires: emacs-lsp/lsp-mode#544
930f774
to
3c216c1
Compare
README.org
Outdated
Add the following line in your configuration file. | ||
#+BEGIN_SRC emacs-lisp | ||
(require 'lsp) | ||
(add-hook 'prog-mode-hook 'lsp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even a warning language server ... is not available for some mode
may be annoying for some people.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This option will be for initial configuration and targeted at beginners which are looking for zero configuration. Once you find the message irritating you can change it to work as you want(e. g. attach to the proper mode hook). Of course we may restructure the README based on the user feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beginners may not know what prog-mode-hook
is and this suggestion does not provide any convenience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
People choose language servers very conservatively, as the status quo tools are not necessarily worse than LSP counterparts.
README.org
Outdated
Add ~lsp~ server call to ~hack-local-variables-hook~ which runs right after the local variables are loaded. | ||
#+BEGIN_SRC emacs-lisp | ||
(add-hook 'hack-local-variables-hook | ||
(lambda () (when (derived-mode-p 'prog-mode) (lsp)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The prog-mode
example should be specific as I have mentioned that prog-mode
might not be a good example...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above.
lsp.el
Outdated
(defun lsp-message (format &rest args) | ||
"Wrapper over `message' which preserves the `eldoc-message'. | ||
FORMAT with ARGS are the original message formats." | ||
(-let ((inhibit-message lsp-inhibit-message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does plain let
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will change it.
(DEPRECATED_send-sync nil :read-only t) | ||
;; ‘add-on?’ when set to t this will indicate that the server can be started as | ||
;; a additional to another server. In case there are several | ||
(add-on? nil :read-only t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name and its associate comments are still obscure to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, the comment is not finished. When the server has add-on? = true this means that it will be started along the other servers for that mode. For example, spring-boot-language-server could run in parallel with jdt-ls. I am open for suggestions for better naming.
(put 'lsp-note 'flymake-category 'flymake-note) | ||
(put 'lsp-warning 'flymake-category 'flymake-warning) | ||
(put 'lsp-error 'flymake-category 'flymake-error) | ||
;; (put 'lsp-note 'flymake-category 'flymake-note) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/flymake.el#L81
A different symbol lsp-note
gives more flexibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but it does not work as I mentioned on Gitter - the Flymake modeline is displaying [0 0] with this change. I guess it is either a Flymake bug or Flymake misconfiguration but we need to figure it out before re-enabling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will recompile latest emacs and I will test on emacs 26.1
lsp.el
Outdated
@@ -1071,6 +1092,10 @@ If NO-WAIT is non-nil, don't synchronously wait for a response." | |||
(cl-defun lsp-request (method params &key no-wait) | |||
(lsp--send-request `(:jsonrpc "2.0" :method ,method :params ,params) no-wait)) | |||
|
|||
(defun lsp-request-async (method params callback &optional mode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mode
may be a good candidate for a keyword parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will be updated.
lsp.el
Outdated
lsp--eldoc-saved-hover-message nil) | ||
|
||
(let (signature-response hover-response) | ||
(if (lsp--capability "signatureHelpProvider") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By splitting signatureHelp and hover, the user can use lsp-eldoc-hook
to do:
- ignore signatureHelp
- use signatureHelp only in evil-insert-state
- other fancy stuff
That was why I added the hook.
signatureHelp may also be expensive to the server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with the current solution is that you should select one of signature or hover, but in the general case you want to see both which does not work without lsp-ui-doc. At this point you could disable whatever method you want by altering lsp-method-requirements
which will be generic way to disable certain feature, I havent yet added this to the docs VSCode works in similar way. We could also add generic method toggle feature off to make it more user friendly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But they can also provide their own callback, e.g.
(defun +my/hover-or-signature-help ()
(if (evil-insert-state-p)
(lsp-signature-help)
(lsp-hover)))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change the code to support this configuration.
cc6ac5f
to
346a61e
Compare
@MaskRay Pushed version based on offline discussion, please take look whether I have missed something. |
3a43580
to
5b589b9
Compare
- added `lsp-auto-require-clients` to remove the need to require lsp-clients. When set to t(default) it will autorequire lsp-clients. - `lsp` command ignores the clients which binary is not present. - `lsp` no longer throws an error when there is no client installed - `lsp` will ask which client to power on if there are multiple clients for a single mode present(also if their binary is available). This will happen each time you open a new file. In order to disable that you will have to remove the server that you do not want to run from `lsp-clients`. Later, when we solve emacs-lsp#405 we will be able to specify per project preferences like: ProjectA uses ccls, projectB uses clangd. - If you want your client to run in parallel with other server you will have to specify `:add-on?` = t when registering the client. - added 3 different message `lsp--info`, `lsp--warn` and `lsp--error` - cleanup - fixed support for tcp LANGUAGE server which apparently works only on Linux. ``` example registration (lsp-register-client (make-lsp-client :new-connection (lsp-tcp-connection (lambda (port) `("php" ,(expand-file-name "~/.composer/vendor/felixfbecker/language-server/bin/php-language-server.php") ,(format "--tcp-server=localhost:%s" port) "--memory-limit=4095M"))) :major-modes '(php-mode) :server-id 'php-ls)) ``` - Implemented signature handling in single method. Fixes emacs-lsp#214 - Changed eldoc message to display signature when it is present. - Replaced the message calls with lsp-message which preserves the eldoc message. At some point we may create separate buffer which will display the
- in some cases the lightner of flymake does not display the correct count
* use get_source_file * fix race condition in suggest specs Code lens request is handled asynchronously. If the file is closed and close notification handle_info executes before suggest_contracts handle_call the previous code added an entry to awaiting_contracts. That entry used URI of a closed file that would later lead to crash when handling analysis_ready Fixes elixir-lsp/vscode-elixir-ls#186
Fixes #512
added
lsp-auto-require-clients
to remove the need to require lsp-clients.When set to t(default) it will autorequire lsp-clients.
lsp
command ignores the clients which binary is not present.lsp
no longer throws an error when there is no client installedlsp
will ask which client to power on if there are multiple clients for asingle mode present(also if their binary is available). This will happen each
time you open a new file. In order to disable that you will have to remove the
server that you do not want to run from
lsp-clients
. Later, when we solveCan't configure lsp servers with file/directory local variables #405 we will be able to specify per project preferences like: ProjectA uses
ccls, projectB uses clangd.
If you want your client to run in parallel with other server you will have to
specify
:add-on?
= t when registering the client.added 3 different message
lsp--info
,lsp--warn
andlsp--error
cleanup
fixed support for tcp LANGUAGE server which apparently works only on Linux.