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

Formatting messes up cursor position #69

Closed
DrunkenToast opened this issue Aug 17, 2023 · 8 comments
Closed

Formatting messes up cursor position #69

DrunkenToast opened this issue Aug 17, 2023 · 8 comments

Comments

@DrunkenToast
Copy link

DrunkenToast commented Aug 17, 2023

Sometimes on format the cursor will move to the top of the file.
I have not been able to properly reproduce this.

Used config:

    {
        "nvimdev/guard.nvim",
        event = { 'BufReadPost', 'BufNewFile' },
        config = function()
            local ft = require('guard.filetype')

            ft('typescript,javascript,typescriptreact,vue'):fmt('prettierd')
            --     :lint({
            --     cmd = 'eslint',
            --     args = { '--fix' },
            --     stdin = true
            -- })

            -- 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 = false,
            })
        end
    },

Possibly related: #68

@barrett-ruth
Copy link
Contributor

barrett-ruth commented Aug 17, 2023

Can you provide an example, try to reproduce it, or provide any helpful info?

@DrunkenToast
Copy link
Author

Can you provide an example, try to reproduce it, or provide any helpful info?

I will update once I am able to reproduce the issue but so far it seems to happen on random occasions.
The current workaround has always been to completely restart nvim because if it happens once, it keeps happening.

@glepnir
Copy link
Member

glepnir commented Aug 18, 2023

if you got something wrong. I'd suggest you try a min config avoid some things conflict.

@DrunkenToast
Copy link
Author

if you got something wrong. I'd suggest you try a min config avoid some things conflict.

Config is posted above. It is already very minimal.

@glepnir
Copy link
Member

glepnir commented Aug 18, 2023

I mean just include guard . something like this not a Config

vim.opt.rtp:append(path/to/guard)
local ft = require('guard.filetype')
ft:('xxx'):fmt

@barrett-ruth
Copy link
Contributor

@DrunkenToast also are you on latest version of guard, pretty sure this was fixed in #48

@DrunkenToast
Copy link
Author

@DrunkenToast also are you on latest version of guard, pretty sure this was fixed in #48

I regularly update plugins, it did happen again recently in a vue3 project. But again, I don't really understand what causes it.

@DrunkenToast
Copy link
Author

DrunkenToast commented Aug 27, 2023

The issue has not occurred anymore since the exit code fix. The only thing that annoys me currently is that undoing makes my cursor jump to the bottom and with prettier it fails very very often even if there is no reason to (which I assume means it sends the wrong buffer as input), but these are separate issues so I'll consider this closed for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants