Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Latexindent doesn't work #183

Closed
1 task done
milan-panta opened this issue Nov 6, 2023 · 6 comments
Closed
1 task done

bug: Latexindent doesn't work #183

milan-panta opened this issue Nov 6, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@milan-panta
Copy link

milan-panta commented Nov 6, 2023

Neovim version (nvim -v)

v0.10.0-dev-1467+g5cefec734-Homebrew

Operating system/version

MacOS 14.0

Add the debug logs

  • I have set log_level = vim.log.levels.DEBUG and pasted the log contents below.

Log file

Log file: /Users/milan/.local/state/nvim/conform.log
13:00:55[INFO] Run latexindent on /Users/milan/Documents/263/A4/a4.tex
13:00:55[DEBUG] Run command: { "latexindent", "-" }

Formatters for this buffer:
latexindent ready (tex)

Other formatters:
clang_format ready (cpp, c)
prettierd ready (markdown, typescriptreact, typescript, javascriptreact, javascript)
ruff_fix ready (python)
ruff_format ready (python)
stylua ready (lua)

Describe the bug

Formatting with latexindent doesn't work and results in the following error message.

E5108: Error executing lua: Vim:E903: Process failed to start: Unknown system error -86: "/Users/milan/.local/shar
e/nvim/mason/bin/latexindent"
stack traceback:
[C]: in function 'jobstart'
...ocal/share/nvim/lazy/conform.nvim/lua/conform/runner.lua:302: in function 'run_formatter'
...ocal/share/nvim/lazy/conform.nvim/lua/conform/runner.lua:566: in function 'format_lines_sync'
...ocal/share/nvim/lazy/conform.nvim/lua/conform/runner.lua:529: in function 'format_sync'
....local/share/nvim/lazy/conform.nvim/lua/conform/init.lua:421: in function 'format'
/Users/milan/.config/nvim/lua/plugins/lintfmt.lua:68: in function </Users/milan/.config/nvim/lua/plugins/l
intfmt.lua:67>

Steps To Reproduce

  1. Open a tex file.
  2. Try formatting it with latexindent and conform.

Expected Behavior

Proper formatting and no error message.

My conform config

config = function()
  -- formatting with conform
  local conform = require("conform")
  conform.setup({
    log_level = vim.log.levels.DEBUG,
    formatters_by_ft = {
      c = { "clang_format" },
      cpp = { "clang_format" },
      lua = { "stylua" },
      python = { "ruff_fix", "ruff_format" },
      tex = { "latexindent" },
    },
  })
  vim.keymap.set({ "n", "v" }, "<Leader>lf", function()
    conform.format({
      lsp_fallback = true,
      async = false,
      timeout_ms = 1000,
    })
    vim.cmd("w")
    -- end
  end, { desc = "Format file or range (in visual mode)" })
end,

Minimal init.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "stevearc/conform.nvim",
    config = function()
      require("conform").setup({
        log_level = vim.log.levels.DEBUG,
        -- add your config here
      })
    end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Additional context

All other formatters work (stylua, ruff, etc).

@milan-panta milan-panta added the bug Something isn't working label Nov 6, 2023
@stevearc
Copy link
Owner

stevearc commented Nov 7, 2023

What happens if you run cat <file> | /Users/milan/.local/shar e/nvim/mason/bin/latexindent - in your shell?

@milan-panta
Copy link
Author

milan-panta commented Nov 10, 2023

I get
zsh: bad CPU type in executable: /Users/milan/.local/share/nvim/mason/bin/latexindent.
But when I do latexindent -w "file" it indents everything properly. The bad CPU type may be because I'm on an M1 Mac?

@milan-panta
Copy link
Author

The logfiles are now giving a different error (only for latexindent, all other formatters work perfectly)
[ERROR] Formatter 'latexindent' error in jobstart: Vim:E903: Process failed to start: Unknown system error -86: "/Users/milan/.local/share/nvim/mason/bin/latexindent"

@stevearc
Copy link
Owner

Smells like something is wrong with the executable. Could be that it was compiled for the wrong CPU architecture. You mentioned that latexindent -w "file" works, my question is: is that the same executable, or something else in your path? What do you see when you run command -v latexindent?

@milan-panta
Copy link
Author

I see /Library/TeX/texbin/latexindent.

@stevearc
Copy link
Owner

That's your answer! You have a working version of latexindent installed at /Library/TeX/texbin/latexindent, but mason has installed a version for the wrong CPU architecture. You should be able to uninstall the mason version and it will work. You could also report a bug to mason that it doesn't install the correct version on mac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants