nvimdev / guard.nvim

async fast minimalist plugin make format easy in neovim
MIT License
449 stars 24 forks source link

fmt_on_save does not format on save? #80

Closed tmpm697 closed 1 year ago

tmpm697 commented 1 year ago

Minimal config:

local ft = require("guard.filetype")

ft("lua"):fmt("stylua"):lint("luacheck")

-- Call setup() LAST!
require("guard").setup({
    -- the only options for the setup function
    fmt_on_save = true,
    -- Use lsp if no formatter was defined for this filetype
    lsp_as_default_formatter = true,
})

nvim
:e file.lua
:w --> does not auto format the file
glepnir commented 1 year ago

something wrong in your config can't reproduce

Untitled

tmpm697 commented 1 year ago

Probably due to this is under nixos that stylua is not epxected under /usr/bin, maybe use command stylua?

but I installed stylua globally --> avail in any shell.

glepnir commented 1 year ago

output of checkhealth

tmpm697 commented 1 year ago

output of checkhealth


guard: require("guard.health").check()

Executable check

glepnir commented 1 year ago

hmm please push full output .

tmpm697 commented 1 year ago

full output

guard: require("guard.health").check()

Executable check

──────────────────────────────────────────────────────────────────────────────
mason: require("mason.health").check()

mason.nvim
- OK mason.nvim version v1.6.2
- OK PATH: prepend
- OK Providers:▓
    mason.providers.registry-api
    mason.providers.client
- OK neovim version >= 0.7.0

mason.nvim [Registries]

mason.nvim [Core utils]
- WARNING unzip: not available
  - ADVICE:
    - spawn: unzip failed with exit code - and signal -. unzip is not executable
- OK wget: GNU Wget 1.21.4 built on linux-gnu.
- OK curl: curl 8.2.1 (x86_64-pc-linux-gnu) libcurl/8.2.1 OpenSSL/3.0.10 zlib/1.2.13 brotli/1.0.9 zstd/1.5.5 libidn2/2.3.4 libssh2/1.11.0 nghttp2/1.54.0
- OK gzip: gzip 1.12
- OK tar: tar (GNU tar) 1.35
- OK bash: GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu)
- OK sh: Ok

mason.nvim [Languages]
- WARNING Go: not available
  - ADVICE:
    - spawn: go failed with exit code - and signal -. go is not executable
- WARNING Composer: not available
  - ADVICE:
    - spawn: composer failed with exit code - and signal -. composer is not executable
- WARNING PHP: not available
  - ADVICE:
    - spawn: php failed with exit code - and signal -. php is not executable
- WARNING npm: not available
  - ADVICE:
    - spawn: npm failed with exit code - and signal -. npm is not executable
- WARNING node: not available
  - ADVICE:
    - spawn: node failed with exit code - and signal -. node is not executable
- WARNING javac: not available
  - ADVICE:
    - spawn: javac failed with exit code - and signal -. javac is not executable
- WARNING java: not available
  - ADVICE:
    - spawn: java failed with exit code - and signal -. java is not executable
- WARNING julia: not available
  - ADVICE:
    - spawn: julia failed with exit code - and signal -. julia is not executable
- WARNING python: not available
  - ADVICE:
    - spawn: python3 failed with exit code - and signal -. python3 is not executable
- WARNING pip: not available
  - ADVICE:
    - spawn: python3 failed with exit code - and signal -. python3 is not executable
- WARNING python venv: not available
  - ADVICE:
    - On Debian/Ubuntu systems, you need to install the python3-venv package using the following command:
▓▓▓▓▓▓
          apt-get install python3-venv
- WARNING cargo: not available
  - ADVICE:
    - spawn: cargo failed with exit code - and signal -. cargo is not executable
- WARNING luarocks: not available
  - ADVICE:
    - spawn: luarocks failed with exit code - and signal -. luarocks is not executable
- OK Ruby: ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux]
- OK python3_host_prog: Python 3.10.12
- WARNING python3_host_prog pip: not available
  - ADVICE:
    - spawn: /nix/store/5lxvl83f9mxy3nml437hhxl39797fp4j-neovim-33e1a8c/bin/nvim-python3 failed with exit code 1 and signal 0. /nix/store/1rqbihvk4sc4lz91kij9qi5acay9v0vw-python3-3.10.12-env/bin/python3.10: No module named pip
 - OK RubyGem: 3.4.18

mason.nvim [GitHub]
- OK GitHub API rate limit. Used: 0. Remaining: 60. Limit: 60. Reset: Wed 23 Aug 2023 05:24:04 PM +07.
  Install and authenticate via gh-cli to increase rate limit.

