تماشای این درس نیاز به اشتراک حرفه‌ای دارد.

Introducing null-ls Sources0:31

And if we scroll down in their README, you'll see all of the features that it integrates with, like code actions, diagnostics, formatting, hover, and completion. And if we jump over to this built-ins document, they list out all of the different sources they support. So things like ESLint, if we jump down to diagnostics, we've got all these things for all these different languages, and so on. So let's jump back into our plugins.lua file, and set it up. I'm going to scroll up to where we set up our language server protocol, and paste in two more plugins. So this one is NullLS itself, and this one is a mason add-on that will automatically

Configuring null-ls and Mason1:38

my project. I've also set up this trailing space diagnostic, which is kind of cool. And then another one for ESLint, but this one is for formatting. So the first one was to show diagnostic information, and this one is to add formatting. And then sometimes I use Prettier, so I've also set up one for Prettier as well. Now we also need to activate our mason plugin, so let's go and add a line for that. And I found this one needs to happen after we call NullLS, so that's why I've put it here. And then last of all, under our keymaps, I'm just going to add in a section for commands. So here we're registering a custom command called format with a capital F, and all of

Adding Format Command2:09

And then last of all, under our keymaps, I'm just going to add in a section for commands. So here we're registering a custom command called format with a capital F, and all of our commands have to start with a capital letter. And this just provides an easy way to call the LSP formatting command. You might like to map this to a key instead of a command, but I actually don't use it that often, and mostly just use the diagnostic information. So let's go ahead and save all of these, and run our Packer sync. And now let's jump back over to our Laravel project. I've created a .eslintrc in here already that just has the Vue 3 recommended ESLint plugin. So let's open up Vim, and we'll jump to welcome.vue.

Checking ESLint Diagnostics2:41

I've created a .eslintrc in here already that just has the Vue 3 recommended ESLint plugin. So let's open up Vim, and we'll jump to welcome.vue. And you'll see straight away, we've got a ton of linting errors in here. So if I use my leader D command, we'll see that ESLint's not happy because the Laravel version requires a default value to be set. You can come down here a bit further, and you'll see we've got two errors here. So it's not happy about the indentation for the ESLint rules, and it also wants class to be on a new line. So let's go ahead and run the format command with :format. And this will ask us which language server we want to use, because we have multiple language

Running null-ls Formatting3:19

So let's go ahead and run the format command with colon format. And this will ask us which language server we want to use, because we have multiple language servers in this buffer that offer a formatting feature. So in this case, I want null-ls. And now you'll see it's fixed everything that it can fix automatically. So it's changed the indentation, and put these things on multiline. The only thing it hasn't been able to fix is these, because it doesn't know what the default value should be. And it also doesn't like that our welcome.vue component is a single word. So that's it for this one.

Transition to Snippets3:50

And it also doesn't like that our welcome.vue component is a single word. So that's it for this one. Next up, let's look at how snippets can save us time and keystrokes.

Integrating Tools with Neovim

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