Skip to content

Commit

Permalink
Run stylua
Browse files Browse the repository at this point in the history
  • Loading branch information
Furkanzmc committed May 3, 2023
1 parent dc140ec commit 728a3b2
Show file tree
Hide file tree
Showing 19 changed files with 232 additions and 179 deletions.
12 changes: 6 additions & 6 deletions ftdetect/firvish.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
vim.cmd [[augroup firvish_ft]]
vim.cmd [[au!]]
vim.cmd [[autocmd BufNewFile,BufRead firvish://buffers setlocal filetype=firvish-buffers]]
vim.cmd [[autocmd BufNewFile,BufRead firvish://history setlocal filetype=firvish-history]]
vim.cmd [[autocmd BufNewFile,BufRead firvish://menu setlocal filetype=firvish-menu]]
vim.cmd [[augroup END]]
vim.cmd([[augroup firvish_ft]])
vim.cmd([[au!]])
vim.cmd([[autocmd BufNewFile,BufRead firvish://buffers setlocal filetype=firvish-buffers]])
vim.cmd([[autocmd BufNewFile,BufRead firvish://history setlocal filetype=firvish-history]])
vim.cmd([[autocmd BufNewFile,BufRead firvish://menu setlocal filetype=firvish-menu]])
vim.cmd([[augroup END]])
18 changes: 9 additions & 9 deletions ftplugin/firvish-buffers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ opt_local.syntax = "firvish-buffers"
opt_local.buftype = "nofile"
opt_local.swapfile = false

require("firvish.config").apply_mappings "buffers"
require("firvish.config").apply_mappings("buffers")

cmd [[command! -buffer -nargs=* -range Bufdo :lua require'firvish.buffers'.buf_do(<line1>, <line2>, <q-args>)]]
cmd([[command! -buffer -nargs=* -range Bufdo :lua require'firvish.buffers'.buf_do(<line1>, <line2>, <q-args>)]])

cmd [[command! -buffer -bang -nargs=* -range Bdelete :lua require'firvish.buffers'.buf_delete(<line1>, <line2>, "<bang>" == "!")]]
cmd([[command! -buffer -bang -nargs=* -range Bdelete :lua require'firvish.buffers'.buf_delete(<line1>, <line2>, "<bang>" == "!")]])

cmd [[augroup neovim_firvish_buffer_local]]
cmd [[autocmd! * <buffer>]]
cmd [[autocmd BufEnter <buffer> lua require'firvish.buffers'.on_buf_enter()]]
cmd [[autocmd BufDelete,BufWipeout <buffer> lua require'firvish.buffers'.on_buf_delete()]]
cmd [[autocmd BufLeave <buffer> lua require'firvish.buffers'.on_buf_leave()]]
cmd [[augroup END]]
cmd([[augroup neovim_firvish_buffer_local]])
cmd([[autocmd! * <buffer>]])
cmd([[autocmd BufEnter <buffer> lua require'firvish.buffers'.on_buf_enter()]])
cmd([[autocmd BufDelete,BufWipeout <buffer> lua require'firvish.buffers'.on_buf_delete()]])
cmd([[autocmd BufLeave <buffer> lua require'firvish.buffers'.on_buf_leave()]])
cmd([[augroup END]])
2 changes: 1 addition & 1 deletion ftplugin/firvish-dir.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ end

vim.opt_local.cursorline = true

require("firvish.config").apply_mappings "dir"
require("firvish.config").apply_mappings("dir")
16 changes: 8 additions & 8 deletions ftplugin/firvish-history.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ opt_local.syntax = "firvish-buffers"
opt_local.buftype = "nofile"
opt_local.swapfile = false

require("firvish.config").apply_mappings "history"
require("firvish.config").apply_mappings("history")

cmd [[augroup neovim_firvish_history]]
cmd [[autocmd! * <buffer>]]
cmd [[autocmd BufEnter <buffer> lua require'firvish.history'.open_history()]]
cmd [[autocmd BufDelete <buffer> lua require'firvish.history'.on_buf_delete()]]
cmd [[autocmd BufWipeout <buffer> lua require'firvish.history'.on_buf_delete()]]
cmd [[autocmd BufLeave <buffer> lua require'firvish.history'.on_buf_leave()]]
cmd [[augroup END]]
cmd([[augroup neovim_firvish_history]])
cmd([[autocmd! * <buffer>]])
cmd([[autocmd BufEnter <buffer> lua require'firvish.history'.open_history()]])
cmd([[autocmd BufDelete <buffer> lua require'firvish.history'.on_buf_delete()]])
cmd([[autocmd BufWipeout <buffer> lua require'firvish.history'.on_buf_delete()]])
cmd([[autocmd BufLeave <buffer> lua require'firvish.history'.on_buf_leave()]])
cmd([[augroup END]])
10 changes: 5 additions & 5 deletions ftplugin/firvish-job-list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ opt_local.modifiable = false
opt_local.readonly = true
opt_local.cursorline = true

require("firvish.config").apply_mappings "job-list"
require("firvish.config").apply_mappings("job-list")

cmd [[augroup firvish_job_list_preview]]
cmd [[autocmd! * <buffer>]]
cmd [[autocmd BufDelete,BufWipeout,WinClosed <buffer> lua require'firvish.job_control'.on_job_list_bufdelete()]]
cmd [[augroup END]]
cmd([[augroup firvish_job_list_preview]])
cmd([[autocmd! * <buffer>]])
cmd([[autocmd BufDelete,BufWipeout,WinClosed <buffer> lua require'firvish.job_control'.on_job_list_bufdelete()]])
cmd([[augroup END]])
10 changes: 5 additions & 5 deletions ftplugin/firvish-job-output.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ local opt_local = vim.opt_local

opt_local.cursorline = true

require("firvish.config").apply_mappings "job-output"
require("firvish.config").apply_mappings("job-output")

cmd [[augroup firvish_job_output_preview]]
cmd [[autocmd! * <buffer>]]
cmd [[autocmd BufDelete,BufWipeout,WinClosed <buffer> lua require'firvish.job_control'.on_job_output_preview_bufdeleter()]]
cmd [[augroup END]]
cmd([[augroup firvish_job_output_preview]])
cmd([[autocmd! * <buffer>]])
cmd([[autocmd BufDelete,BufWipeout,WinClosed <buffer> lua require'firvish.job_control'.on_job_output_preview_bufdeleter()]])
cmd([[augroup END]])
2 changes: 1 addition & 1 deletion ftplugin/firvish-job.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ local opt_local = vim.opt_local

opt_local.cursorline = true

require("firvish.config").apply_mappings "job"
require("firvish.config").apply_mappings("job")
12 changes: 6 additions & 6 deletions ftplugin/firvish-menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ opt_local.syntax = "firvish"
opt_local.buftype = "nofile"
opt_local.swapfile = false

require("firvish.config").apply_mappings "menu"
require("firvish.config").apply_mappings("menu")

cmd [[augroup neovim_firvish_buffer_local]]
cmd [[autocmd! * <buffer>]]
cmd [[autocmd BufEnter <buffer> lua require'firvish.menu'.on_buf_enter()]]
cmd [[autocmd BufDelete,BufWipeout <buffer> lua require'firvish.menu'.on_buf_delete()]]
cmd [[augroup END]]
cmd([[augroup neovim_firvish_buffer_local]])
cmd([[autocmd! * <buffer>]])
cmd([[autocmd BufEnter <buffer> lua require'firvish.menu'.on_buf_enter()]])
cmd([[autocmd BufDelete,BufWipeout <buffer> lua require'firvish.menu'.on_buf_delete()]])
cmd([[augroup END]])

require("firvish.menu").open()
50 changes: 26 additions & 24 deletions lua/firvish.lua
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
local vim = vim
local utils = require "firvish.utils"
local log = require "firvish.log"
local utils = require("firvish.utils")
local log = require("firvish.log")
local M = {}

local options_loaded, options = pcall(require, "options")
if not options_loaded then
log.warning "options.nvim is not installed. See `:help firvish.txt` for disabled features."
log.warning("options.nvim is not installed. See `:help firvish.txt` for disabled features.")
end

if options_loaded then
options.register_option {
options.register_option({
name = "alwayspreview",
type_info = "boolean",
description = "When set to true, the output of the running job will be shown in previewwindow.",
default = false,
source = "firvish",
global = true,
}
})
end

M.open_linedo_buffer = function(line1, line2, source_buffer, cmd, sh_mode)
local lines = vim.api.nvim_buf_get_lines(source_buffer, line1 - 1, line2, true)
local shell = vim.api.nvim_get_var "firvish_shell"
local shell = vim.api.nvim_get_var("firvish_shell")
local extension = "sh"

if sh_mode == false then
Expand All @@ -44,25 +44,25 @@ M.open_linedo_buffer = function(line1, line2, source_buffer, cmd, sh_mode)
vim.api.nvim_buf_set_option(".", "readonly", false)
vim.api.nvim_buf_set_option(".", "buflisted", false)

vim.api.nvim_command "setlocal cursorline"
vim.api.nvim_command("setlocal cursorline")

require("firvish.keymap").nnoremap {
require("firvish.keymap").nnoremap({
"E!",
function()
vim.cmd "silent write"
vim.cmd("silent write")
M.run_commands(vim.fn.bufnr(), sh_mode)
end,
}
})

utils.set_buf_lines(bufnr, command_lines)
vim.api.nvim_command "write"
vim.api.nvim_command("write")

return bufnr
end

M.run_commands = function(bufnr, sh_mode)
if sh_mode == true then
local shell = vim.api.nvim_get_var "firvish_shell"
local shell = vim.api.nvim_get_var("firvish_shell")
local cmd = { shell }
if string.match(shell, "powershell") ~= nil or string.match(shell, "pwsh") ~= nil then
table.insert(cmd, "-NoLogo")
Expand All @@ -73,19 +73,19 @@ M.run_commands = function(bufnr, sh_mode)
table.insert(cmd, "-File")
end

table.insert(cmd, vim.fn.expand "%")
require("firvish.job_control").start_job {
table.insert(cmd, vim.fn.expand("%"))
require("firvish.job_control").start_job({
cmd = cmd,
filetype = "firvish-job",
title = "fhdo",
use_last_buffer = false,
is_background_job = "<bang>" == "!",
listed = true,
}
})
vim.api.nvim_command("bwipeout! " .. bufnr)
else
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, true)
vim.api.nvim_command "wincmd p"
vim.api.nvim_command("wincmd p")
vim.api.nvim_command("bwipeout! " .. bufnr)

for _, line in pairs(lines) do
Expand All @@ -103,33 +103,35 @@ M.filter_lines = function(start_line, end_line, matching, args)
if start_line == end_line then
vim.fn.execute("execute '%g" .. bang .. "/" .. args .. "/d'")
else
vim.fn.execute("execute '" .. start_line .. "," .. end_line .. "g" .. bang .. "/" .. args .. "/d'")
vim.fn.execute(
"execute '" .. start_line .. "," .. end_line .. "g" .. bang .. "/" .. args .. "/d'"
)
end
end

M.open_file_under_cursor = function(nav_direction, preview, reuse_window, vertical)
if reuse_window then
local current_winnr = vim.fn.winnr()
vim.api.nvim_command "wincmd l"
vim.api.nvim_command("wincmd l")
if vim.fn.winnr() ~= current_winnr then
vim.api.nvim_command "normal q"
vim.api.nvim_command("normal q")
end
end

if vertical then
vim.api.nvim_command "vertical normal ^F"
vim.api.nvim_command("vertical normal ^F")
else
vim.api.nvim_command "normal ^F"
vim.api.nvim_command("normal ^F")
end

if preview then
vim.api.nvim_command "wincmd p"
vim.api.nvim_command("wincmd p")
end

if nav_direction == "down" then
vim.api.nvim_command "normal j"
vim.api.nvim_command("normal j")
elseif nav_direction == "up" then
vim.api.nvim_command "normal k"
vim.api.nvim_command("normal k")
end
end

Expand Down
10 changes: 5 additions & 5 deletions lua/firvish/buffers.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local vim = vim
local M = {}
local utils = require "firvish.utils"
local utils = require("firvish.utils")

local s_open_bufnr = -1
local s_buffer_list_dirty = true
Expand All @@ -14,7 +14,7 @@ local function create_buffer_list(predicate)

local buffer_information = vim.fn.getbufinfo()
local buffers = {}
local all_buffers = vim.fn.range(1, vim.fn.bufnr "$")
local all_buffers = vim.fn.range(1, vim.fn.bufnr("$"))
local buf_num_length = #tostring(#all_buffers)

for key, bufnr in ipairs(all_buffers) do
Expand Down Expand Up @@ -62,7 +62,7 @@ local function get_bufnr(linenr)
bufnr = vim.fn.bufnr(buffer_name)

if bufnr == -1 then
utils.log_error "Cannot read buffer number from the list."
utils.log_error("Cannot read buffer number from the list.")
return -1
end

Expand All @@ -86,7 +86,7 @@ M.mark_dirty = function()
end

M.jump_to_buffer = function()
local bufnr = get_bufnr(vim.fn.line ".")
local bufnr = get_bufnr(vim.fn.line("."))
if bufnr == -1 then
return
end
Expand All @@ -103,7 +103,7 @@ M.open_buffers = function()
local tabnr = vim.fn.tabpagenr()

if vim.fn.bufexists(s_open_bufnr) == 0 then
vim.api.nvim_command "e firvish://buffers"
vim.api.nvim_command("e firvish://buffers")
s_open_bufnr = vim.fn.bufnr()

M.refresh_buffers()
Expand Down

0 comments on commit 728a3b2

Please sign in to comment.