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

feat: improve default haxe_language_server init_options #3284

Merged
merged 2 commits into from
Aug 26, 2024

Conversation

tobil4sk
Copy link
Contributor

Adds .git as a root directory pattern.

Previously, it would detect the root dir by matching with "*.hxml", however, it
would use "build.hxml" as the default displayArguments even though it may not
exist. This could cause the error:

haxe_language_server: -32603: Error: Could not process argument build.hxml (file not found)
Invalid character:

Now it will use the first ".hxml" file that is found in the project. It will
only do this if no displayArguments value has been set in the setup() call,
so it will still respect user set values.

If no hxml file is found, then it uses empty displayArguments, which is still
better than a broken configuration.

@tobil4sk tobil4sk requested a review from glepnir as a code owner August 25, 2024 11:53
@@ -1,18 +1,36 @@
local util = require 'lspconfig.util'

local function find_hxml(path)
return vim.fs.find(function(name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use vim.fs.root

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vim.fs.root seems to return the parent directory, but I'd like to find a file. e.g. /path/to/project/build.hxml

init_options = {},
on_new_config = function(new_config, new_root_dir)
if new_config.init_options.displayArguments then
print 'displayArguments already set. Skipping'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use vim.notify replace print

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I left in by mistake while debugging. I've replaced the other one with vim.notify.

@tobil4sk tobil4sk force-pushed the improve-haxe-config branch from dc97f6c to 964497f Compare August 25, 2024 11:55
Previously, it would detect the root dir by matching with "*.hxml", however, it
would use "build.hxml" as the default `displayArguments` even though it may not
exist. This could cause the error:

```
haxe_language_server: -32603: Error: Could not process argument build.hxml (file not found)
Invalid character:
```

Now it will use the first ".hxml" file that is found in the project. It will
only do this if no `displayArguments` value has been set in the `setup()` call,
so it will still respect user set values.

If no hxml file is found, then it uses empty `displayArguments`, which is still
better than a broken configuration.
@tobil4sk tobil4sk force-pushed the improve-haxe-config branch from 964497f to f342b7f Compare August 25, 2024 12:01
@glepnir glepnir merged commit acf17dc into neovim:master Aug 26, 2024
8 checks passed
@tobil4sk tobil4sk deleted the improve-haxe-config branch August 26, 2024 09:41
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

Successfully merging this pull request may close these issues.

2 participants