Coder Social home page Coder Social logo

Toggle last nvchad.term about nvchad HOT 4 CLOSED

t1gu1 avatar t1gu1 commented on May 28, 2024
Toggle last nvchad.term

from nvchad.

Comments (4)

t1gu1 avatar t1gu1 commented on May 28, 2024 2

Oh, i finally create a custom solution.

local lastTermIdUsed = 1

map({ "n" }, "<leader>t", function()
	require("nvchad.term").toggle({ pos = "float", id = lastTermIdUsed })
end, { desc = "Terminal Toggle Floating" })

for id = 1, 9 do
	map({ "n" }, id .. "<leader>t", function()
		require("nvchad.term").toggle({ pos = "float", id = id })
		lastTermIdUsed = id
	end, { desc = "Terminal Toggle to " .. id })
end

Finally the feature request could simply be a method that could return the last used terminal id number. (Maybe usefull for other case external to keymaps)

from nvchad.

siduck avatar siduck commented on May 28, 2024 1

@TirtharajPramanik you can do this yourself, just make an autocmd

vim.api.nvim_create_autocmd({ "TermOpen" }, {
  callback = function(args)
    local buf = args.buf
    -- now do your stuff here
  end
})

from nvchad.

siduck avatar siduck commented on May 28, 2024

It's currently not possible to open the last open terminal if we don't know his ID.

nvchad.term needs an id at least... or else how would you toggle? or just loop through vim.g.nvchad_terms table, it has info of all terminals with their opts & buf etc. and then get info of each buf upto your matching & toggle it by sending its opts as arg

from nvchad.

t1gu1 avatar t1gu1 commented on May 28, 2024

@siduck Would it be a nice and simple idea to keep track of the last active term id?

With something like vim.g.nvchad_active_term_id

I would contribute that simple change, but I don't find the NvChad's terminal module O.o

OR

Maybe simply paste my example in the Doc to help others that would want to do that. (At least I added something in the help channel in discord with the resolve tag and my solution)

from nvchad.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.