u/brokenreed5

41 post karma · 237 comment karma · joined Feb 2017

brokenreed5

If you think it makes your editor laggy, https://neovim.io/doc/user/treesitter/#vim.treesitter.stop()) is your friend.

brokenreed5

In some case you can use tee. Tee can redirect the input to a file or stdio while also being able to pipe it to ur desired prog. I dabbled with it in the past and got it working. Can't do it with char wise selection though as others mentioned. In this case a user command could work but shell escaping as well as text Insertion would have to be handled yourself

brokenreed5

Super intelligence aber kein Text align :(

brokenreed5

You found the smoking gun. That's real, but more importantly it shows you are genuinely learning.

brokenreed5

Thanks! I only searched help and not news.

brokenreed5

@@ repeats the last used macro while old Q used the last recorded macro

brokenreed5

But how? Mapping Leader Q to new Q behaviour is easy, but how do you get back the old Q behavior?

brokenreed5

your right, with the latest nvim it works better. But i still have an issue with the following. from "x" mode selecting all gives an extra cursor at the current position and as well as at the start of selection. the same for normal mode. e.g. foo<cursor>bar, inserts cursors in front of every foo, but leaves my cursor before bar. e.g. select all -> insert mode does not work as expected. I think the desired behaviour is similar to (*1Q) in normal and x mode.

I came up with this version which auto q= and removes highlighting. im not sure why the vim.schedule is needed tbh, but it seemed like * is not processed synchronously, if someone cares to explain

vim.keymap.set({ "x", "n" }, "<leader>kk", function()
local mode = vim.fn.mode() == "n" and "n" or "x"
-- make sure to feed the * in the current mode, since normal mode "*" acts differently than x mode "*"
vim.api.nvim_feedkeys("*", mode, false)
-- need to wait for processing of nvim_feedkeys it seems 
vim.schedule(function ()
vim.cmd("normal!1Qq=")
vim.cmd("nohlsearch")
end)
end)
brokenreed5

Sie spielte offensichtlich darauf an, dass sie nicht Jurist sondern Juristin ist /s

brokenreed5

It does not work for me. Val selects all lines. 1Q then puts a cursor on each beginning of those lines. Simple 1Q without Val works

brokenreed5
--- Place a cursor and then perform a motion
--- u/param opts? {visual_mode?: boolean}
local select_all = function(opts)
local lopts = opts or {}
if lopts.visual_mode then
local selection = vim.fn.getregion(vim.fn.getpos("v"), vim.fn.getpos("."))
vim.fn.setreg("/", "\\V" .. table.concat(selection, "\\n"))
vim.api.nvim_feedkeys("v`<", "n", false)
else
vim.api.nvim_feedkeys("wb", "n", false) -- move to the beginning of the word and place a cursor
vim.fn.setreg("/", "\\V\\<" .. vim.fn.expand("<cword>") .. "\\>") -- set search pattern to the current word
end
local pos = vim.api.nvim_win_get_cursor(0)
vim.api.nvim_feedkeys("Val1Q", "n", false)
vim.schedule(function()
vim.api.nvim_win_set_cursor(0, pos) -- place cursor back in its original position before placing cursors on the whole document
end)
end

vim.api.nvim_feedkeys("Val1Q", "n", false)

does not seem right. also stale doc comment

brokenreed5

I really like that a Human made this very insightful video and the very human first response. Is anyone interested in chatting at www.wikiservice.at/dse ?

brokenreed5

I don't want to miss Django-cotton

brokenreed5

try this. row and col are hardcoded for now but can be replaced by an api call for the cursor position. buffnr is the number of the buffer you want (0 in most cases for the current buffer)
Make sure to use the right indexing for col and row.

local function walk(node, field)
  if vim.treesitter.node_contains(node,{row,col, row,col}) then
  local type = node:type()
  local ok, text = pcall(vim.treesitter.get_node_text, node, bufnr)
  print("------type " ..type.. " with fields " ..(field or "").."-----------")
  print(text)
  print("-------end of node -----------")
  for child, field in node:iter_children() do
    walk(child, field)
  end
  end
end
local lang = vim.treesitter.language.get_lang(vim.bo[bufnr].filetype)
bufnr=2
row = 24 -- 0 indexed
col = 0 -- 0 indexed
parser= vim.treesitter.get_parser(bufnr)
gnode = nil
local tree = parser:parse()[1]
local root = tree:root()
for node, field in root:iter_children() do
  print(field)
  walk(node, field)
end

this walks the AST of the treesitter root. it will give you the nodes which contain the row/col.

If you are interested in the highlight group of your current position instead of the pure AST/grammar use

bufnr=2
row = 22 -- 0 indexed
col = 4 -- 0 indexed
parser= vim.treesitter.get_parser(bufnr)
gnode = nil
local tree = parser:parse()[1]
local root = tree:root()
local lang = vim.treesitter.language.get_lang(vim.bo[bufnr].filetype)
local query = vim.treesitter.query.get(lang, "highlights")
for id, node, _ in query:iter_captures(root, bufnr) do
  if vim.treesitter.node_contains(node,{row,col, row,col}) then
  local name = query.captures[id]
  local type = node:type()
  local ok, text = pcall(vim.treesitter.get_node_text, node, bufnr)
  print("-------"..name.." of type " ..type.."-----------")
  print(text)
  print("-------end of node -----------")
  end
end

other interesting queries are "indents" or if installed "textobjects"

brokenreed5

i dont get it. why dont you swap the nav in using hx-select-oob or send it via hx-swap-oob="true"?

<button 
  hx-get="blog/"
  hx-swap="outerHTML"
  hx-select-oob="#header, #nav"
  hx-select="#main"
  hx-target="#main"
>
  Fetch blog
</button>

with your response being

<header id="header" >Blog</header>
 <nav id="nav" >
 <ul>
 <li><strong>Blog</strong></li>
  <li>Main</li>
 </ul>
<p id="main" >This is the blog content</p>

and if you dont like defining hx-select-oob you can use hx-swap-oob, you define it once in your base and thats it

        <button 
          hx-get="blog/"
          hx-swap="outerHTML"
          hx-select="#main"
          hx-target="#main"
        >
          Fetch blog
        </button>

with the response

<header id="header" hx-swap-oob="true"> Blog</header>
<nav id="nav" hx-swap-oob="true" >
<ul>
<li><strong>Blog</strong></li>
<li>Main</li>
</ul>
<p id="main" >This is the blog content</p>
brokenreed5

4

brokenreed5

ok, than the green arrow is kinda misleading in my opinion.
If my "project is not setup enough with MyPy. This is the most important part", do you mind sharing it.

brokenreed5

the autocomplete looks like buffer / textcomplete and not lsp complete. Following your guide didn't give me query complete like your screenshot suggests

brokenreed5

thanks for the article. It might give me the motivation to implement some heavier macros myself.

Somewhat unrelated: How do you format your code snippets in the blog post? I've been experimenting a little bit myself with creating a blog, and the "easiest" way seemed to use :TOhtml and insert the result as Iframe, but you seem to use a different way.

brokenreed5

had this issue myself before. for components its a good reminder to disinherit on the top scope so the behaviour is limited in scope as intended and rather pass "inherited" values explicitly.

brokenreed5

i hate the reaction shots so much

brokenreed5

Git stores not two copies of each file but possibly much more. Each commit contains the modified files in full (though compressed). To be more specific, each changed file is stored as a blob and the commit specifies which blobs belong to the commit. Checking out a branch or commit is getting these files. So first of, there might no be much gains from your suggestions, secondly VFS describes itself as

VFS stands for Virtual File System. VFS for Git virtualizes the file system beneath your Git repository so that Git and all tools see what appears to be a regular working directory, but VFS for Git only downloads objects as they are needed. VFS for Git also manages the files that Git will consider, to ensure that Git operations such as status, checkout, etc., can be as quick as possible because they will only consider the files that the user has accessed, not all files in the repository.

Which reads much differently then your summary.

I recommend reading the repository, cause it cleary states that VFS for Git is deprecated and microsoft/scalar should be used instead. Now, microsoft/scalar is also deprecated and says its functionality has been moved to https://github.com/microsoft/git . Microsoft git is active and also support Linux

They state

Well, because Git is a distributed version control system, each Git repository has a copy of all files in the entire history. As large repositories, aka monorepos grow, Git can struggle to manage all that data. As Git commands like status and fetch get slower, developers stop waiting and start switching context. And context switches harm developer productivity.

microsoft/git is focused on addressing these performance woes and making the monorepo developer experience first-class. The Scalar CLI packages all of these recommendations into a simple set of commands.

brokenreed5

Die mit Kohle wissen genau was sie damit machen wollen: Es behalten!

brokenreed5

did you try https://github.com/tpope/vim-dadbod and if so what was lacking?

brokenreed5

yeah, those other parents should definitley check on their children, luckily mine is smart/can swim/whatever so I dont have to.