I look forward to this series every day. Thank you TJ
@cag111 күн бұрын
same
@avramukk11 күн бұрын
me too)
@yuxiang421811 күн бұрын
+1
@echobucket11 күн бұрын
The biggest problem people will usually run into that you didn't cover is when languages don't have LSP based formatting, but instead have command line based formatting tools. So you probably should also cover how to set those up (which has been in vim forever). I kind of wish there was a built in abstraction for formatting in neovim over both mechanisms.
@cubiccode386710 күн бұрын
He kinda of hints it in the end of the video when he says that lua is a programming language
@pmmeurcatpics3 күн бұрын
Isn't that exactly what null-ls does?
@heian1717 сағат бұрын
Just set `formatprg` to name of a program
@demolazer11 күн бұрын
I switched from VS Code to Neovim a few months back, installed Kickstarter and was blown away by the LSP and environment. Thank you TJ and code, you made coding amazing. My colleague trying to encourage VS code cos of some tooling in there, I lasted an hour. Like coding with one hand. Even with the vim plugin.
@Luclecool12311 күн бұрын
Love this series! thank you so much for your work
@asd121asd10 күн бұрын
Went over all advent of nvim videos up to date and liked those. Keep 'em coming!
@examinethose11 күн бұрын
another day another line of code saying "Hey!"
@yogxoth195910 күн бұрын
I don’t understand where you put the editorconfig file so the LSP in Neovim respects it for every project?
@DavRambo8 күн бұрын
Have you tried putting one in your home directory?
@hackerware_sh11 күн бұрын
Great series so far! ❤ I’m wondering what’s generally your reasoning wether to use the vim (api) “native way” to do things vs to use a plugin that has slightly more functionality (in this particular case conform). I realize this is a beginners series, but generally speaking… Thanks!
@jorgeimo11 күн бұрын
This is awesome! The config I have to format on save is a fucking mess, now I know how to make it better 😎 Thanks TJ!
@dadinhoschannel400311 күн бұрын
This man is on fire!
@taetaebahohiningamo11 күн бұрын
Next vid: Linting made easy
@teej_dv11 күн бұрын
very speedy reply, nice work :)
@gustavoviana550811 күн бұрын
Please more of these thank you
@Bvngee9 күн бұрын
I would love if you considered covering non-lsp-based formatters at some point :P (and the plugins that integrate with them, i.e. conform.nvim) great series!!
@WeshalbDennNicht11 күн бұрын
What is the benefit of using .editorconfig vs. implementing a ftplugin for lua, specifying the wanted shiftwidth? Because the ftplugin would be nvim-only and the .editorconfig also works für lua-ls? Keep up the great videos! 🙂
@hoxefko11 күн бұрын
.editorconfig is compatible with more editors and you can put it in a git repository to keep consistency of format among every project member ;-)
@m.ihnatenko11 күн бұрын
2:46 Out of curiosity. Wouldn't it be simpler to pass vim.lsp.buf.format instead of wrapping it into a function and then calling format inside of it? Or am I missing something?
@hoxefko11 күн бұрын
so are conform.nvim and that kind of plugins useless these days? or they are something to extend the formatting feature? I'm lost in this part of Neovim
@LinuxCook11 күн бұрын
Plugins like conform.nvim enable integration with third-party formatters. The formatting method demonstrated by TJ in this video relies on the LSP's textDocument/formatting endpoint, which may be limited or unavailable for some language servers. To use standalone formatters such as stylua for Lua, prettier for JavaScript, ruff for Python, or clang-format for C, you need to integrate these tools separately. A plugin like conform.nvim can simplify hooking into these external formatters.
@hoxefko11 күн бұрын
@@LinuxCook thanks so much for your explanation :-)
@avramukk11 күн бұрын
Awesome. Thank you.
@ivanaytzhanov88467 күн бұрын
I have very similar setup with formatting on save and *sometimes* it just doesn't work. I save a file and formatting just does not fire
@miyalys4 күн бұрын
There needs to be an LSP available for the current file type, that supports code formatting. If it inconsistently works for the same format that is strange.
@ivanaytzhanov88464 күн бұрын
@miyalys I have a key binding that calls exactly the same `format` function and it works
@leonardodavinci285611 күн бұрын
is there any plugin to auto import stuff in neovim like in cursor ai . it automatically suggests and with single tap boom everything that was not imported is imported it
@miyalys4 күн бұрын
Some LSPs support automatic importing via code actions.
@CNich9010 күн бұрын
You also applied the formatting to your hair…fresh cut!
@andriesvanwyk322611 күн бұрын
Thanks TJ! Question: Any idea why using something like Prettier formatting in VSCode and Neovim would give different results? A colleague of mine is on Mac + VSCode and I'm on linux + Neovim. We can't get prettier to format the exact same way. We are working in Angular. From what I can tell, the Typescript files are relatively the same, except for an extra line at the end of the file in VSCode. The html file formatting is quite significantly different. And yes, all other formatting options and plugins have been disabled. We merely have a .editorconfig file. If you know of anything, would really appreciate it, thanks!
@maleldil110 күн бұрын
Have you tried running Prettier on the CLI? Is the result the same of either VS Code or Neovim?
@guitarhero6911 күн бұрын
at 4:32 what did teej do? how did he get the diagnostic fix by typing "gra"
@WeshalbDennNicht11 күн бұрын
"gra" (in normal mode) is the default mapping for LSP code actions (see previous video of the series on LSP), which he uses here the show the available code actions and select the appropriate one do disable the diagnostic warning.
@teej_dv11 күн бұрын
Exactly right.
@nazarzibilyuk15116 күн бұрын
I just wander, Error like: 'attempt to index field 'completion' (a nil value) is a result of me using nvim 0.10 and not 0.11?
@СергейЛюбимов-у3ф11 күн бұрын
Thank you for the video, teej. Could you, please, explain, how to set up own rules for code formatting? I.e. what if I need to use only single quotes instead of double quotes and my default code.format produces double quotes?
@moussaadem793311 күн бұрын
some language servers look for a configuration file (such as tsconfig.json in the case of the typescript language server) and some send a "workspace/configuration" request to neovim, which you can specify when you setup the lsp, example lspconfig.tsserver.setup { settings = { javascript = { format = { semicolons = "insert" -- etc... } } } }
@biffandhapp41811 күн бұрын
I'm not sure but I think you should have gotten bufnr from the args in the BufWritePre callback, not the LspAttach callback. When I use your code the formatted code seems to go in the wrong buffer if more than one buffer is open. Either that or I am doing something really wrong and can't see it.
@tekladongmekanikal56729 күн бұрын
I think the error code on the vim.lsp.Client function supports_method is missing self cause your using (.) not (:).
@THIRSTYGNOME11 күн бұрын
I like my LSP formatting to be under a hotkey so i don't accidentally format co-workers files.
@ArdentInfoSec11 күн бұрын
Absolutely loving this series. Been using vim since Yoda was a boy and learning something new each day so far. I have been following along with the series day-by-day, right down to building from scratch and isolating this config from my usual working setup. All was going well until today, when I simply do not have the same `:help lsp` result as Teej. at 3:20 - `/format` & nnnnn'd to 8/57 line 119 and the boilerplate code used in the example just isn't the same for me. I'm on v0.10.2 freshly built. The code example for me doesn't have the 'textDocument/formatting' example below 'rename' & 'implementation'. It's not a massive issue to get to the result I need, but it makes following along a bit challenging when it's done so fast and you don't get the same results... (I can see this very easily because 'textDocument/formatting' only appears once in my version of `:help lsp`) I wonder if the demo is on a different tag of NeoVim...
@ArdentInfoSec8 күн бұрын
I see this was related to changes in the v0.11.0-dev version of nevovim.
@mnk4allcaps11 күн бұрын
he got a hair cut
@teej_dv11 күн бұрын
True. Thanks for noticing 😁
@muizzyranking11 күн бұрын
I've always pronounced teej as tee jay.
@teej_dv11 күн бұрын
Actually, my initials are TJ. So lots of ppl call me that. Teej is a Nickname of a nickname
@abdulalimmahir11 күн бұрын
Please get out of Fireships influence, let's make 15-20 minutes video. Me loving this series
@Ryuujin102411 күн бұрын
It's great to see this but my goodness what a lot of work for something so basic. Ctrl + alt + L for IntelliJ Ctrl + shift + l for vs Code.
@zeyadalaa801510 күн бұрын
You can map your vim.lsp.buf.format() function to your desired shortcut as shown in the video so it’ll do what those do. In Intellij for example, the concept is the same except that the default settings there are already specified for Java according to “some conventions” which you can either modify yourself or use a configuration file (check out a plugin called checkstyle) Here in neovim, you’re building up exactly the same thing with your own configs how you like them instead of using something that someone else has done for you (ex. Intellij devs) which is the whole point of using something like neovim as an editor ;)
@miyalys4 күн бұрын
You get more fleshed out default functionality and binds - including code formatting - if you use something like LunarVim, SpaceVim or NVChad. Ie. preconfigured neovim distros.