──────────────────────────────────────────────────────────────────────────────
null-ls: require("null-ls.health").check()

- no sources registered

──────────────────────────────────────────────────────────────────────────────
nvim: require("nvim.health").check()

Configuration
- OK no issues found

Runtime
- OK $VIMRUNTIME: /nix/store/0d2haf1cmsr9n9y5vadvj362djzsxim2-neovim-unwrapped-33e1a8c/share/nvim/runtime

Performance
- OK Build type: Release

Remote Plugins
- OK Up to date

terminal
- key_backspace (kbs) terminfo entry: key_backspace=\177
- key_dc (kdch1) terminfo entry: key_dc=\E[3~
- $SSH_TTY="/dev/pts/0"

──────────────────────────────────────────────────────────────────────────────
nvim-treesitter: require("nvim-treesitter.health").check()

Installation
- OK tree-sitter found 0.20.8 (parser generator, only needed for :TSInstallFromGrammar)
- WARNING node executable not found (only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK git executable found.
- ERROR cc executable not found.
  - ADVICE:
    - Check that any of { vim.NIL, "cc", "gcc", "clang", "cl", "zig" } is in your $PATH or set the environment variable CC or require"nvim-treesitter.install".compilers explicitly!
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "x86_64",
  release = "6.4.11",
  sysname = "Linux",
  version = "#1-NixOS SMP PREEMPT_DYNAMIC Wed Aug 16 16:32:31 UTC 2023"
}

Parser/Features         H L F I J
  - bash                ✓ ✓ ✓ . ✓
  - c                   ✓ ✓ ✓ ✓ ✓
  - cpp                 ✓ ✓ ✓ ✓ ✓
  - json                ✓ ✓ ✓ ✓ .
  - lua                 ✓ ✓ ✓ ✓ ✓
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . . ✓
  - nix                 ✓ ✓ ✓ . ✓
  - python              ✓ ✓ ✓ ✓ ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - regex               ✓ . . . .
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              ✓ . . . ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}

──────────────────────────────────────────────────────────────────────────────
provider: require("provider.health").check()

Clipboard (optional)
- WARNING No clipboard tool found. Clipboard registers ("+ and "*) will not work.
  - ADVICE:
     - :help clipboard

Python 3 provider (optional)
- Using: g:python3_host_prog = "/nix/store/5lxvl83f9mxy3nml437hhxl39797fp4j-neovim-33e1a8c/bin/nvim-python3"
- Executable: /nix/store/5lxvl83f9mxy3nml437hhxl39797fp4j-neovim-33e1a8c/bin/nvim-python3
- Python version: 3.10.12
- pynvim version: 0.4.3
- OK Latest pynvim is installed.

Python virtualenv
- OK no $VIRTUAL_ENV

Ruby provider (optional)
- Ruby: ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux]
- Host: /nix/store/5lxvl83f9mxy3nml437hhxl39797fp4j-neovim-33e1a8c/bin/nvim-ruby
- WARNING Gem "neovim" is out-of-date. Installed: 0.9.0, latest: neovim (0.9.1, 0.9.0, 0.8.1, 0.8.0, 0.7.1, 0.7.0, 0.6.2, 0.6.1, 0.6.0, 0.5.1, 0.5.0, 0.4.0, 0.3.3, 0.3.2, 0.3.1, 0.3.0, 0.2.5, 0.2.4, 0.2.3, 0.2.2, 0.2.1, 0.2.0, 0.1.0, 0.0.6, 0.0.5, 0.0.4, 0.0.3, 0.0.2, 0.0.1)
  - ADVICE:
    - Run in shell: gem update neovim

Node.js provider (optional)
- Disabled (loaded_node_provider=0).

Perl provider (optional)
- Disabled (loaded_perl_provider=0).

──────────────────────────────────────────────────────────────────────────────
telescope: require("telescope.health").check()

Checking for required plugins
- OK plenary installed.
- OK nvim-treesitter installed.

Checking external dependencies
- OK rg: found ripgrep 13.0.0
- OK fd: found fd 8.7.0

===== Installed extensions =====

──────────────────────────────────────────────────────────────────────────────
vim.lsp: require("vim.lsp.health").check()

- LSP log level : WARN
- Log path: /home/user/.local/state/nvim/lsp.log
- Log size: 2 KB

vim.lsp: Active Clients
- No active clients

──────────────────────────────────────────────────────────────────────────────
vim.treesitter: require("vim.treesitter.health").check()

