-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Goto Definition is broken #53
Comments
Thanks for reporting this, @Gert-JanPeeters! I wonder if VSCode would still accept it with the Looking at this line here, I'm wondering why I opted for stripping it 🤔 stimulus-lsp/server/src/service.ts Line 29 in 88f5fe5
|
I went searching a bit and found a similar issue: NomicFoundation/hardhat-vscode#355 I think that VSCode can deal with both but Neovim is forcing LSPs to use an URI with a scheme. Not really sure which scheme it has to be used but I am guessing |
I guess in that case we should be able to use always use |
I have investigated a bit further. I tried changing this line: stimulus-lsp/server/src/service.ts Line 29 in 86bd86b
to this.project = new Project(this.settings.projectPath) But then things break. For example, stimulus-lsp cannot find the controllers anymore. However, if I change: stimulus-lsp/server/src/definitions.ts Line 57 in 86bd86b
to: const locations = controllers.map((controller) => Location.create(`file://${controller.path}`, Range.create(0, 0, 0, 0))) The Goto definition works in neovim. However, I don't think we should make the change here. If I am correct then it is |
Thanks for investigating! I think we should rather do it here in the repo, since this is more LSP specific. The Stimulus Parser could be used outside of an LSP context, which is why I think it doesn't really make sense to use the |
This is probably not the right place to share this, but I ended up here after some googling about not being able to The files I'm trying to navigate exist in a user defined pinned folder in the Here's what worked for me.
# Pin npm packages by running ./bin/importmap
pin "application"
pin "@hotwired/turbo-rails", to: "turbo.min.js"
pin "@hotwired/stimulus", to: "stimulus.min.js"
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
pin_all_from "app/javascript/controllers", under: "controllers"
pin_all_from "app/javascript/custom", under: "custom" # this is the new/important line to load our custom folder
import "custom/trix_date_extension";
import { FormManager } from "custom/form_manager";
import { Logger } from "custom/logger";
export class TrixDateExtension {
//... lots of code
// Custom button handler
document.addEventListener("click", async (event) => {
const dateButton = event.target.closest(
"[data-trix-action='insertDatePlaceholder']",
);
if (dateButton) {
event.preventDefault();
try {
await this.#formManager.openTaskDatePopup(dateButton);
} catch (error) {
Logger.logError(error, "insertDatePlaceholder");
}
}
});
}
document.addEventListener("DOMContentLoaded", function () {
console.log("Loading Trix Date Extension...");
new TrixDateExtension();
});
import { DOMHelper } from "custom/dom_helper";
import { Logger } from "custom/logger";
export class FormManager {
#editor;
#taskManager;
constructor(editor, taskManager) {
this.#editor = editor;
this.#taskManager = taskManager;
this.lastFormData = {
taskName: "",
dateTag: "",
dateTime: "",
};
}
async openTaskDatePopup(button) {
try {
const result = await this.promptForTaskDateDetails(
button,
this.getNextTaskDateTagInt(),
);
if (!result) {
return;
}
const { dateTag, taskName, date } = result;
await this.#taskManager.createTask(dateTag, date, taskName);
} catch (error) {
Logger.logError(error, "Error handling date placeholder");
alert("There was an error creating the date placeholder and task.");
}
}
// ... more code
} Because of the way the import statements have to be setup for local modules with But if you add this {
"compilerOptions": {
"baseUrl": "./app/javascript",
"paths": {
"controllers/*": [
"controllers/*"
],
"custom/*": [
"custom/*"
]
}
},
"include": [
"app/javascript/**/*"
]
} Then it will allow for navigating to those definitions again. google keyword help: go-to-definition, go_to_definition |
I am using
neovim
, when I try to "Goto Definition", I get the following error:I think
neovim
is expecting a URI with a scheme, e.g.file://usr/local/var/www/sticket/app/javascript/controllers/show_controller.js
instead of/usr/local/var/www/sticket/app/javascript/controllers/show_controller.js
The text was updated successfully, but these errors were encountered: