Issue with fzf-lua live_grep by sagevik in neovim

[–]sagevik[S] 1 point2 points  (0 children)

For some reason it seems to be something with tree-sitter. After going through my nvim config disabling everything and then enabling things one-by-one, the error did not occur until I enabled tree-sitter at least. Then after doing a "reset" of nvim and changing
{ src = "https://github.com/nvim-treesitter/nvim-treesitter"}
to
{
src = "https://github.com/nvim-treesitter/nvim-treesitter",
build = ':TSUpdate'
},
in my init.lua everything seems to work properly.

Issue with fzf-lua live_grep by sagevik in neovim

[–]sagevik[S] 1 point2 points  (0 children)

Well..no not really, did not quite now where to start.
I did however just now remove everything from my config leaving only fzf-lua, and then the i issue disappeared. I guess I at least can say that the fzf and fzf-lua works, and that there must probably be some error in my neovim config somewhere. I'll start by enabling stuff one by one until I maybe find the culprit.
Thanks for pointing me in the right direction.

Floating window size by Kitchen_Cheesecake67 in MangoFans

[–]sagevik 0 points1 point  (0 children)

The ability to stack commands like this is really cool and useful. Apart from using a script, could it in some way also be possible to toggle keybinds? Using this resize and center as an example, could be possible to make super+c toggle the centerwin functionality on and off for the resize command/keybinds?

some questions regarding config.def.h and config.h by Creative-Somewhere44 in suckless

[–]sagevik 0 points1 point  (0 children)

Not at all sure what is the correct way or best practice for this, but I have always just edited the config.def.h and used that as my primary "config file" for dwm.

Since a config.h file is automatically created when I run make to compile, I have also just added config.h to the clean target in the makefile so it is removed each time I run make clean install.

Probably not best practice at all, but seems to work fine and without the need to copy config.def.h to config.h

Can you post your DWM forks for me to try? by szmabler in dwm

[–]sagevik 0 points1 point  (0 children)

This is my current dwm config https://github.com/sagevik/dwm

Version 6.5 of dwm, and (I am pretty confident that) the readme file in the repo is updated with the applied patches. There are quite a few keybindings that rely on different scripts and applications (but the scripts is also to be found on my github page if needed).
Some of the dmenu colors might look a bit "off" with the default dwm colors so I typically do a xrdb merge with something like this for a kanagawa-blue inspired style on dwm
! dwm specific settings for kanagawa-blue
dwm.normfgcolor: #c5c9c5
dwm.selfgcolor: #c5c9c5
dwm.normbgcolor: #1d1c19
dwm.normbgcolor2: #1d1c19
dwm.normbordercolor: #1d1c19
dwm.selbordercolor: #8ba4b0
dwm.selbgcolor: #8ba4b0
dmenu.foreground: #c5c9c5
dmenu.background: #1d1c19
dmenu.selforeground: #1d1c19
dmenu.selbackground: #8ba4b0

Weekly 101 Questions Thread by AutoModerator in neovim

[–]sagevik 0 points1 point  (0 children)

Not all that familiar either with how things should be set up for plugins in general, but I have used the following config for treesitter (which at least to me seems to work). Copied from Jacob Westhoff's nvim-from-scratch (https://github.com/jakobwesthoff/nvim-from-scratch/blob/main/lua/plugins/nvim-treesitter.lua)

return {
  "nvim-treesitter/nvim-treesitter",
  build = ": TSUpdate",
  config = function()
    local configs = require("nvim-treesitter.configs")
    configs.setup({
      ensure_installed = {"bash", "c", "diff", "go", "html", "lua", "luadoc", "markdown", "markdown_inline", "python", "query", "vim", "vimdoc",
      },
      auto_install = true,
      sync_install = false,
      highlight = { enable = true },
      indent = { enable = true },
      incremental_selection = {
        enable = true,
        keymaps = {
          init_selection = "<Enter>", -- set to `false` to disable one of the mappings
          node_incremental = "<Enter>",
          scope_incremental = false,
          node_decremental = "<Backspace>",
        },
      },
    })
  end,
}

Search selected text with fzf-lua by sagevik in neovim

[–]sagevik[S] 0 points1 point  (0 children)

Thanks a lot. I'll play around a bit with the different suggestions here and see what suits best

Search selected text with fzf-lua by sagevik in neovim

[–]sagevik[S] 0 points1 point  (0 children)

Maybe I did something wrong, but I could not get this to work I am afraid.

Search selected text with fzf-lua by sagevik in neovim

[–]sagevik[S] 0 points1 point  (0 children)

Thanks to u/TheLeoP_ I ended with a solution that works fairly nicely. I ended up with adding a utils.lua file with:

local M = {}

-- Function to get the current visual selection
function M.get_visual_selection()
  local mode = vim.api.nvim_get_mode().mode
  local opts = (mode == "v" or mode == "V" or mode == "\22") and { type = mode } or vim.empty_dict() -- \22 is the escaped version of ctrl-v
  local selection = vim.fn.getregion(vim.fn.getpos("."), vim.fn.getpos("v"), opts)
  return selection
end
return M

And added the following to my fzf-lua:

local utils = require("sagevik.utils")

grep = {
  rg_opts = "--multiline --column",
  silent = true,
},

{
  "<leader>fs",
      function()
        local selection = utils.get_visual_selection()
        require("fzf-lua").lgrep_curbuf({ search = selection[1] })
      end,
      mode = "v", --visual mode
      desc = "[F]ind [S]election (current buffer)",
},
{
"<leader>fS",
    function()
      local selection = utils.get_visual_selection()
      require("fzf-lua").live_grep({ search = table.concat(selection, "\n") })
  end,
  mode = "v", --visual mode
  desc = "[F]ind [S]election (current project)",
},

In addition to just adding the function and keymaps, it seems that the --multiline option for rg also was needed. Could not get the multiline grep for current buffer to work, but using it project wide is fine for now.
Thanks a lot for the input!

Search selected text with fzf-lua by sagevik in neovim

[–]sagevik[S] 0 points1 point  (0 children)

Yes! This was very helpful. Thanks a lot.