- Nvim runtime ABI version: 14
- OK Parser: bash       ABI: 14, path: /nix/store/7jwzydmcwcy4lc8dhwq0aflgk1ynh78c-vim-pack-dir/pack/myNeovimPackages/start/vimplugin-treesitter-grammar-bash/parser/bash.so
- OK Parser: c          ABI: 14, path: /nix/store/7jwzydmcwcy4lc8dhwq0aflgk1ynh78c-vim-pack-dir/pack/myNeovimPackages/start/vimplugin-treesitter-grammar-c/parser/c.so
- OK Parser: cpp        ABI: 14, path: /nix/store/7jwzydmcwcy4lc8dhwq0aflgk1ynh78c-vim-pack-dir/pack/myNeovimPackages/start/vimplugin-treesitter-grammar-cpp/parser/cpp.so
- OK Parser: json       ABI: 14, path: /nix/store/7jwzydmcwcy4lc8dhwq0aflgk1ynh78c-vim-pack-dir/pack/myNeovimPackages/start/vimplugin-treesitter-grammar-json/parser/json.so
- OK Parser: lua        ABI: 14, path: /nix/store/7jwzydmcwcy4lc8dhwq0aflgk1ynh78c-vim-pack-dir/pack/myNeovimPackages/start/vimplugin-treesitter-grammar-lua/parser/lua.so
- OK Parser: markdown   ABI: 14, path: /nix/store/7jwzydmcwcy4lc8dhwq0aflgk1ynh78c-vim-pack-dir/pack/myNeovimPackages/start/vimplugin-treesitter-grammar-markdown/parser/markdown.so
- OK Parser: markdown_inline ABI: 14, path: /nix/store/7jwzydmcwcy4lc8dhwq0aflgk1ynh78c-vim-pack-dir/pack/myNeovimPackages/start/vimplugin-treesitter-grammar-markdown_inline/parser/markdown_inline.so
- OK Parser: nix        ABI: 13, path: /nix/store/7jwzydmcwcy4lc8dhwq0aflgk1ynh78c-vim-pack-dir/pack/myNeovimPackages/start/vimplugin-treesitter-grammar-nix/parser/nix.so
- OK Parser: python     ABI: 14, path: /nix/store/7jwzydmcwcy4lc8dhwq0aflgk1ynh78c-vim-pack-dir/pack/myNeovimPackages/start/vimplugin-treesitter-grammar-python/parser/python.so
- OK Parser: regex      ABI: 14, path: /nix/store/7jwzydmcwcy4lc8dhwq0aflgk1ynh78c-vim-pack-dir/pack/myNeovimPackages/start/vimplugin-treesitter-grammar-regex/parser/regex.so
- OK Parser: bash       ABI: 14, path: /nix/store/0d2haf1cmsr9n9y5vadvj362djzsxim2-neovim-unwrapped-33e1a8c/lib/nvim/parser/bash.so
- OK Parser: c          ABI: 14, path: /nix/store/0d2haf1cmsr9n9y5vadvj362djzsxim2-neovim-unwrapped-33e1a8c/lib/nvim/parser/c.so
- OK Parser: lua        ABI: 14, path: /nix/store/0d2haf1cmsr9n9y5vadvj362djzsxim2-neovim-unwrapped-33e1a8c/lib/nvim/parser/lua.so
- OK Parser: markdown   ABI: 14, path: /nix/store/0d2haf1cmsr9n9y5vadvj362djzsxim2-neovim-unwrapped-33e1a8c/lib/nvim/parser/markdown.so
- OK Parser: python     ABI: 14, path: /nix/store/0d2haf1cmsr9n9y5vadvj362djzsxim2-neovim-unwrapped-33e1a8c/lib/nvim/parser/python.so
- OK Parser: query      ABI: 14, path: /nix/store/0d2haf1cmsr9n9y5vadvj362djzsxim2-neovim-unwrapped-33e1a8c/lib/nvim/parser/query.so
- OK Parser: vim        ABI: 14, path: /nix/store/0d2haf1cmsr9n9y5vadvj362djzsxim2-neovim-unwrapped-33e1a8c/lib/nvim/parser/vim.so
- OK Parser: vimdoc     ABI: 14, path: /nix/store/0d2haf1cmsr9n9y5vadvj362djzsxim2-neovim-unwrapped-33e1a8c/lib/nvim/parser/vimdoc.so
- OK Parser: bash       ABI: 14, path: /nix/store/2nfh5kvjaa7608r94859wlh3p8lmc4zq-treesitter-parsers/parser/bash.so
- OK Parser: c          ABI: 14, path: /nix/store/2nfh5kvjaa7608r94859wlh3p8lmc4zq-treesitter-parsers/parser/c.so
- OK Parser: cpp        ABI: 14, path: /nix/store/2nfh5kvjaa7608r94859wlh3p8lmc4zq-treesitter-parsers/parser/cpp.so
- OK Parser: json       ABI: 14, path: /nix/store/2nfh5kvjaa7608r94859wlh3p8lmc4zq-treesitter-parsers/parser/json.so
- OK Parser: lua        ABI: 14, path: /nix/store/2nfh5kvjaa7608r94859wlh3p8lmc4zq-treesitter-parsers/parser/lua.so
- OK Parser: markdown   ABI: 14, path: /nix/store/2nfh5kvjaa7608r94859wlh3p8lmc4zq-treesitter-parsers/parser/markdown.so
- OK Parser: markdown_inline ABI: 14, path: /nix/store/2nfh5kvjaa7608r94859wlh3p8lmc4zq-treesitter-parsers/parser/markdown_inline.so
- OK Parser: nix        ABI: 13, path: /nix/store/2nfh5kvjaa7608r94859wlh3p8lmc4zq-treesitter-parsers/parser/nix.so
- OK Parser: python     ABI: 14, path: /nix/store/2nfh5kvjaa7608r94859wlh3p8lmc4zq-treesitter-parsers/parser/python.so
- OK Parser: regex      ABI: 14, path: /nix/store/2nfh5kvjaa7608r94859wlh3p8lmc4zq-treesitter-parsers/parser/regex.so
glepnir commented 1 year ago

