adalessa / laravel.nvim

Plugin for Nvim to work with laravel projects.
MIT License
280 stars 15 forks source link

How to configure artisan command to be used #92

Closed neitanod closed 3 months ago

neitanod commented 3 months ago

Since I installed the plugin I'm constantly receiving the error "Executable artisan not found" when saving my file or switching buffers. The thing is that I cannot run artisan in the current project, as I have a static copy and the actual artisan command must run inside a Docker container. But I could configure the correct command to be used if I knew how to do that.

Is there a configuration option for that?

Thanks in advance!

adalessa commented 3 months ago

Hey, sorry to heard that you have problems. how the plugin works by default it check if the file artisan is present in the root it assumes is a laravel project. To define the environment first check the environment variable NVIM_LARAVEL_ENV which you can set up in your .env file. here you can set local sail or docker-compose given your case you can use docker-compose and you need to define the container name by default is app but you can also set the environment variable APP_SERVICE with the name of the container. this the command will run as docker compose exec -it <container name> <command> by default will tried to run php (and artisan) commands, composer and npm commands.

If this is not enought for you, you can add your own overwriting the configuration in the setup function in environments.definitions and set your own of type LaravelEnvironmentConfig

---@class EnvironmentCondition
---@field file_exists string[]|nil
---@field executable string[]|nil

---@class LaravelEnvironmentConfig
---@field name string
---@field condition EnvironmentCondition
---@field commands table|nil

in the lua/laravel/config/environments.lua file you can see examples how the ones I mentioned before are set.

Hope this explanation helps you to have it set up for your environment.

adalessa commented 3 months ago

Hey, were you able to solve it ? I will close it since two weeks since the last message, feel free to re-open it with more comments.