Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option for working from buffers #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions lua/instant.lua
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,12 @@ end

local function StartClient(first, appuri, port)
local v, username = pcall(function() return vim.api.nvim_get_var("instant_username") end)
local work_from_buffer = pcall(function() return vim.api.nvim_get_var("instant_work_from_buffer") end)

if not work_from_buffer then
work_from_buffer = 0
end

if not v then
error("Please specify a username in g:instant_username")
end
Expand Down Expand Up @@ -1419,8 +1425,9 @@ local function StartClient(first, appuri, port)
vim.api.nvim_command("doautocmd BufRead " .. vim.api.nvim_buf_get_name(buf))
end)
end

vim.api.nvim_buf_set_option(buf, "buftype", "")
if not work_from_buffer then
vim.api.nvim_buf_set_option(buf, "buftype", "")
end

end

Expand Down Expand Up @@ -2813,8 +2820,18 @@ local function Join(host, port)
autocmd_init = true
end

local work_from_buffer = pcall(function() return vim.api.nvim_get_var("instant_work_from_buffer") end)

if not work_from_buffer then
work_from_buffer = 0
end

local buf = vim.api.nvim_create_buf(true, false)

if work_from_buffer then
vim.api.nvim_buf_set_option(buf, "buftype", "nofile")
end

vim.api.nvim_win_set_buf(0, buf)

singlebuf = buf
Expand Down