looks like stylua not in path ? something should be like this

image

tmpm697 commented 1 year ago

ft("lua"):fmt("stylua")

What if i use this only? ft("lua"):fmt("stylua") --> still able to format?

luacheck under nixos is installed via luajitPackages.luacheck, idk if it's will avail to nvim or not, but under shell prompt it's avail.

glepnir commented 1 year ago

ft("lua"):fmt("stylua") this also will work. if the executable can find in path.

tmpm697 commented 1 year ago

ft("lua"):fmt("stylua") this also will work. if the executable can find in path.

I don't have anything after:

guard: require("guard.health").check()

Executable check
glepnir commented 1 year ago

that mean stylua not found . where stylua have output ?

tmpm697 commented 1 year ago

that mean stylua not found . where stylua have output ?

whereis stylua
stylua: /nix/store/gaizra0nnri7wsi07adhg4lb1rdrrmvm-user-environment/bin/stylua
glepnir commented 1 year ago

then output in neovim :echo executable('stylua') ?

tmpm697 commented 1 year ago

that mean stylua not found . where stylua have output ?

whereis stylua
stylua: /nix/store/gaizra0nnri7wsi07adhg4lb1rdrrmvm-user-environment/bin/stylua
>command stylua
error: no files provided
tmpm697 commented 1 year ago

then output in neovim :echo executable('stylua') ?

:echo executable('stylua')
1
glepnir commented 1 year ago

output of au BufWritePre and how you load guard . try disable lsp_as_default

tmpm697 commented 1 year ago

output of au BufWritePre and how you load guard . try disable lsp_as_default

:au BufWritePre
--- Autocommands ---
UserAutoGroup  BufWritePre
    *         %s/\s\+$//e [Remove whitespaces at line endings on save]
glepnir commented 1 year ago

problem found guard not load.

tmpm697 commented 1 year ago

lsp_as_default_formatter = false --> same result.

tmpm697 commented 1 year ago

problem found guard not load.

why it's not loaded under nixos?

tmpm697 commented 1 year ago

afaik, nixos will use native way of installing lua plugin from neovim.

expect plugin put to a folder and will be loaded.

glepnir commented 1 year ago

:help packadd . there has two folder /start and /opt if plugin in opt that mean it need you loaded it manually in start when neovim start all the plugins in start dir will load. you also can try some plugin manage plugin like lazy packer vim-plug etc.

tmpm697 commented 1 year ago

:help packadd . there has two folder /start and /opt if plugin in opt that mean it need you loaded it manually in start when neovim start all the plugins in start dir will load. you also can try some plugin manage plugin like lazy packer vim-plug etc.

fun fact: null-ls works out-of-box for me, but im currently test for a switch.

maybe this dues to how to package this plugin in nixos, i installed it from source

glepnir commented 1 year ago

Idk how nixos install neovim plugin.