Comments (8)
It is this line causing the difference:
coc.nvim/src/model/document.ts
Line 349 in 2ec3166
from coc.nvim.
tracked down to line
coc.nvim/autoload/coc/compat.vim
Line 18 in 2ec3166
turns out when format without change, the arguments passed to nvim_buf_set_lines is (bufnr, 1, 1, 0, {})
And i test this function on a buffer, it did change the buffer and create empty change.
From :h nvim_buf_set_lines:
To insert lines at a given index, set
start
andend
to the same index.
To delete a range of lines, setreplacement
to an empty array.
So (bufnr, 1, 1, 0, {})
will do nothing but make an empty change since a:start
is same as a:end
and replacement is empty.
from coc.nvim.
Thank you for your tracking, but I can't reproduce this with your mini.nivm and formatted demo.lua, with coc-sumneko-lua on nvim nightly. And I couldn't reproduce with other language servers too.
from coc.nvim.
The checking fix in #4995 is OK, but I couldn't result any format without change, coc.nvim couldn't run to this check.
from coc.nvim.
@fannheyward Just tested on different version of coc.
coc release branch coc.nvim version: 0.0.82-2ec31666 2024-04-23 09:10:14 +0800
have issue.
coc tag v0.0.82, v0.0.81 doesn't have issue.
from coc.nvim.
I believe this issue was introduced after v0.0.82.
another issue in format is that I have to use call CocAction('format') | sleep 1m
to make it work in BufWritePre
, otherwise the buf sometimes will be in dirty state.
But in v0.0.82, it works well without the need of sleep 1m
.
You can discard this pr, and i will just stick to version v0.0.82.
from coc.nvim.
I believe this issue was introduced after v0.0.82.
Thank you for your tests with different releases of coc, I don't complain your PR, but how to reproduce this, here's my tests:
mkdir -p test-4994
- copy your mini.vim and demo.lua, and empty coc-settings.json. I've removed
@statiolake/coc-stylua
because sumneko-lua already supports formatting, no need to use stylus any more. - When tested with nvim 0.10.0 nightly, I need to add
nvim-treesitter
, otherwise, nvim reports highlighting error
augroup vimrc | autocmd! | augroup end
set nocompatible
set number
set laststatus=2
let g:coc_global_extensions = ['coc-sumneko-lua']
" change this to your local coc.nvim location.
set runtimepath^=/Users/fannheyward/.local/share/nvim/plugged/coc.nvim
set runtimepath^=/Users/fannheyward/.local/share/nvim/plugged/nvim-treesitter
filetype plugin indent on
syntax on
autocmd BufWritePre * call CocAction('format')
command! -nargs=0 Format :call CocActionAsync('format')
set expandtab shiftwidth=4 tabstop=4 softtabstop=4
nvim -u mini.vim demo.lua
, sumneko-lua reportsunused local foo
, the Lua LS is working:call CocAction('format')
, no changes:Format
, no changes:w
to fire autocmd, no changes- Tested with nvim 0.9.5 and 0.10.0 nightly, vim 9.1.0350, same results.
Also I've tested the formatting with tsserver, gopls, rust-analyzer servers, won't change on formatted files.
from coc.nvim.
You can use coc.preferences.formatOnSave
instead of BufWritePre.
from coc.nvim.
Related Issues (20)
- something about jumpback after gD coc-definition HOT 2
- 打开rust文件时, coc报错 HOT 3
- Hover/docstring information with custom sources HOT 2
- 为什么会代码提示会提示两次? HOT 5
- [coc.nvim] Server languageserver.ccls failed to start: Error: expected rootUri HOT 1
- Failed open exsit file with list in vim HOT 5
- The text above get seleted automatically HOT 2
- The documentation has incorrect installation instructions for NeoBundle HOT 1
- How to remove the highlights when using go references HOT 3
- LinkedEditing not work in vim HOT 1
- help: completion of variables from dotenv files in shell scripts HOT 9
- <CR> can not confirm in vimwiki and folding codes failed HOT 4
- coc.nvim takes up two shortcut keys that I prefer to use. HOT 1
- Error on notification "codeAction": code action without data HOT 4
- Asynchronous Completion for `isIncomplete` Items in coc.nvim
- FEAT: Disable all formatting and linting except for what is output by the `languageservers` in coc-settings.json HOT 2
- organizeImport stopped working for months HOT 10
- 执行`rust-analyzer.reload`后报错 HOT 1
- Incorrect cwd when call vim with '-c cd xxx'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coc.nvim.