zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
24.95k stars 1.17k forks source link

How exactly do I get the linter to work? #3164

Closed ryan-caesar-ramos closed 7 months ago

ryan-caesar-ramos commented 7 months ago

Description of the problem or steps to reproduce

How do I get the linter plugin to work? I made the directory ~/.config/micro/plug/linter then downloaded this file into it. According to the repo, if the plugin is enabled, then saving the file should start the linting, but unless my machine is insanely slow, I don't think anything's happening. Is there a chance that the plugin is not enabled? How would I do that?

Specifications

Commit hash: 68d88b57 OS: Ubuntu 20.04.5 LTS Terminal: iTerm 3.4.15

taconi commented 7 months ago

The linter plugin is already installed by default so you wouldn't need to download it to ~/.config/micro/plug/linter, I don't know if this could be causing an error.

One thing to test is to remove the ~/.config/micro/plug/linter folder.

Or something that could be happening is that the command is not installed.

How are you adding the linter?

ryan-caesar-ramos commented 7 months ago

I added the linter by downloading the lua file to the directory ~/.config/micro/plug/linter. I'll try removing ~/.config/micro/plug/linter, but what should I expect to happen?

taconi commented 7 months ago

To add a linter you need to create the file ~/.config/micro/init.lua. This is a plugin that you create to write your configurations in lua.

In it you create an init() function globally, the micro will call this callback when it starts. Within this callback you could define your linters.

Example:

-- ~/.config/micro/init.lua

function init()
  linter.makeLinter('tsc', 'typescript', 'tsc', {'--noEmit', '--pretty', 'false'}, '%f%(%l,%c%): %m')
end

Enter the command bar with Ctrl-e and type help linter to see more plugin help.

ryan-caesar-ramos commented 7 months ago

Thanks for your help so far; I deleted the folder I made, ran micro -plugin list, and indeed linter still shows up.

The biggest issue here is that I didn't realize that I needed to configure the linter inside the init function.

Thanks again!