alephium / ralph-lsp

Ralph language server
7 stars 1 forks source link

Respect `.gitignore` #290

Closed tdroxler closed 2 weeks ago

tdroxler commented 3 weeks ago

From a discord discussion, for example when working when installing node alephium-cli module, it comes with some ralph templates node_modules/@alephium/cli/templates and ralph-lsp will complains

image

simerplaha commented 3 weeks ago

Do they have their contractPath in ralph.json or their sourceDir in alephium.config.ts set to "." or empty ""? This sets the sourceDir to the current workspace, which by the looks of it includes node_modules. If they'd want just the contracts directory to be compiled maybe they should set sourceDir to contracts?

tdroxler commented 3 weeks ago

I'll check, but isn't it anyway good to ignore .gitinore files?

simerplaha commented 3 weeks ago

I would recommend against using files in .gitignore to be ignored from compilation process simply because it's not a standard practice. .gitignore has no relation to the compilation process, otherwise it would have been named .ignore or something, but it is explicitly for Git.

Ignoring files from Git might not always mean also ignore from compilation. For example, I have a project where some files are added to .gitignore because they are re-generated during the build process. These files don't need to be committed to Git but are needed during compilation.

There are also multiple ways to ignore files from Git in addition to local .gitignore, for example, globally in ~/.gitignore or exlude. There are probably multiple other ways as well, which would increase the scope of this task.

To target compilation to a specific directory and ignore the rest we already have sourceDir in alephium.config.ts. So the behaviour/error seen in the above screenshot is expected.

tdroxler commented 2 weeks ago

you convinced me, let's close this issue for now.