Comments (7)
Hello, I think, you have 'shiftwidth' equals 0 for filetype 'lua'.
Indent calculating on value of 'shiftwidth'.
Try :lua =vim.bo.shiftwidth
. If it will be '0', set option shiftwitdh
bigger than 0 in your init.lua.
from treesj.
Thank you for the quick response.
Yes it's true i have shiftwith = 0
because when zero, it defaults to tabstop
. And I have tabstop = 4
.
Interestingly, when inside e.g..js
or .py
files, the indent works properly with shiftwith = 0
. Is this intended, that .lua
files are treated differently?
Setting shiftwith to 4 would solve my problem, however I like having shiftwith
bound to my tabstop
. If it's not too complicated, I'd love to see a fix but otherwise i'll just change my shiftwith value.
Great plugin by the way ❤️
from treesj.
Thanks for feedback.
I not sure what it needs to be fixed, because shiftwidth
is a default for builtin neovim indent engine.
Try set expandtab
to false – it will save tabs instead of spaces and you can use shiftwidth
.
Is this intended, that .lua files are treated differently?
I think, it sets by neovim's directly. Neovim have builtin preset for different filetypes.
from treesj.
Yes it's true, shiftwith
is a default. However you can not take that value literally.
Output from :help shiftwith
:
Number of spaces to use for each step of (auto)indent.
Used for 'cindent', >>, <<, etc. When zero the 'ts' value will be used.
That means, whenever shiftwidth
is set to zero, the true value of shiftwidth is the value of tabstop
. The zero just denotes, that tabstop and shiftwith are bound together.
You're using the shiftwidth literally in two palces:
Line 368 in 023db2f
treesj/lua/treesj/treesj/init.lua
Line 72 in 10aed3c
An additional check like the following would solve the issue:
if shiftwidth == 0 then
shiftwidth = vim.api.nvim_buf_get_option(0, 'tabstop')
end
I'd do a PR, but i don't understand the logic of your plugin. Do when do you use the calc_indent()
and when the build_tree()
function? Do you need to change it in both places? I guess you have a better understanding of that.
from treesj.
I think, it sets by neovim's directly. Neovim have builtin preset for different filetypes.
You're right with that. The global value was overwritten by ftplugin. Thanks for the clarification
from treesj.
That means, whenever
shiftwidth
is set to zero, the true value of shiftwidth is the value oftabstop
. The zero just denotes, that tabstop and shiftwith are bound together.
I use shiftwidth
in a logic way – because it about indentation. tabstop
it only about width of tabulation.
I'll learn a little more about interconnections of tabstop
and shiftwidth
. At the moment, sw
looks the best values for use.
from treesj.
An additional check like the following would solve the issue:
if shiftwidth == 0 then shiftwidth = vim.api.nvim_buf_get_option(0, 'tabstop') end
The shiftwidth()
function returns the effective value of 'shiftwidth'
; see :h shiftwidth()
.
from treesj.
Related Issues (20)
- Allow fallback when no node is found HOT 2
- Adds semicolon at the end of function declarations in Rust
- [BUG] Incorrect behaviour for toggling Ruby blocks HOT 2
- Join adds unnecessary space for empty Lua table HOT 1
- Join adds unnecessary commas and spaces, in Python HOT 2
- [Feature Request]: Toggle between <a></a> and <a /> (if tag is empty) in HTML/JSX etc. HOT 1
- Paranthesized expression support for Rust HOT 1
- Fix tests that fail
- module 'treesj' not found HOT 2
- FR: when on comment, just run `gqq` HOT 9
- Can only split/join/toggle once HOT 11
- Cant disable the preset keybindings. HOT 4
- Typescript: Split/Join some arrow functions results in invalid code HOT 1
- Error when Running Lua Config from README
- [TreeSJ]: Cannot join "table_constructor" containing node from one of this: { "commend" } HOT 3
- Allow ignoring the max join length for single calls HOT 1
- Fallback to `mini.splitjoin` HOT 2
- [golang] "The current node is already splitted" when attempting to split a multiline statement HOT 1
- JS/TS: split-join should support curly-less if statements HOT 2
- Is `nvim-treesitter` still a dependency? HOT 2
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 treesj.