Skip to content

Commit

Permalink
Add stylua integration (#21)
Browse files Browse the repository at this point in the history
* chore(root): Add stylua config

* style(init): Change formatting

* style(utils): Change formatting
  • Loading branch information
NikolaM-Dev authored Dec 1, 2023
1 parent 38db46b commit 3402c51
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
13 changes: 8 additions & 5 deletions lua/browse/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ local browse = function(config)

finder = finders.new_table({
results = {
{ "Bookmarks Search", "bookmarks" },
{ "Devdocs Search", "devdocs" },
{ "Bookmarks Search", "bookmarks" },
{ "Devdocs Search", "devdocs" },
{ "Devdocs Search with filetype", "devdocs_file" },
{ "Input Search", "input" },
{ "MDN Web Docs", "mdn" },
{ "Input Search", "input" },
{ "MDN Web Docs", "mdn" },
},
entry_maker = function(entry)
return {
Expand All @@ -52,7 +52,10 @@ local browse = function(config)
local browse_selection = selection["ordinal"]

if browse_selection == "bookmarks" then
search_bookmarks({ bookmarks = bookmarks, visual_text = visual_text })
search_bookmarks({
bookmarks = bookmarks,
visual_text = visual_text,
})
elseif browse_selection == "input" then
search_input(visual_text)
elseif browse_selection == "devdocs" then
Expand Down
27 changes: 15 additions & 12 deletions lua/browse/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ local get_os_name = function()
return os_name
end

-- WSL
local is_wsl = function ()
local output = vim.fn.systemlist "uname -r"
-- WSL
local is_wsl = function()
local output = vim.fn.systemlist("uname -r")
return not not string.find(output[1] or "", "WSL")
end

Expand All @@ -24,9 +24,9 @@ local get_open_cmd = function()
open_cmd = { "open" }
else
if is_wsl() then
open_cmd = { "wsl-open" }
open_cmd = { "wsl-open" }
else
open_cmd = { "xdg-open" }
open_cmd = { "xdg-open" }
end
end
return open_cmd
Expand Down Expand Up @@ -78,14 +78,17 @@ end
M.search = function(target_fn, opts)
local prompt = opts and opts.prompt or "Search String:"
local default = opts and opts.visual_text or ""
vim.ui.input({ prompt = prompt, default = default, kind = "browse" }, function(input)
if input == nil or input == "" then
return
end
vim.ui.input(
{ prompt = prompt, default = default, kind = "browse" },
function(input)
if input == nil or input == "" then
return
end

local escaped_input = escape_target(vim.fn.trim(input))
M.default_search(target_fn(escaped_input))
end)
local escaped_input = escape_target(vim.fn.trim(input))
M.default_search(target_fn(escaped_input))
end
)
end

-- a generic searching closure util
Expand Down
6 changes: 6 additions & 0 deletions stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
call_parentheses = "Always"
column_width = 80
indent_type = "Spaces"
indent_width = 4
line_endings = "Unix"
quote_style = "ForceDouble"

0 comments on commit 3402c51

Please sign in to comment.