-
Notifications
You must be signed in to change notification settings - Fork 46
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
Integrate YCMD JSON settings #485
base: master
Are you sure you want to change the base?
Integrate YCMD JSON settings #485
Conversation
Add `ycmd-settings-json-filepath` - path to YCMD settings JSON file. YCMD accepts a json file where the server settings are set, including a one-time HMAC. The file is deleted after the server starts. As for now, emacs-ycmd was just creating a temporary file from some hard-coded/customizable values. Since those settings have to direct relation to emacs-ycmd, rather only to YCMD, it is good idea to keep it this way and just feed the file adding an HMAC value. That change will read the JSON file, insert HMAC and pass it to YCMD. Please, test it, feedback is appreciated, I will mainly test it on C/C++ and Go. That is supposed to solve abingham#472, abingham#479.
58885a6
to
ec50eed
Compare
ec50eed
to
3974850
Compare
(let ((hmac-secret (base64-encode-string hmac-secret)) | ||
(global-config (or ycmd-global-config "")) | ||
(extra-conf-whitelist (or ycmd-extra-conf-whitelist [])) | ||
(confirm-extra-conf (if (eq ycmd-extra-conf-handler 'load) 0 1)) |
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.
ycmd-extra-conf-handler
is used also in ycmd--handle-extra-conf-exception
so it needs to be saved from the json.
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 makes also a couple of defcustom
s redundant and need to be removed
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.
ycmd-extra-conf-handler
is used also inycmd--handle-extra-conf-exception
so it needs to be saved from the json.
I am not sure about that, because that is just how emacs-ycmd displays exceptions from ycmd. ycmd's option to confirm config is a little bit different, it is about does the server send this exceptions or not.
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.
Actually you are right. ycmd-extra-conf-handler
also has to be removed, also from the check in ycmd--handle-extra-conf-exception
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 do not have a strong opinion, but I find it ok to keep ycmd-extra-conf-handler
even, though it does overlap in behavior with the ycmd's option, it still has some neat behavior control over how emacs handles the exceptions, that someone might like. Ofc, it is not useful if the exceptions are totally disabled from the JSON settings, but I think it is fine.
ycmd.el
Outdated
@@ -130,6 +130,10 @@ | |||
"Path to global extra conf file." | |||
:type '(string)) | |||
|
|||
(defcustom ycmd-settings-json-filepath (concat (file-name-directory load-file-name) "ycmd_default_settings.json") |
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.
For this it's better to use the f.el
library and this (f-join (f-dirname (f-this-file)) "ycmd_default_settings.json")
because it handles also the cases when the file is loaded with eval-buffer
, rather than loaded from the init file.
f.el
is already used in company-ycmd
and needs only to be added to the required packages to the header.
Maybe we should keep the way we load settings and add loading from a json file as additional option, because this adds an extra step to setting up emacs-ycmd (which is already a pain point). Or we add a default json file to the repo. The setting should work out of the box. |
Actually, I intended to add the default settings file, but forgot to commit it. Thank you for the review. I will clean up the stuff you mentioned earlier. |
First of all, thanks for putting this together. I think this is a big step forward for emacs-ycmd. I do have some concerns about the design, though. My primary concern is that we've moved a lot of stuff that was under programmatic control and put it into a JSON file. For example, users used to be able to set As I mentioned in my comments in #479, I was hoping for a system that augmented the existing implementation rather than replacing it. I imagined that we would keep the original emacs-lisp-based system intact (i.e. As I see it, this approach has several benefits:
It's possible that the merging I mention is hard or impossible, in which case I'm happy to be corrected. But am I missing some benefits of the approach taken in this PR? |
The advantage of this is to not duplicate the functionality that is already done in ycmd. At the beginning there was no ycmd, there was ycm - vim plugin, all options of the server were in vim's config. Now, there is ycmd and they moved the options from vim to ycmd json file, likewise emacs-ycmd should not keep server options inside itself for many reasons. |
What reasons? I'm asking in all seriousness, because it's entirely possible that I'm missing an important point. As far as I can see, though, with your approach we still have to maintain and ship a JSON file with all of the ycmd configuration options in there, so we haven't gained any freedom from needing to know that information. Given that we have to know what goes in that file, I don't see how putting it in a JSON file is better than keeping it in emacs-lisp. On other hand, I think there are practical benefits to keeping it in emacs-lisp (though perhaps minor ones, as you say).
As long as we have to maintain a JSON file containing all of the options with their default values, we are still dependent on them. Now, if we could get the ycmd server to generate a default configuration for us on demand (i.e. so that we didn't have to know anything about it), that would be a different story. As it is, though, we've just moved the location of a dependency from one place to another, while degrading actual and potential functionality. I guess I'm struggling to see how the new JSON file you're proposing is any better than keeping identical information in emacs-lisp. Either we need to know that information or we don't. |
ycmd ships this default file. In this revision we added it only to avoid breaking changes, or reduce them to minimum, with the current version of emacs-ycmd. In the future we might post a fat comment in the readme, to draw people attention to switch to ycmd config. Also it is possible to provide an option to set a path to ycmd. This path will be used for two things: json config and ycmd command, with this you do not need to ship the options (and the side improvement would be to set a default command prefix to
If you take into account what I said above, this means that you do not need to know this information. As I said in the comments above it has no relevance to emacs-ycmd itself, it is only relevant to ycmd. |
I guess this is where we differ. I'm strongly opposed to requiring people to have a ycmd config, esp. as we've already demonstrated that we can provide one for them. I think it's part of our job to make using ycmd as painless as possible, while at the same time giving them the flexibility to configure it as much as they want to. A lot of users - myself included - will never have a need to know about these configuration files, and I think that we're doing them a service by not forcing them to.
I'm sorry, but this is nonsense. emacs-ycmd only exists to make ycmd accessible to emacs users. To say that the details of ycmd aren't "relevant" to emacs-ycmd is some sort of software engineering fundamentalism. |
Relax, it is just 50 line pull request, no reasons to get that emotional. |
You're right, and I apologize. I was in a pretty bad mood when I wrote
that, and you got the short end of it.
My technical objections to the direction you're taking still stand, though.
We shouldn't worry too much about dependencies on ycmd; depending on it is
the whole point of emacs-ycmd, in a sense. And I want to keep the barrier
of entry for users as low as possible, so requiring them to create a JSON
config just to get completion for Python or something feels like a
non-starter.
The scenario I typically consider is someone who wants to try emacs, so
they've downloaded spacemacs. They're already in an unfamiliar and perhaps
uncomfortable space, and I don't want to increase their chances of
abandoning the endeavour because emacs-ycmd adds too much cognitive load.
…On Fri, Oct 19, 2018 at 4:33 PM Yuki ***@***.***> wrote:
this is nonsense
software engineering fundamentalism.
Relax, it is just 50 line pull request.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#485 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAE1eHRJivJInMyxmR05vQOyviMdrIqUks5umeLTgaJpZM4XtRD2>
.
|
Add
ycmd-settings-json-filepath
- path to YCMD settings JSON file.YCMD accepts a json file where the server settings are set, including
a one-time HMAC. The file is deleted after the server starts.
As for now, emacs-ycmd was just creating a temporary file from
some hard-coded/customizable values.
Since those settings have to direct relation to emacs-ycmd, rather
only to YCMD, it is good idea to keep it this way and just feed the
file adding an HMAC value.
That change will read the JSON file, insert HMAC and pass it to YCMD.
Please, test it, feedback is appreciated, I will mainly test it on
C/C++ and Go.
That is supposed to solve #472, #479.
I copied
ycmd/default_settings.json
to my .emacs. and use it