aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Coquand <marc@baemingo.com>2023-05-22 18:07:18 -0500
committerMarc Coquand <marc@baemingo.com>2023-05-22 18:07:18 -0500
commit1cdfa026cf1f6bbb877f9cd80a0bf563aaf1a21d (patch)
tree61b172d87918d72274c81233077e92d389d992b2
parent8c2d0505185b86fd73e8637577121f0a96596bc5 (diff)
downloadBufferBrowser-1cdfa026cf1f6bbb877f9cd80a0bf563aaf1a21d.tar.gz
BufferBrowser-1cdfa026cf1f6bbb877f9cd80a0bf563aaf1a21d.tar.bz2
BufferBrowser-1cdfa026cf1f6bbb877f9cd80a0bf563aaf1a21d.zip
Add check for filetype
-rw-r--r--lua/buffer_browser.lua16
1 files changed, 8 insertions, 8 deletions
diff --git a/lua/buffer_browser.lua b/lua/buffer_browser.lua
index 701e500..c9ab6d7 100644
--- a/lua/buffer_browser.lua
+++ b/lua/buffer_browser.lua
@@ -22,7 +22,7 @@ local function matchesFilter(filters, name)
end
-local function StateAppend(bufNr, stateFiletype, state, filters)
+local function stateAppend(bufNr, stateFiletype, state, filters)
if (state.current == bufNr) then
return state
end
@@ -40,7 +40,7 @@ local function StateAppend(bufNr, stateFiletype, state, filters)
end
end
-local function StateGoBack(state)
+local function stateGoBack(state)
-- Go back in the state by setting current to the first element of previous, and appending the current to the future
-- Check if past is empty, if so return state as is
if #state.previous == 0 then
@@ -52,7 +52,7 @@ local function StateGoBack(state)
return state
end
-local function StateGoForward(state)
+local function stateGoForward(state)
-- Go forward in the state by setting current to the first element of future, and appending the current to the previous
-- Check if future is empty, if so return state as is
@@ -136,8 +136,8 @@ local function getBufNr()
end
local function getFiletype(bufnr)
- if (bufnr == nil) then
- return ''
+ if (bufnr == nil and vim.bo[bufnr] == nil) then
+ return nil
end
return vim.bo[bufnr].filetype
end
@@ -153,7 +153,7 @@ function BufferBrowserBufferEnter(args)
else
if (state.current ~= bufNr) then
local stateFiletype = getFiletype(state.current)
- StateAppend(bufNr, stateFiletype, state, filters)
+ stateAppend(bufNr, stateFiletype, state, filters)
setState(state)
end
end
@@ -200,7 +200,7 @@ local function next()
if stateIsEmpty(state) then
initState(bufnr)
else
- StateGoForward(state)
+ stateGoForward(state)
setState(state)
end
api.nvim_command('buffer ' .. state.current)
@@ -213,7 +213,7 @@ local function prev()
if stateIsEmpty(state) then
initState(bufnr)
else
- StateGoBack(state)
+ stateGoBack(state)
setState(state)
end
api.nvim_command('buffer ' .. state.current)