-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add support for local language configuration #1249
Conversation
e5eefae
to
d34a7d9
Compare
390792c
to
c5682a0
Compare
Tested and seems to work. |
4460580
to
19a3ca1
Compare
It works for me. I added a new Also, could it be discussed to have a window to show LSP loaded parameters? |
The merging behavior is on a per-key basis: if you want to turn LSP auto-format off for rust for example, you can have a [[language]]
name = "rust"
auto-format = false And that will override that key but not change other keys like |
I tested on:
With:
[[language]]
name = "rust"
auto-format = false
comment-token = "//"
indent = { tab-width = 4, unit = " " }
[[language]]
name = "rust"
comment-token = "#"
indent = { tab-width = 4, unit = " " }
[[language]]
name = "rust"
indent = { tab-width = 2, unit = " " } correctly becoming [[language]]
auto-format = false
comment-token = "#"
file-types = ["rs", "rs"]
injection-regex = "rust"
name = "rust"
roots = ["Cargo.toml", "Cargo.lock", "Cargo.toml", "Cargo.lock"]
scope = "source.rust"
[language.indent]
tab-width = 2
unit = " " |
@kirawi how did you check the final result? |
I added |
I see. I thought there was an option I didn't know |
@@ -56,15 +56,33 @@ pub struct Application { | |||
} | |||
|
|||
impl Application { | |||
pub fn new(args: Args, config: Config) -> Result<Self, Error> { | |||
pub fn new(args: Args) -> Result<Self, Error> { |
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'm sorry I'm kind of late to the party here. Thanks for the change, @kirawi, this will be super useful!
But this particular part of the change actually presents a problem. I'm working on an integration testing branch, and this change makes it so that you can't pass in a pre-parsed Config object. This was very useful for testing, as it's super easy to just make the struct literal you want to describe the config option you want to test. Now it seems that the config can only come from a toml file. Could we please move this logic back into main?
The documentation of find_root described the following priority for detecting a project root: - Top-most folder containing a root marker in current git repository - Git repository root if no marker detected - Top-most folder containing a root marker if not git repository detected - Current working directory as fallback The commit contained in helix-editor#1249 extracted and changed the implementation of find_root in find_root_impl, actually reversing its result order (since that is the order that made sense for the local configuration merge, from innermost to outermost ancestors). Since the two uses of find_root_impl have different requirements (and it's not a matter of reversing the order of results since, e.g., the top repository dir should be used by find_root only if there's not marker in other dirs), this PR splits the two implementations in two different specialized functions. In doing so, find_root_impl is removed and the implementation is moved back in find_root, moving it closer to the documented behaviour thus making it easier to verify it's actually correct
The documentation of find_root described the following priority for detecting a project root: - Top-most folder containing a root marker in current git repository - Git repository root if no marker detected - Top-most folder containing a root marker if not git repository detected - Current working directory as fallback The commit contained in helix-editor#1249 extracted and changed the implementation of find_root in find_root_impl, actually reversing its result order (since that is the order that made sense for the local configuration merge, from innermost to outermost ancestors). Since the two uses of find_root_impl have different requirements (and it's not a matter of reversing the order of results since, e.g., the top repository dir should be used by find_root only if there's not marker in other dirs), this PR splits the two implementations in two different specialized functions. In doing so, find_root_impl is removed and the implementation is moved back in find_root, moving it closer to the documented behaviour thus making it easier to verify it's actually correct
The documentation of find_root described the following priority for detecting a project root: - Top-most folder containing a root marker in current git repository - Git repository root if no marker detected - Top-most folder containing a root marker if not git repository detected - Current working directory as fallback The commit contained in helix-editor#1249 extracted and changed the implementation of find_root in find_root_impl, actually reversing its result order (since that is the order that made sense for the local configuration merge, from innermost to outermost ancestors). Since the two uses of find_root_impl have different requirements (and it's not a matter of reversing the order of results since, e.g., the top repository dir should be used by find_root only if there's not marker in other dirs), this PR splits the two implementations in two different specialized functions. In doing so, find_root_impl is removed and the implementation is moved back in find_root, moving it closer to the documented behaviour thus making it easier to verify it's actually correct
The documentation of find_root described the following priority for detecting a project root: - Top-most folder containing a root marker in current git repository - Git repository root if no marker detected - Top-most folder containing a root marker if not git repository detected - Current working directory as fallback The commit contained in helix-editor#1249 extracted and changed the implementation of find_root in find_root_impl, actually reversing its result order (since that is the order that made sense for the local configuration merge, from innermost to outermost ancestors). Since the two uses of find_root_impl have different requirements (and it's not a matter of reversing the order of results since, e.g., the top repository dir should be used by find_root only if there's not marker in other dirs), this PR splits the two implementations in two different specialized functions. In doing so, find_root_impl is removed and the implementation is moved back in find_root, moving it closer to the documented behaviour thus making it easier to verify it's actually correct
The documentation of find_root described the following priority for detecting a project root: - Top-most folder containing a root marker in current git repository - Git repository root if no marker detected - Top-most folder containing a root marker if not git repository detected - Current working directory as fallback The commit contained in helix-editor#1249 extracted and changed the implementation of find_root in find_root_impl, actually reversing its result order (since that is the order that made sense for the local configuration merge, from innermost to outermost ancestors). Since the two uses of find_root_impl have different requirements (and it's not a matter of reversing the order of results since, e.g., the top repository dir should be used by find_root only if there's not marker in other dirs), this PR splits the two implementations in two different specialized functions. In doing so, find_root_impl is removed and the implementation is moved back in find_root, moving it closer to the documented behaviour thus making it easier to verify it's actually correct
…3929) * Split helix_core::find_root and helix_loader::find_local_config_dirs The documentation of find_root described the following priority for detecting a project root: - Top-most folder containing a root marker in current git repository - Git repository root if no marker detected - Top-most folder containing a root marker if not git repository detected - Current working directory as fallback The commit contained in #1249 extracted and changed the implementation of find_root in find_root_impl, actually reversing its result order (since that is the order that made sense for the local configuration merge, from innermost to outermost ancestors). Since the two uses of find_root_impl have different requirements (and it's not a matter of reversing the order of results since, e.g., the top repository dir should be used by find_root only if there's not marker in other dirs), this PR splits the two implementations in two different specialized functions. In doing so, find_root_impl is removed and the implementation is moved back in find_root, moving it closer to the documented behaviour thus making it easier to verify it's actually correct * helix-core: remove Option from find_root return type It always returns some result, so Option is not needed
…elix-editor#3929) * Split helix_core::find_root and helix_loader::find_local_config_dirs The documentation of find_root described the following priority for detecting a project root: - Top-most folder containing a root marker in current git repository - Git repository root if no marker detected - Top-most folder containing a root marker if not git repository detected - Current working directory as fallback The commit contained in helix-editor#1249 extracted and changed the implementation of find_root in find_root_impl, actually reversing its result order (since that is the order that made sense for the local configuration merge, from innermost to outermost ancestors). Since the two uses of find_root_impl have different requirements (and it's not a matter of reversing the order of results since, e.g., the top repository dir should be used by find_root only if there's not marker in other dirs), this PR splits the two implementations in two different specialized functions. In doing so, find_root_impl is removed and the implementation is moved back in find_root, moving it closer to the documented behaviour thus making it easier to verify it's actually correct * helix-core: remove Option from find_root return type It always returns some result, so Option is not needed
[ Sorry for commenting here, but you appear not to have set up the security tab for reporting potential vulnerabilities ] If I add a .helix folder in my git repo that sets the language server protocol command to |
This isn't the appropriate place to make that comment. You should create a separate issue instead. |
If you do not configure the security settings on GitHub or provide a SECURITY.me, external people have no idea how to report suspected security issues. There was no coordinated disclosure process documented for this project, so I filed it on the place closest to where the problem was introduced. If you want security issues filed in a specific place then I suggest that you document this. Either way, I have reported it and it’s now up to you to choose how to handle it. |
I dont think editors have a particular high thread model that would warrant a security policy like that. If you clone untrusted code and run any language server on it you are already vulnerable (rust analyzer runs cargo check which runs build scripts which can run arbitrary untrusted code, same for many other LS) so really any editor that runs language servers is gulernabke. So emacs-lsp mode, nvim and kakune can all be attacked if you open files from a compromised repo. Either way just like any other problem it should be reported as an issue instead of a random comment on old PR that is likely easily forgotten. |
I'm currently working on a patch to explicitly approve each new workspace. |
Resolves #1217, allowing users to have configuration for local directories. It defaults to looking for every
.helix
folder until it finds a.git
folder or is at the root, and merges all the configs in order.