diff --git a/.config/awesome/desktop/rc.lua b/.config/awesome/desktop/rc.lua index 3fd15213..e57bd7bc 100644 --- a/.config/awesome/desktop/rc.lua +++ b/.config/awesome/desktop/rc.lua @@ -33,20 +33,20 @@ require("awful.hotkeys_popup.keys") local weather_file = '/home/kristofers/.config/awesome/weather' -- absolute path to `weather` file -- see if the file exists local function file_exists(file) - local f = io.open(file, "rb") - if f then f:close() end - return f ~= nil + local f = io.open(file, "rb") + if f then f:close() end + return f ~= nil end -- get all lines from a file, returns an empty -- list/table if the file does not exist local function lines_from(file) - if not file_exists(file) then return {} end - local lines = {} - for line in io.lines(file) do - lines[#lines + 1] = line - end - return lines + if not file_exists(file) then return {} end + local lines = {} + for line in io.lines(file) do + lines[#lines + 1] = line + end + return lines end local weather_output = lines_from(weather_file) @@ -59,24 +59,24 @@ local longitude = tonumber(weather_output[3]) -- Check if awesome encountered an error during startup and fell back to -- another config (This code will only ever execute for the fallback config) if awesome.startup_errors then - naughty.notify({ preset = naughty.config.presets.critical, - title = "Oops, there were errors during startup!", - text = awesome.startup_errors }) + naughty.notify({ preset = naughty.config.presets.critical, + title = "Oops, there were errors during startup!", + text = awesome.startup_errors }) end -- Handle runtime errors after startup do - local in_error = false - awesome.connect_signal("debug::error", function(err) - -- Make sure we don't go into an endless error loop - if in_error then return end - in_error = true + local in_error = false + awesome.connect_signal("debug::error", function(err) + -- Make sure we don't go into an endless error loop + if in_error then return end + in_error = true - naughty.notify({ preset = naughty.config.presets.critical, - title = "Oops, an error happened!", - text = tostring(err) }) - in_error = false - end) + naughty.notify({ preset = naughty.config.presets.critical, + title = "Oops, an error happened!", + text = tostring(err) }) + in_error = false + end) end -- }}} @@ -99,42 +99,42 @@ modkey = "Mod4" -- Table of layouts to cover with awful.layout.inc, order matters. awful.layout.layouts = { - awful.layout.suit.tile, - awful.layout.suit.spiral.dwindle, - awful.layout.suit.spiral, - --awful.layout.suit.floating, - --awful.layout.suit.tile.left, - --awful.layout.suit.tile.bottom, - --awful.layout.suit.tile.top, - awful.layout.suit.fair, - --awful.layout.suit.fair.horizontal, - --awful.layout.suit.max, - --awful.layout.suit.max.fullscreen, - --awful.layout.suit.magnifier, - --awful.layout.suit.corner.nw, - --awful.layout.suit.corner.ne, - --awful.layout.suit.corner.sw, - --awful.layout.suit.corner.se, + awful.layout.suit.tile, + awful.layout.suit.spiral.dwindle, + awful.layout.suit.spiral, + --awful.layout.suit.floating, + --awful.layout.suit.tile.left, + --awful.layout.suit.tile.bottom, + --awful.layout.suit.tile.top, + awful.layout.suit.fair, + --awful.layout.suit.fair.horizontal, + --awful.layout.suit.max, + --awful.layout.suit.max.fullscreen, + --awful.layout.suit.magnifier, + --awful.layout.suit.corner.nw, + --awful.layout.suit.corner.ne, + --awful.layout.suit.corner.sw, + --awful.layout.suit.corner.se, } -- }}} -- {{{ Menu -- Create a launcher widget and a main menu myawesomemenu = { - { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end }, - { "manual", terminal .. " -e man awesome" }, - { "edit config", editor_cmd .. " " .. awesome.conffile }, - { "restart", awesome.restart }, - { "quit", function() awesome.quit() end }, + { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end }, + { "manual", terminal .. " -e man awesome" }, + { "edit config", editor_cmd .. " " .. awesome.conffile }, + { "restart", awesome.restart }, + { "quit", function() awesome.quit() end }, } mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, - { "open terminal", terminal } + { "open terminal", terminal } } }) mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, - menu = mymainmenu }) + menu = mymainmenu }) -- Menubar configuration menubar.utils.terminal = terminal -- Set the terminal for applications that require it @@ -148,380 +148,380 @@ menubar.utils.terminal = terminal -- Set the terminal for applications that requ mytextclock = wibox.widget.textclock() local cw = calendar_widget({ - theme = 'nord', - placement = "top_right", - previous_month_button = 4, - next_month_button = 5, + theme = 'nord', + placement = "top_right", + previous_month_button = 4, + next_month_button = 5, }) mytextclock:connect_signal("button::press", - function(_, _, _, button) - if button == 1 then cw.toggle() end - end) + function(_, _, _, button) + if button == 1 then cw.toggle() end + end) -- Create a wibox for each screen and add it local taglist_buttons = gears.table.join( - awful.button({}, 1, function(t) t:view_only() end), - awful.button({ modkey }, 1, function(t) - if client.focus then - client.focus:move_to_tag(t) - end - end), - awful.button({}, 3, awful.tag.viewtoggle), - awful.button({ modkey }, 3, function(t) - if client.focus then - client.focus:toggle_tag(t) - end - end), - awful.button({}, 4, function(t) awful.tag.viewnext(t.screen) end), - awful.button({}, 5, function(t) awful.tag.viewprev(t.screen) end) + awful.button({}, 1, function(t) t:view_only() end), + awful.button({ modkey }, 1, function(t) + if client.focus then + client.focus:move_to_tag(t) + end + end), + awful.button({}, 3, awful.tag.viewtoggle), + awful.button({ modkey }, 3, function(t) + if client.focus then + client.focus:toggle_tag(t) + end + end), + awful.button({}, 4, function(t) awful.tag.viewnext(t.screen) end), + awful.button({}, 5, function(t) awful.tag.viewprev(t.screen) end) ) local tasklist_buttons = gears.table.join( - awful.button({}, 1, function(c) - if c == client.focus then - c.minimized = true - else - c:emit_signal( - "request::activate", - "tasklist", - { raise = true } - ) - end - end), - awful.button({}, 3, function() - awful.menu.client_list({ theme = { width = 250 } }) - end), - awful.button({}, 4, function() - awful.client.focus.byidx(1) - end), - awful.button({}, 5, function() - awful.client.focus.byidx(-1) - end)) + awful.button({}, 1, function(c) + if c == client.focus then + c.minimized = true + else + c:emit_signal( + "request::activate", + "tasklist", + { raise = true } + ) + end + end), + awful.button({}, 3, function() + awful.menu.client_list({ theme = { width = 250 } }) + end), + awful.button({}, 4, function() + awful.client.focus.byidx(1) + end), + awful.button({}, 5, function() + awful.client.focus.byidx(-1) + end)) local function set_wallpaper(s) - -- Wallpaper - if beautiful.wallpaper then - local wallpaper = beautiful.wallpaper - -- If wallpaper is a function, call it with the screen - if type(wallpaper) == "function" then - wallpaper = wallpaper(s) - end - gears.wallpaper.maximized(wallpaper, s, true) - end + -- Wallpaper + if beautiful.wallpaper then + local wallpaper = beautiful.wallpaper + -- If wallpaper is a function, call it with the screen + if type(wallpaper) == "function" then + wallpaper = wallpaper(s) + end + gears.wallpaper.maximized(wallpaper, s, true) + end end -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution) screen.connect_signal("property::geometry", set_wallpaper) awful.screen.connect_for_each_screen(function(s) - -- Wallpaper - set_wallpaper(s) + -- Wallpaper + set_wallpaper(s) - -- Each screen has its own tag table. - awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) + -- Each screen has its own tag table. + awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) - -- Create a promptbox for each screen - s.mypromptbox = awful.widget.prompt() - -- Create an imagebox widget which will contain an icon indicating which layout we're using. - -- We need one layoutbox per screen. - s.mylayoutbox = awful.widget.layoutbox(s) - s.mylayoutbox:buttons(gears.table.join( - awful.button({}, 1, function() awful.layout.inc(1) end), - awful.button({}, 3, function() awful.layout.inc(-1) end), - awful.button({}, 4, function() awful.layout.inc(1) end), - awful.button({}, 5, function() awful.layout.inc(-1) end))) - -- Create a taglist widget - s.mytaglist = awful.widget.taglist { - screen = s, - filter = awful.widget.taglist.filter.all, - buttons = taglist_buttons - } + -- Create a promptbox for each screen + s.mypromptbox = awful.widget.prompt() + -- Create an imagebox widget which will contain an icon indicating which layout we're using. + -- We need one layoutbox per screen. + s.mylayoutbox = awful.widget.layoutbox(s) + s.mylayoutbox:buttons(gears.table.join( + awful.button({}, 1, function() awful.layout.inc(1) end), + awful.button({}, 3, function() awful.layout.inc(-1) end), + awful.button({}, 4, function() awful.layout.inc(1) end), + awful.button({}, 5, function() awful.layout.inc(-1) end))) + -- Create a taglist widget + s.mytaglist = awful.widget.taglist { + screen = s, + filter = awful.widget.taglist.filter.all, + buttons = taglist_buttons + } - -- Create a tasklist widget - s.mytasklist = awful.widget.tasklist { - screen = s, - filter = awful.widget.tasklist.filter.currenttags, - buttons = tasklist_buttons - } + -- Create a tasklist widget + s.mytasklist = awful.widget.tasklist { + screen = s, + filter = awful.widget.tasklist.filter.currenttags, + buttons = tasklist_buttons + } - -- Create the wibox - s.mywibox = awful.wibar({ position = "top", screen = s }) + -- Create the wibox + s.mywibox = awful.wibar({ position = "top", screen = s }) - -- Add widgets to the wibox - s.mywibox:setup { - layout = wibox.layout.align.horizontal, - { -- Left widgets - layout = wibox.layout.fixed.horizontal, - --mylauncher, - s.mytaglist, - s.mypromptbox, - }, - s.mytasklist, -- Middle widget - { -- Right widgets - layout = wibox.layout.fixed.horizontal, - wibox.widget.systray(), - cpu_widget(), - ram_widget(), - net_speed_widget(), - spotify_widget({ - dim_when_paused = true, - dim_opacity = 0.5, - max_lenght = -1, - }), - weather_widget({ - api_key = API, - coordinates = { latitude, longitude }, - show_daily_forecast = true, - }), - --volume_widget{ - --widget_type = 'arc', - --mixer_cmd = 'pulsemixer', - --}, - -- logout_menu_widget(), - mytextclock, - s.mylayoutbox, - }, - } + -- Add widgets to the wibox + s.mywibox:setup { + layout = wibox.layout.align.horizontal, + { -- Left widgets + layout = wibox.layout.fixed.horizontal, + --mylauncher, + s.mytaglist, + s.mypromptbox, + }, + s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + wibox.widget.systray(), + cpu_widget(), + ram_widget(), + net_speed_widget(), + spotify_widget({ + dim_when_paused = true, + dim_opacity = 0.5, + max_lenght = -1, + }), + weather_widget({ + api_key = API, + coordinates = { latitude, longitude }, + show_daily_forecast = true, + }), + --volume_widget{ + --widget_type = 'arc', + --mixer_cmd = 'pulsemixer', + --}, + -- logout_menu_widget(), + mytextclock, + s.mylayoutbox, + }, + } end) -- }}} -- {{{ Mouse bindings root.buttons(gears.table.join( - awful.button({}, 3, function() mymainmenu:toggle() end), - awful.button({}, 4, awful.tag.viewnext), - awful.button({}, 5, awful.tag.viewprev) + awful.button({}, 3, function() mymainmenu:toggle() end), + awful.button({}, 4, awful.tag.viewnext), + awful.button({}, 5, awful.tag.viewprev) )) -- }}} -- {{{ Key bindings globalkeys = gears.table.join( - awful.key({}, "Pause", function() awful.spawn.with_shell("playerctl -a play-pause") end, - { description = "pause/play", group = "media controls" }), + awful.key({}, "Pause", function() awful.spawn.with_shell("playerctl -a play-pause") end, + { description = "pause/play", group = "media controls" }), - awful.key({ "Control" }, "Pause", function() awful.spawn.with_shell("playerctl -a pause") end, - { description = "pause all", group = "media controls" }), + awful.key({ "Control" }, "Pause", function() awful.spawn.with_shell("playerctl -a pause") end, + { description = "pause all", group = "media controls" }), - awful.key({}, "#117", function() awful.spawn.with_shell("playerctl next") end, - { description = "play next", group = "media controls" }), + awful.key({}, "#117", function() awful.spawn.with_shell("playerctl next") end, + { description = "play next", group = "media controls" }), - awful.key({}, "#112", function() awful.spawn.with_shell("playerctl previous") end, - { description = "play previous", group = "media controls" }), + awful.key({}, "#112", function() awful.spawn.with_shell("playerctl previous") end, + { description = "play previous", group = "media controls" }), - --awful.key( {}, "#123", function () volume_widget:inc(5) end ), -- increase volume - --awful.key( {}, "#122", function () volume_widget:dec(5) end ), -- decrease volume - --awful.key( {}, "#121", function () volume_widget:toggle() end ), -- mute + --awful.key( {}, "#123", function () volume_widget:inc(5) end ), -- increase volume + --awful.key( {}, "#122", function () volume_widget:dec(5) end ), -- decrease volume + --awful.key( {}, "#121", function () volume_widget:toggle() end ), -- mute - awful.key({}, "#123", function() awful.spawn.with_shell("pulsemixer --change-volume +5") end), -- increase volume - awful.key({}, "#122", function() awful.spawn.with_shell("pulsemixer --change-volume -5") end), -- decrease volume - awful.key({}, "#121", function() awful.spawn.with_shell("pulsemixer --toggle-mute") end), -- mute - awful.key({}, "#171", function() awful.spawn.with_shell("playerctl next") end), -- play next - awful.key({}, "#173", function() awful.spawn.with_shell("playerctl previous") end), -- play previous - awful.key({}, "#174", function() awful.spawn.with_shell("playerctl -a stop") end), -- stop - awful.key({}, "#172", function() awful.spawn.with_shell("playerctl -a play-pause") end), -- play/pause + awful.key({}, "#123", function() awful.spawn.with_shell("pulsemixer --change-volume +5") end), -- increase volume + awful.key({}, "#122", function() awful.spawn.with_shell("pulsemixer --change-volume -5") end), -- decrease volume + awful.key({}, "#121", function() awful.spawn.with_shell("pulsemixer --toggle-mute") end), -- mute + awful.key({}, "#171", function() awful.spawn.with_shell("playerctl next") end), -- play next + awful.key({}, "#173", function() awful.spawn.with_shell("playerctl previous") end), -- play previous + awful.key({}, "#174", function() awful.spawn.with_shell("playerctl -a stop") end), -- stop + awful.key({}, "#172", function() awful.spawn.with_shell("playerctl -a play-pause") end), -- play/pause - awful.key({ "Control" }, "#107", function() awful.spawn.with_shell("flameshot gui") end, - { description = "take region screenshot", group = "launcher" }), -- take region screenshot + awful.key({ "Control" }, "#107", function() awful.spawn.with_shell("flameshot gui") end, + { description = "take region screenshot", group = "launcher" }), -- take region screenshot - awful.key({ modkey, }, "s", hotkeys_popup.show_help, - { description = "show help", group = "awesome" }), - awful.key({ modkey, }, "Left", awful.tag.viewprev, - { description = "view previous", group = "tag" }), - awful.key({ modkey, }, "Right", awful.tag.viewnext, - { description = "view next", group = "tag" }), - awful.key({ modkey, }, "Escape", awful.tag.history.restore, - { description = "go back", group = "tag" }), + awful.key({ modkey, }, "s", hotkeys_popup.show_help, + { description = "show help", group = "awesome" }), + awful.key({ modkey, }, "Left", awful.tag.viewprev, + { description = "view previous", group = "tag" }), + awful.key({ modkey, }, "Right", awful.tag.viewnext, + { description = "view next", group = "tag" }), + awful.key({ modkey, }, "Escape", awful.tag.history.restore, + { description = "go back", group = "tag" }), - awful.key({ modkey, }, "j", - function() - awful.client.focus.byidx(1) - end, - { description = "focus next by index", group = "client" } - ), - awful.key({ modkey, }, "k", - function() - awful.client.focus.byidx(-1) - end, - { description = "focus previous by index", group = "client" } - ), - awful.key({ modkey, }, "w", function() mymainmenu:show() end, - { description = "show main menu", group = "awesome" }), + awful.key({ modkey, }, "j", + function() + awful.client.focus.byidx(1) + end, + { description = "focus next by index", group = "client" } + ), + awful.key({ modkey, }, "k", + function() + awful.client.focus.byidx(-1) + end, + { description = "focus previous by index", group = "client" } + ), + awful.key({ modkey, }, "w", function() mymainmenu:show() end, + { description = "show main menu", group = "awesome" }), - -- Layout manipulation - awful.key({ modkey, "Shift" }, "j", function() awful.client.swap.byidx(1) end, - { description = "swap with next client by index", group = "client" }), - awful.key({ modkey, "Shift" }, "k", function() awful.client.swap.byidx(-1) end, - { description = "swap with previous client by index", group = "client" }), - awful.key({ modkey, "Control" }, "j", function() awful.screen.focus_relative(1) end, - { description = "focus the next screen", group = "screen" }), - awful.key({ modkey, "Control" }, "k", function() awful.screen.focus_relative(-1) end, - { description = "focus the previous screen", group = "screen" }), - awful.key({ modkey, }, "u", awful.client.urgent.jumpto, - { description = "jump to urgent client", group = "client" }), - awful.key({ modkey, }, "Tab", - function() - awful.client.focus.history.previous() - if client.focus then - client.focus:raise() - end - end, - { description = "go back", group = "client" }), + -- Layout manipulation + awful.key({ modkey, "Shift" }, "j", function() awful.client.swap.byidx(1) end, + { description = "swap with next client by index", group = "client" }), + awful.key({ modkey, "Shift" }, "k", function() awful.client.swap.byidx(-1) end, + { description = "swap with previous client by index", group = "client" }), + awful.key({ modkey, "Control" }, "j", function() awful.screen.focus_relative(1) end, + { description = "focus the next screen", group = "screen" }), + awful.key({ modkey, "Control" }, "k", function() awful.screen.focus_relative(-1) end, + { description = "focus the previous screen", group = "screen" }), + awful.key({ modkey, }, "u", awful.client.urgent.jumpto, + { description = "jump to urgent client", group = "client" }), + awful.key({ modkey, }, "Tab", + function() + awful.client.focus.history.previous() + if client.focus then + client.focus:raise() + end + end, + { description = "go back", group = "client" }), - -- Standard program - awful.key({ modkey, }, "Return", function() awful.spawn(terminal) end, - { description = "open a terminal", group = "launcher" }), - awful.key({ modkey, "Control" }, "r", awesome.restart, - { description = "reload awesome", group = "awesome" }), - -- awful.key({ modkey, "Control" }, "q", awesome.quit, - -- {description = "quit awesome", group = "awesome"}), - awful.key({ modkey, }, "b", function() awful.spawn("firefox") end, - { description = "open firefox", group = "launcher" }), - awful.key({ modkey, }, "n", function() awful.spawn("spacefm") end, - { description = "open spacefm", group = "launcher" }), + -- Standard program + awful.key({ modkey, }, "Return", function() awful.spawn(terminal) end, + { description = "open a terminal", group = "launcher" }), + awful.key({ modkey, "Control" }, "r", awesome.restart, + { description = "reload awesome", group = "awesome" }), + -- awful.key({ modkey, "Control" }, "q", awesome.quit, + -- {description = "quit awesome", group = "awesome"}), + awful.key({ modkey, }, "b", function() awful.spawn("firefox") end, + { description = "open firefox", group = "launcher" }), + awful.key({ modkey, }, "n", function() awful.spawn("spacefm") end, + { description = "open spacefm", group = "launcher" }), - awful.key({ modkey, }, "l", function() awful.tag.incmwfact(0.05) end, - { description = "increase master width factor", group = "layout" }), - awful.key({ modkey, }, "h", function() awful.tag.incmwfact(-0.05) end, - { description = "decrease master width factor", group = "layout" }), - awful.key({ modkey, "Shift" }, "h", function() awful.tag.incnmaster(1, nil, true) end, - { description = "increase the number of master clients", group = "layout" }), - awful.key({ modkey, "Shift" }, "l", function() awful.tag.incnmaster(-1, nil, true) end, - { description = "decrease the number of master clients", group = "layout" }), - awful.key({ modkey, "Control" }, "h", function() awful.tag.incncol(1, nil, true) end, - { description = "increase the number of columns", group = "layout" }), - awful.key({ modkey, "Control" }, "l", function() awful.tag.incncol(-1, nil, true) end, - { description = "decrease the number of columns", group = "layout" }), - awful.key({ modkey, }, "space", function() awful.layout.inc(1) end, - { description = "select next", group = "layout" }), - awful.key({ modkey, "Shift" }, "space", function() awful.layout.inc(-1) end, - { description = "select previous", group = "layout" }), + awful.key({ modkey, }, "l", function() awful.tag.incmwfact(0.05) end, + { description = "increase master width factor", group = "layout" }), + awful.key({ modkey, }, "h", function() awful.tag.incmwfact(-0.05) end, + { description = "decrease master width factor", group = "layout" }), + awful.key({ modkey, "Shift" }, "h", function() awful.tag.incnmaster(1, nil, true) end, + { description = "increase the number of master clients", group = "layout" }), + awful.key({ modkey, "Shift" }, "l", function() awful.tag.incnmaster(-1, nil, true) end, + { description = "decrease the number of master clients", group = "layout" }), + awful.key({ modkey, "Control" }, "h", function() awful.tag.incncol(1, nil, true) end, + { description = "increase the number of columns", group = "layout" }), + awful.key({ modkey, "Control" }, "l", function() awful.tag.incncol(-1, nil, true) end, + { description = "decrease the number of columns", group = "layout" }), + awful.key({ modkey, }, "space", function() awful.layout.inc(1) end, + { description = "select next", group = "layout" }), + awful.key({ modkey, "Shift" }, "space", function() awful.layout.inc(-1) end, + { description = "select previous", group = "layout" }), - -- Prompt - awful.key({ modkey }, "r", function() awful.screen.focused().mypromptbox:run() end, - { description = "run prompt", group = "launcher" }), + -- Prompt + awful.key({ modkey }, "r", function() awful.screen.focused().mypromptbox:run() end, + { description = "run prompt", group = "launcher" }), - awful.key({ modkey }, "x", - function() - awful.prompt.run { - prompt = "Run Lua code: ", - textbox = awful.screen.focused().mypromptbox.widget, - exe_callback = awful.util.eval, - history_path = awful.util.get_cache_dir() .. "/history_eval" - } - end, - { description = "lua execute prompt", group = "awesome" }), - -- Menubar - awful.key({ modkey }, "p", function() menubar.show() end, - { description = "show the menubar", group = "launcher" }) + awful.key({ modkey }, "x", + function() + awful.prompt.run { + prompt = "Run Lua code: ", + textbox = awful.screen.focused().mypromptbox.widget, + exe_callback = awful.util.eval, + history_path = awful.util.get_cache_dir() .. "/history_eval" + } + end, + { description = "lua execute prompt", group = "awesome" }), + -- Menubar + awful.key({ modkey }, "p", function() menubar.show() end, + { description = "show the menubar", group = "launcher" }) ) clientkeys = gears.table.join( - awful.key({ modkey, }, "f", - function(c) - c.fullscreen = not c.fullscreen - c:raise() - end, - { description = "toggle fullscreen", group = "client" }), - awful.key({ modkey, "Shift" }, "q", function(c) c:kill() end, - { description = "close", group = "client" }), - awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle, - { description = "toggle floating", group = "client" }), - awful.key({ modkey, "Control" }, "Return", function(c) c:swap(awful.client.getmaster()) end, - { description = "move to master", group = "client" }), - awful.key({ modkey, }, "o", function(c) c:move_to_screen() end, - { description = "move to screen", group = "client" }), - awful.key({ modkey, }, "t", function(c) c.ontop = not c.ontop end, - { description = "toggle keep on top", group = "client" }), - awful.key({ modkey, }, "n", - function(c) - -- The client currently has the input focus, so it cannot be - -- minimized, since minimized clients can't have the focus. - c.minimized = true - end, - { description = "minimize", group = "client" }), - awful.key({ modkey, }, "m", - function(c) - c.maximized = not c.maximized - c:raise() - end, - { description = "(un)maximize", group = "client" }), - awful.key({ modkey, "Control" }, "m", - function(c) - c.maximized_vertical = not c.maximized_vertical - c:raise() - end, - { description = "(un)maximize vertically", group = "client" }), - awful.key({ modkey, "Shift" }, "m", - function(c) - c.maximized_horizontal = not c.maximized_horizontal - c:raise() - end, - { description = "(un)maximize horizontally", group = "client" }) + awful.key({ modkey, }, "f", + function(c) + c.fullscreen = not c.fullscreen + c:raise() + end, + { description = "toggle fullscreen", group = "client" }), + awful.key({ modkey, "Shift" }, "q", function(c) c:kill() end, + { description = "close", group = "client" }), + awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle, + { description = "toggle floating", group = "client" }), + awful.key({ modkey, "Control" }, "Return", function(c) c:swap(awful.client.getmaster()) end, + { description = "move to master", group = "client" }), + awful.key({ modkey, }, "o", function(c) c:move_to_screen() end, + { description = "move to screen", group = "client" }), + awful.key({ modkey, }, "t", function(c) c.ontop = not c.ontop end, + { description = "toggle keep on top", group = "client" }), + awful.key({ modkey, }, "n", + function(c) + -- The client currently has the input focus, so it cannot be + -- minimized, since minimized clients can't have the focus. + c.minimized = true + end, + { description = "minimize", group = "client" }), + awful.key({ modkey, }, "m", + function(c) + c.maximized = not c.maximized + c:raise() + end, + { description = "(un)maximize", group = "client" }), + awful.key({ modkey, "Control" }, "m", + function(c) + c.maximized_vertical = not c.maximized_vertical + c:raise() + end, + { description = "(un)maximize vertically", group = "client" }), + awful.key({ modkey, "Shift" }, "m", + function(c) + c.maximized_horizontal = not c.maximized_horizontal + c:raise() + end, + { description = "(un)maximize horizontally", group = "client" }) ) -- Bind all key numbers to tags. -- Be careful: we use keycodes to make it work on any keyboard layout. -- This should map on the top row of your keyboard, usually 1 to 9. for i = 1, 9 do - globalkeys = gears.table.join(globalkeys, - -- View tag only. - awful.key({ modkey }, "#" .. i + 9, - function() - local screen = awful.screen.focused() - local tag = screen.tags[i] - if tag then - tag:view_only() - end - end, - { description = "view tag #" .. i, group = "tag" }), - -- Toggle tag display. - awful.key({ modkey, "Control" }, "#" .. i + 9, - function() - local screen = awful.screen.focused() - local tag = screen.tags[i] - if tag then - awful.tag.viewtoggle(tag) - end - end, - { description = "toggle tag #" .. i, group = "tag" }), - -- Move client to tag. - awful.key({ modkey, "Shift" }, "#" .. i + 9, - function() - if client.focus then - local tag = client.focus.screen.tags[i] - if tag then - client.focus:move_to_tag(tag) - end - end - end, - { description = "move focused client to tag #" .. i, group = "tag" }), - -- Toggle tag on focused client. - awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, - function() - if client.focus then - local tag = client.focus.screen.tags[i] - if tag then - client.focus:toggle_tag(tag) - end - end - end, - { description = "toggle focused client on tag #" .. i, group = "tag" }) - ) + globalkeys = gears.table.join(globalkeys, + -- View tag only. + awful.key({ modkey }, "#" .. i + 9, + function() + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + tag:view_only() + end + end, + { description = "view tag #" .. i, group = "tag" }), + -- Toggle tag display. + awful.key({ modkey, "Control" }, "#" .. i + 9, + function() + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + awful.tag.viewtoggle(tag) + end + end, + { description = "toggle tag #" .. i, group = "tag" }), + -- Move client to tag. + awful.key({ modkey, "Shift" }, "#" .. i + 9, + function() + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:move_to_tag(tag) + end + end + end, + { description = "move focused client to tag #" .. i, group = "tag" }), + -- Toggle tag on focused client. + awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, + function() + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:toggle_tag(tag) + end + end + end, + { description = "toggle focused client on tag #" .. i, group = "tag" }) + ) end clientbuttons = gears.table.join( - awful.button({}, 1, function(c) - c:emit_signal("request::activate", "mouse_click", { raise = true }) - end), - awful.button({ modkey }, 1, function(c) - c:emit_signal("request::activate", "mouse_click", { raise = true }) - awful.mouse.client.move(c) - end), - awful.button({ modkey }, 3, function(c) - c:emit_signal("request::activate", "mouse_click", { raise = true }) - awful.mouse.client.resize(c) - end) + awful.button({}, 1, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + end), + awful.button({ modkey }, 1, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + awful.mouse.client.move(c) + end), + awful.button({ modkey }, 3, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + awful.mouse.client.resize(c) + end) ) -- Set keys @@ -531,128 +531,128 @@ root.keys(globalkeys) -- {{{ Rules -- Rules to apply to new clients (through the "manage" signal). awful.rules.rules = { - -- All clients will match this rule. - { rule = {}, - properties = { border_width = beautiful.border_width, - border_color = beautiful.border_normal, - focus = awful.client.focus.filter, - raise = true, - keys = clientkeys, - -- buttons = clientbuttons, - screen = awful.screen.preferred, - --placement = awful.placement.no_overlap+awful.placement.no_offscreen - } - }, + -- All clients will match this rule. + { rule = {}, + properties = { border_width = beautiful.border_width, + border_color = beautiful.border_normal, + focus = awful.client.focus.filter, + raise = true, + keys = clientkeys, + -- buttons = clientbuttons, + screen = awful.screen.preferred, + --placement = awful.placement.no_overlap+awful.placement.no_offscreen + } + }, - -- Floating clients. - { rule_any = { - instance = { - "DTA", -- Firefox addon DownThemAll. - "copyq", -- Includes session name in class. - "pinentry", - }, - class = { - "Arandr", - "Blueman-manager", - "Gpick", - "Kruler", - "MessageWin", -- kalarm. - "Sxiv", - "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size. - "Wpa_gui", - "veromix", - "xtightvncviewer" }, + -- Floating clients. + { rule_any = { + instance = { + "DTA", -- Firefox addon DownThemAll. + "copyq", -- Includes session name in class. + "pinentry", + }, + class = { + "Arandr", + "Blueman-manager", + "Gpick", + "Kruler", + "MessageWin", -- kalarm. + "Sxiv", + "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size. + "Wpa_gui", + "veromix", + "xtightvncviewer" }, - -- Note that the name property shown in xprop might be set slightly after creation of the client - -- and the name shown there might not match defined rules here. - name = { - "Event Tester", -- xev. - }, - role = { - "AlarmWindow", -- Thunderbird's calendar. - "ConfigManager", -- Thunderbird's about:config. - "pop-up", -- e.g. Google Chrome's (detached) Developer Tools. - } - }, properties = { floating = true, beautiful.useless } }, + -- Note that the name property shown in xprop might be set slightly after creation of the client + -- and the name shown there might not match defined rules here. + name = { + "Event Tester", -- xev. + }, + role = { + "AlarmWindow", -- Thunderbird's calendar. + "ConfigManager", -- Thunderbird's about:config. + "pop-up", -- e.g. Google Chrome's (detached) Developer Tools. + } + }, properties = { floating = true, beautiful.useless } }, - -- Add titlebars to normal clients and dialogs - { rule_any = { type = { "normal", "dialog" } - }, properties = { titlebars_enabled = false } - }, + -- Add titlebars to normal clients and dialogs + { rule_any = { type = { "normal", "dialog" } + }, properties = { titlebars_enabled = false } + }, - { - rule_any = { - class = { "discord", "TelegramDesktop", "Ripcord" } - }, properties = { screen = 2, tag = "8" } - }, + { + rule_any = { + class = { "discord", "TelegramDesktop", "Ripcord" } + }, properties = { screen = 2, tag = "8" } + }, - { - rule_any = { - class = { "spotify", "Spotify" }, - name = { "Spotify" } - }, properties = { screen = 2, tag = "9" } - }, + { + rule_any = { + class = { "spotify", "Spotify" }, + name = { "Spotify" } + }, properties = { screen = 2, tag = "9" } + }, } -- {{{ Signals -- Signal function to execute when a new client appears. client.connect_signal("manage", function(c) - -- Set the windows at the slave, - -- i.e. put it at the end of others instead of setting it master. - -- if not awesome.startup then awful.client.setslave(c) end + -- Set the windows at the slave, + -- i.e. put it at the end of others instead of setting it master. + -- if not awesome.startup then awful.client.setslave(c) end - if awesome.startup - and not c.size_hints.user_position - and not c.size_hints.program_position then - -- Prevent clients from being unreachable after screen count changes. - awful.placement.no_offscreen(c) - end + if awesome.startup + and not c.size_hints.user_position + and not c.size_hints.program_position then + -- Prevent clients from being unreachable after screen count changes. + awful.placement.no_offscreen(c) + end end) -- Add a titlebar if titlebars_enabled is set to true in the rules. client.connect_signal("request::titlebars", function(c) - -- buttons for the titlebar - local buttons = gears.table.join( - awful.button({}, 1, function() - c:emit_signal("request::activate", "titlebar", { raise = true }) - awful.mouse.client.move(c) - end), - awful.button({}, 3, function() - c:emit_signal("request::activate", "titlebar", { raise = true }) - awful.mouse.client.resize(c) - end) - ) + -- buttons for the titlebar + local buttons = gears.table.join( + awful.button({}, 1, function() + c:emit_signal("request::activate", "titlebar", { raise = true }) + awful.mouse.client.move(c) + end), + awful.button({}, 3, function() + c:emit_signal("request::activate", "titlebar", { raise = true }) + awful.mouse.client.resize(c) + end) + ) - awful.titlebar(c):setup { - { -- Left - awful.titlebar.widget.iconwidget(c), - buttons = buttons, - layout = wibox.layout.fixed.horizontal - }, - { -- Middle - { -- Title - align = "center", - widget = awful.titlebar.widget.titlewidget(c) - }, - buttons = buttons, - layout = wibox.layout.flex.horizontal - }, - { -- Right - awful.titlebar.widget.floatingbutton(c), - awful.titlebar.widget.maximizedbutton(c), - awful.titlebar.widget.stickybutton(c), - awful.titlebar.widget.ontopbutton(c), - awful.titlebar.widget.closebutton(c), - layout = wibox.layout.fixed.horizontal() - }, - layout = wibox.layout.align.horizontal - } + awful.titlebar(c):setup { + { -- Left + awful.titlebar.widget.iconwidget(c), + buttons = buttons, + layout = wibox.layout.fixed.horizontal + }, + { -- Middle + { -- Title + align = "center", + widget = awful.titlebar.widget.titlewidget(c) + }, + buttons = buttons, + layout = wibox.layout.flex.horizontal + }, + { -- Right + awful.titlebar.widget.floatingbutton(c), + awful.titlebar.widget.maximizedbutton(c), + awful.titlebar.widget.stickybutton(c), + awful.titlebar.widget.ontopbutton(c), + awful.titlebar.widget.closebutton(c), + layout = wibox.layout.fixed.horizontal() + }, + layout = wibox.layout.align.horizontal + } end) -- Enable sloppy focus, so that focus follows mouse. client.connect_signal("mouse::enter", function(c) - c:emit_signal("request::activate", "mouse_enter", { raise = false }) + c:emit_signal("request::activate", "mouse_enter", { raise = false }) end) client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) diff --git a/.config/awesome/json.lua b/.config/awesome/json.lua index ab9af7b5..223c0a80 100644 --- a/.config/awesome/json.lua +++ b/.config/awesome/json.lua @@ -31,103 +31,103 @@ local json = { _version = "0.1.2" } local encode local escape_char_map = { - ["\\"] = "\\", - ["\""] = "\"", - ["\b"] = "b", - ["\f"] = "f", - ["\n"] = "n", - ["\r"] = "r", - ["\t"] = "t", + ["\\"] = "\\", + ["\""] = "\"", + ["\b"] = "b", + ["\f"] = "f", + ["\n"] = "n", + ["\r"] = "r", + ["\t"] = "t", } local escape_char_map_inv = { ["/"] = "/" } for k, v in pairs(escape_char_map) do - escape_char_map_inv[v] = k + escape_char_map_inv[v] = k end local function escape_char(c) - return "\\" .. (escape_char_map[c] or string.format("u%04x", c:byte())) + return "\\" .. (escape_char_map[c] or string.format("u%04x", c:byte())) end local function encode_nil(val) - return "null" + return "null" end local function encode_table(val, stack) - local res = {} - stack = stack or {} + local res = {} + stack = stack or {} - -- Circular reference? - if stack[val] then error("circular reference") end + -- Circular reference? + if stack[val] then error("circular reference") end - stack[val] = true + stack[val] = true - if rawget(val, 1) ~= nil or next(val) == nil then - -- Treat as array -- check keys are valid and it is not sparse - local n = 0 - for k in pairs(val) do - if type(k) ~= "number" then - error("invalid table: mixed or invalid key types") - end - n = n + 1 - end - if n ~= #val then - error("invalid table: sparse array") - end - -- Encode - for i, v in ipairs(val) do - table.insert(res, encode(v, stack)) - end - stack[val] = nil - return "[" .. table.concat(res, ",") .. "]" + if rawget(val, 1) ~= nil or next(val) == nil then + -- Treat as array -- check keys are valid and it is not sparse + local n = 0 + for k in pairs(val) do + if type(k) ~= "number" then + error("invalid table: mixed or invalid key types") + end + n = n + 1 + end + if n ~= #val then + error("invalid table: sparse array") + end + -- Encode + for i, v in ipairs(val) do + table.insert(res, encode(v, stack)) + end + stack[val] = nil + return "[" .. table.concat(res, ",") .. "]" - else - -- Treat as an object - for k, v in pairs(val) do - if type(k) ~= "string" then - error("invalid table: mixed or invalid key types") - end - table.insert(res, encode(k, stack) .. ":" .. encode(v, stack)) - end - stack[val] = nil - return "{" .. table.concat(res, ",") .. "}" - end + else + -- Treat as an object + for k, v in pairs(val) do + if type(k) ~= "string" then + error("invalid table: mixed or invalid key types") + end + table.insert(res, encode(k, stack) .. ":" .. encode(v, stack)) + end + stack[val] = nil + return "{" .. table.concat(res, ",") .. "}" + end end local function encode_string(val) - return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"' + return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"' end local function encode_number(val) - -- Check for NaN, -inf and inf - if val ~= val or val <= -math.huge or val >= math.huge then - error("unexpected number value '" .. tostring(val) .. "'") - end - return string.format("%.14g", val) + -- Check for NaN, -inf and inf + if val ~= val or val <= -math.huge or val >= math.huge then + error("unexpected number value '" .. tostring(val) .. "'") + end + return string.format("%.14g", val) end local type_func_map = { - ["nil"] = encode_nil, - ["table"] = encode_table, - ["string"] = encode_string, - ["number"] = encode_number, - ["boolean"] = tostring, + ["nil"] = encode_nil, + ["table"] = encode_table, + ["string"] = encode_string, + ["number"] = encode_number, + ["boolean"] = tostring, } encode = function(val, stack) - local t = type(val) - local f = type_func_map[t] - if f then - return f(val, stack) - end - error("unexpected type '" .. t .. "'") + local t = type(val) + local f = type_func_map[t] + if f then + return f(val, stack) + end + error("unexpected type '" .. t .. "'") end function json.encode(val) - return (encode(val)) + return (encode(val)) end ------------------------------------------------------------------------------- @@ -137,11 +137,11 @@ end local parse local function create_set(...) - local res = {} - for i = 1, select("#", ...) do - res[select(i, ...)] = true - end - return res + local res = {} + for i = 1, select("#", ...) do + res[select(i, ...)] = true + end + return res end local space_chars = create_set(" ", "\t", "\r", "\n") @@ -150,223 +150,223 @@ local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u") local literals = create_set("true", "false", "null") local literal_map = { - ["true"] = true, - ["false"] = false, - ["null"] = nil, + ["true"] = true, + ["false"] = false, + ["null"] = nil, } local function next_char(str, idx, set, negate) - for i = idx, #str do - if set[str:sub(i, i)] ~= negate then - return i - end - end - return #str + 1 + for i = idx, #str do + if set[str:sub(i, i)] ~= negate then + return i + end + end + return #str + 1 end local function decode_error(str, idx, msg) - local line_count = 1 - local col_count = 1 - for i = 1, idx - 1 do - col_count = col_count + 1 - if str:sub(i, i) == "\n" then - line_count = line_count + 1 - col_count = 1 - end - end - error(string.format("%s at line %d col %d", msg, line_count, col_count)) + local line_count = 1 + local col_count = 1 + for i = 1, idx - 1 do + col_count = col_count + 1 + if str:sub(i, i) == "\n" then + line_count = line_count + 1 + col_count = 1 + end + end + error(string.format("%s at line %d col %d", msg, line_count, col_count)) end local function codepoint_to_utf8(n) - -- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa - local f = math.floor - if n <= 0x7f then - return string.char(n) - elseif n <= 0x7ff then - return string.char(f(n / 64) + 192, n % 64 + 128) - elseif n <= 0xffff then - return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128) - elseif n <= 0x10ffff then - return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128, - f(n % 4096 / 64) + 128, n % 64 + 128) - end - error(string.format("invalid unicode codepoint '%x'", n)) + -- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa + local f = math.floor + if n <= 0x7f then + return string.char(n) + elseif n <= 0x7ff then + return string.char(f(n / 64) + 192, n % 64 + 128) + elseif n <= 0xffff then + return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128) + elseif n <= 0x10ffff then + return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128, + f(n % 4096 / 64) + 128, n % 64 + 128) + end + error(string.format("invalid unicode codepoint '%x'", n)) end local function parse_unicode_escape(s) - local n1 = tonumber(s:sub(1, 4), 16) - local n2 = tonumber(s:sub(7, 10), 16) - -- Surrogate pair? - if n2 then - return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000) - else - return codepoint_to_utf8(n1) - end + local n1 = tonumber(s:sub(1, 4), 16) + local n2 = tonumber(s:sub(7, 10), 16) + -- Surrogate pair? + if n2 then + return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000) + else + return codepoint_to_utf8(n1) + end end local function parse_string(str, i) - local res = "" - local j = i + 1 - local k = j + local res = "" + local j = i + 1 + local k = j - while j <= #str do - local x = str:byte(j) + while j <= #str do + local x = str:byte(j) - if x < 32 then - decode_error(str, j, "control character in string") + if x < 32 then + decode_error(str, j, "control character in string") - elseif x == 92 then -- `\`: Escape - res = res .. str:sub(k, j - 1) - j = j + 1 - local c = str:sub(j, j) - if c == "u" then - local hex = str:match("^[dD][89aAbB]%x%x\\u%x%x%x%x", j + 1) - or str:match("^%x%x%x%x", j + 1) - or decode_error(str, j - 1, "invalid unicode escape in string") - res = res .. parse_unicode_escape(hex) - j = j + #hex - else - if not escape_chars[c] then - decode_error(str, j - 1, "invalid escape char '" .. c .. "' in string") - end - res = res .. escape_char_map_inv[c] - end - k = j + 1 + elseif x == 92 then -- `\`: Escape + res = res .. str:sub(k, j - 1) + j = j + 1 + local c = str:sub(j, j) + if c == "u" then + local hex = str:match("^[dD][89aAbB]%x%x\\u%x%x%x%x", j + 1) + or str:match("^%x%x%x%x", j + 1) + or decode_error(str, j - 1, "invalid unicode escape in string") + res = res .. parse_unicode_escape(hex) + j = j + #hex + else + if not escape_chars[c] then + decode_error(str, j - 1, "invalid escape char '" .. c .. "' in string") + end + res = res .. escape_char_map_inv[c] + end + k = j + 1 - elseif x == 34 then -- `"`: End of string - res = res .. str:sub(k, j - 1) - return res, j + 1 - end + elseif x == 34 then -- `"`: End of string + res = res .. str:sub(k, j - 1) + return res, j + 1 + end - j = j + 1 - end + j = j + 1 + end - decode_error(str, i, "expected closing quote for string") + decode_error(str, i, "expected closing quote for string") end local function parse_number(str, i) - local x = next_char(str, i, delim_chars) - local s = str:sub(i, x - 1) - local n = tonumber(s) - if not n then - decode_error(str, i, "invalid number '" .. s .. "'") - end - return n, x + local x = next_char(str, i, delim_chars) + local s = str:sub(i, x - 1) + local n = tonumber(s) + if not n then + decode_error(str, i, "invalid number '" .. s .. "'") + end + return n, x end local function parse_literal(str, i) - local x = next_char(str, i, delim_chars) - local word = str:sub(i, x - 1) - if not literals[word] then - decode_error(str, i, "invalid literal '" .. word .. "'") - end - return literal_map[word], x + local x = next_char(str, i, delim_chars) + local word = str:sub(i, x - 1) + if not literals[word] then + decode_error(str, i, "invalid literal '" .. word .. "'") + end + return literal_map[word], x end local function parse_array(str, i) - local res = {} - local n = 1 - i = i + 1 - while 1 do - local x - i = next_char(str, i, space_chars, true) - -- Empty / end of array? - if str:sub(i, i) == "]" then - i = i + 1 - break - end - -- Read token - x, i = parse(str, i) - res[n] = x - n = n + 1 - -- Next token - i = next_char(str, i, space_chars, true) - local chr = str:sub(i, i) - i = i + 1 - if chr == "]" then break end - if chr ~= "," then decode_error(str, i, "expected ']' or ','") end - end - return res, i + local res = {} + local n = 1 + i = i + 1 + while 1 do + local x + i = next_char(str, i, space_chars, true) + -- Empty / end of array? + if str:sub(i, i) == "]" then + i = i + 1 + break + end + -- Read token + x, i = parse(str, i) + res[n] = x + n = n + 1 + -- Next token + i = next_char(str, i, space_chars, true) + local chr = str:sub(i, i) + i = i + 1 + if chr == "]" then break end + if chr ~= "," then decode_error(str, i, "expected ']' or ','") end + end + return res, i end local function parse_object(str, i) - local res = {} - i = i + 1 - while 1 do - local key, val - i = next_char(str, i, space_chars, true) - -- Empty / end of object? - if str:sub(i, i) == "}" then - i = i + 1 - break - end - -- Read key - if str:sub(i, i) ~= '"' then - decode_error(str, i, "expected string for key") - end - key, i = parse(str, i) - -- Read ':' delimiter - i = next_char(str, i, space_chars, true) - if str:sub(i, i) ~= ":" then - decode_error(str, i, "expected ':' after key") - end - i = next_char(str, i + 1, space_chars, true) - -- Read value - val, i = parse(str, i) - -- Set - res[key] = val - -- Next token - i = next_char(str, i, space_chars, true) - local chr = str:sub(i, i) - i = i + 1 - if chr == "}" then break end - if chr ~= "," then decode_error(str, i, "expected '}' or ','") end - end - return res, i + local res = {} + i = i + 1 + while 1 do + local key, val + i = next_char(str, i, space_chars, true) + -- Empty / end of object? + if str:sub(i, i) == "}" then + i = i + 1 + break + end + -- Read key + if str:sub(i, i) ~= '"' then + decode_error(str, i, "expected string for key") + end + key, i = parse(str, i) + -- Read ':' delimiter + i = next_char(str, i, space_chars, true) + if str:sub(i, i) ~= ":" then + decode_error(str, i, "expected ':' after key") + end + i = next_char(str, i + 1, space_chars, true) + -- Read value + val, i = parse(str, i) + -- Set + res[key] = val + -- Next token + i = next_char(str, i, space_chars, true) + local chr = str:sub(i, i) + i = i + 1 + if chr == "}" then break end + if chr ~= "," then decode_error(str, i, "expected '}' or ','") end + end + return res, i end local char_func_map = { - ['"'] = parse_string, - ["0"] = parse_number, - ["1"] = parse_number, - ["2"] = parse_number, - ["3"] = parse_number, - ["4"] = parse_number, - ["5"] = parse_number, - ["6"] = parse_number, - ["7"] = parse_number, - ["8"] = parse_number, - ["9"] = parse_number, - ["-"] = parse_number, - ["t"] = parse_literal, - ["f"] = parse_literal, - ["n"] = parse_literal, - ["["] = parse_array, - ["{"] = parse_object, + ['"'] = parse_string, + ["0"] = parse_number, + ["1"] = parse_number, + ["2"] = parse_number, + ["3"] = parse_number, + ["4"] = parse_number, + ["5"] = parse_number, + ["6"] = parse_number, + ["7"] = parse_number, + ["8"] = parse_number, + ["9"] = parse_number, + ["-"] = parse_number, + ["t"] = parse_literal, + ["f"] = parse_literal, + ["n"] = parse_literal, + ["["] = parse_array, + ["{"] = parse_object, } parse = function(str, idx) - local chr = str:sub(idx, idx) - local f = char_func_map[chr] - if f then - return f(str, idx) - end - decode_error(str, idx, "unexpected character '" .. chr .. "'") + local chr = str:sub(idx, idx) + local f = char_func_map[chr] + if f then + return f(str, idx) + end + decode_error(str, idx, "unexpected character '" .. chr .. "'") end function json.decode(str) - if type(str) ~= "string" then - error("expected argument of type string, got " .. type(str)) - end - local res, idx = parse(str, next_char(str, 1, space_chars, true)) - idx = next_char(str, idx, space_chars, true) - if idx <= #str then - decode_error(str, idx, "trailing garbage") - end - return res + if type(str) ~= "string" then + error("expected argument of type string, got " .. type(str)) + end + local res, idx = parse(str, next_char(str, 1, space_chars, true)) + idx = next_char(str, idx, space_chars, true) + if idx <= #str then + decode_error(str, idx, "trailing garbage") + end + return res end return json diff --git a/.config/awesome/mytheme.lua b/.config/awesome/mytheme.lua index 6b4b3449..1cf1a3e9 100644 --- a/.config/awesome/mytheme.lua +++ b/.config/awesome/mytheme.lua @@ -47,10 +47,10 @@ theme.border_marked = "#91231c" -- Generate taglist squares: local taglist_square_size = dpi(4) theme.taglist_squares_sel = theme_assets.taglist_squares_sel( - taglist_square_size, theme.fg_normal + taglist_square_size, theme.fg_normal ) theme.taglist_squares_unsel = theme_assets.taglist_squares_unsel( - taglist_square_size, theme.fg_normal + taglist_square_size, theme.fg_normal ) -- Variables set for theming notifications: @@ -120,7 +120,7 @@ theme.layout_cornerse = themes_path .. "default/layouts/cornersew.png" -- Generate Awesome icon: theme.awesome_icon = theme_assets.awesome_icon( - theme.menu_height, theme.bg_focus, theme.fg_focus + theme.menu_height, theme.bg_focus, theme.fg_focus ) -- Define the icon theme for application icons. If not set then the icons diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index bd17f676..7aa58925 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -35,20 +35,20 @@ require("awful.hotkeys_popup.keys") local weather_file = '/home/kristofers/.config/awesome/weather' -- absolute path to `weather` file -- see if the file exists local function file_exists(file) - local f = io.open(file, "rb") - if f then f:close() end - return f ~= nil + local f = io.open(file, "rb") + if f then f:close() end + return f ~= nil end -- get all lines from a file, returns an empty -- list/table if the file does not exist local function lines_from(file) - if not file_exists(file) then return {} end - local lines = {} - for line in io.lines(file) do - lines[#lines + 1] = line - end - return lines + if not file_exists(file) then return {} end + local lines = {} + for line in io.lines(file) do + lines[#lines + 1] = line + end + return lines end local weather_output = lines_from(weather_file) @@ -61,24 +61,24 @@ local longitude = tonumber(weather_output[3]) -- Check if awesome encountered an error during startup and fell back to -- another config (This code will only ever execute for the fallback config) if awesome.startup_errors then - naughty.notify({ preset = naughty.config.presets.critical, - title = "Oops, there were errors during startup!", - text = awesome.startup_errors }) + naughty.notify({ preset = naughty.config.presets.critical, + title = "Oops, there were errors during startup!", + text = awesome.startup_errors }) end -- Handle runtime errors after startup do - local in_error = false - awesome.connect_signal("debug::error", function(err) - -- Make sure we don't go into an endless error loop - if in_error then return end - in_error = true + local in_error = false + awesome.connect_signal("debug::error", function(err) + -- Make sure we don't go into an endless error loop + if in_error then return end + in_error = true - naughty.notify({ preset = naughty.config.presets.critical, - title = "Oops, an error happened!", - text = tostring(err) }) - in_error = false - end) + naughty.notify({ preset = naughty.config.presets.critical, + title = "Oops, an error happened!", + text = tostring(err) }) + in_error = false + end) end -- }}} @@ -101,42 +101,42 @@ modkey = "Mod4" -- Table of layouts to cover with awful.layout.inc, order matters. awful.layout.layouts = { - awful.layout.suit.tile, - awful.layout.suit.spiral.dwindle, - awful.layout.suit.spiral, - --awful.layout.suit.floating, - --awful.layout.suit.tile.left, - --awful.layout.suit.tile.bottom, - --awful.layout.suit.tile.top, - awful.layout.suit.fair, - --awful.layout.suit.fair.horizontal, - --awful.layout.suit.max, - --awful.layout.suit.max.fullscreen, - --awful.layout.suit.magnifier, - --awful.layout.suit.corner.nw, - --awful.layout.suit.corner.ne, - --awful.layout.suit.corner.sw, - --awful.layout.suit.corner.se, + awful.layout.suit.tile, + awful.layout.suit.spiral.dwindle, + awful.layout.suit.spiral, + --awful.layout.suit.floating, + --awful.layout.suit.tile.left, + --awful.layout.suit.tile.bottom, + --awful.layout.suit.tile.top, + awful.layout.suit.fair, + --awful.layout.suit.fair.horizontal, + --awful.layout.suit.max, + --awful.layout.suit.max.fullscreen, + --awful.layout.suit.magnifier, + --awful.layout.suit.corner.nw, + --awful.layout.suit.corner.ne, + --awful.layout.suit.corner.sw, + --awful.layout.suit.corner.se, } -- }}} -- {{{ Menu -- Create a launcher widget and a main menu myawesomemenu = { - { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end }, - { "manual", terminal .. " -e man awesome" }, - { "edit config", editor_cmd .. " " .. awesome.conffile }, - { "restart", awesome.restart }, - { "quit", function() awesome.quit() end }, + { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end }, + { "manual", terminal .. " -e man awesome" }, + { "edit config", editor_cmd .. " " .. awesome.conffile }, + { "restart", awesome.restart }, + { "quit", function() awesome.quit() end }, } mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, - { "open terminal", terminal } + { "open terminal", terminal } } }) mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, - menu = mymainmenu }) + menu = mymainmenu }) -- Menubar configuration menubar.utils.terminal = terminal -- Set the terminal for applications that require it @@ -149,376 +149,376 @@ menubar.utils.terminal = terminal -- Set the terminal for applications that requ -- Create a textclock widget mytextclock = wibox.widget.textclock() local cw = calendar_widget({ - theme = 'nord', - placement = "top_right", - previous_month_button = 4, - next_month_button = 5, + theme = 'nord', + placement = "top_right", + previous_month_button = 4, + next_month_button = 5, }) mytextclock:connect_signal("button::press", - function(_, _, _, button) - if button == 1 then cw.toggle() end - end) + function(_, _, _, button) + if button == 1 then cw.toggle() end + end) -- Create a wibox for each screen and add it local taglist_buttons = gears.table.join( - awful.button({}, 1, function(t) t:view_only() end), - awful.button({ modkey }, 1, function(t) - if client.focus then - client.focus:move_to_tag(t) - end - end), - awful.button({}, 3, awful.tag.viewtoggle), - awful.button({ modkey }, 3, function(t) - if client.focus then - client.focus:toggle_tag(t) - end - end), - awful.button({}, 4, function(t) awful.tag.viewnext(t.screen) end), - awful.button({}, 5, function(t) awful.tag.viewprev(t.screen) end) + awful.button({}, 1, function(t) t:view_only() end), + awful.button({ modkey }, 1, function(t) + if client.focus then + client.focus:move_to_tag(t) + end + end), + awful.button({}, 3, awful.tag.viewtoggle), + awful.button({ modkey }, 3, function(t) + if client.focus then + client.focus:toggle_tag(t) + end + end), + awful.button({}, 4, function(t) awful.tag.viewnext(t.screen) end), + awful.button({}, 5, function(t) awful.tag.viewprev(t.screen) end) ) local tasklist_buttons = gears.table.join( - awful.button({}, 1, function(c) - if c == client.focus then - c.minimized = true - else - c:emit_signal( - "request::activate", - "tasklist", - { raise = true } - ) - end - end), - awful.button({}, 3, function() - awful.menu.client_list({ theme = { width = 250 } }) - end), - awful.button({}, 4, function() - awful.client.focus.byidx(1) - end), - awful.button({}, 5, function() - awful.client.focus.byidx(-1) - end)) + awful.button({}, 1, function(c) + if c == client.focus then + c.minimized = true + else + c:emit_signal( + "request::activate", + "tasklist", + { raise = true } + ) + end + end), + awful.button({}, 3, function() + awful.menu.client_list({ theme = { width = 250 } }) + end), + awful.button({}, 4, function() + awful.client.focus.byidx(1) + end), + awful.button({}, 5, function() + awful.client.focus.byidx(-1) + end)) local function set_wallpaper(s) - -- Wallpaper - if beautiful.wallpaper then - local wallpaper = beautiful.wallpaper - -- If wallpaper is a function, call it with the screen - if type(wallpaper) == "function" then - wallpaper = wallpaper(s) - end - gears.wallpaper.maximized(wallpaper, s, true) - end + -- Wallpaper + if beautiful.wallpaper then + local wallpaper = beautiful.wallpaper + -- If wallpaper is a function, call it with the screen + if type(wallpaper) == "function" then + wallpaper = wallpaper(s) + end + gears.wallpaper.maximized(wallpaper, s, true) + end end -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution) screen.connect_signal("property::geometry", set_wallpaper) awful.screen.connect_for_each_screen(function(s) - -- Wallpaper - set_wallpaper(s) + -- Wallpaper + set_wallpaper(s) - -- Each screen has its own tag table. - awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) + -- Each screen has its own tag table. + awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) - -- Create a promptbox for each screen - s.mypromptbox = awful.widget.prompt() - -- Create an imagebox widget which will contain an icon indicating which layout we're using. - -- We need one layoutbox per screen. - s.mylayoutbox = awful.widget.layoutbox(s) - s.mylayoutbox:buttons(gears.table.join( - awful.button({}, 1, function() awful.layout.inc(1) end), - awful.button({}, 3, function() awful.layout.inc(-1) end), - awful.button({}, 4, function() awful.layout.inc(1) end), - awful.button({}, 5, function() awful.layout.inc(-1) end))) - -- Create a taglist widget - s.mytaglist = awful.widget.taglist { - screen = s, - filter = awful.widget.taglist.filter.all, - buttons = taglist_buttons - } + -- Create a promptbox for each screen + s.mypromptbox = awful.widget.prompt() + -- Create an imagebox widget which will contain an icon indicating which layout we're using. + -- We need one layoutbox per screen. + s.mylayoutbox = awful.widget.layoutbox(s) + s.mylayoutbox:buttons(gears.table.join( + awful.button({}, 1, function() awful.layout.inc(1) end), + awful.button({}, 3, function() awful.layout.inc(-1) end), + awful.button({}, 4, function() awful.layout.inc(1) end), + awful.button({}, 5, function() awful.layout.inc(-1) end))) + -- Create a taglist widget + s.mytaglist = awful.widget.taglist { + screen = s, + filter = awful.widget.taglist.filter.all, + buttons = taglist_buttons + } - -- Create a tasklist widget - s.mytasklist = awful.widget.tasklist { - screen = s, - filter = awful.widget.tasklist.filter.currenttags, - buttons = tasklist_buttons - } + -- Create a tasklist widget + s.mytasklist = awful.widget.tasklist { + screen = s, + filter = awful.widget.tasklist.filter.currenttags, + buttons = tasklist_buttons + } - -- Create the wibox - s.mywibox = awful.wibar({ position = "top", screen = s }) + -- Create the wibox + s.mywibox = awful.wibar({ position = "top", screen = s }) - -- Add widgets to the wibox - s.mywibox:setup { - layout = wibox.layout.align.horizontal, - { -- Left widgets - layout = wibox.layout.fixed.horizontal, - --mylauncher, - s.mytaglist, - s.mypromptbox, - }, - s.mytasklist, -- Middle widget - { -- Right widgets - layout = wibox.layout.fixed.horizontal, - wibox.widget.systray(), - cpu_widget(), - ram_widget(), - net_speed_widget(), - spotify_widget({ - dim_when_paused = true, - dim_opacity = 0.5, - max_lenght = -1, - }), - batteryarc_widget({ - show_current_level = true, - size = 32, - }), - brightness_widget { - program = 'brightnessctl', - step = 5, - base = 60, - tooltip = true, - }, - weather_widget({ - api_key = API, - coordinates = { latitude, longitude }, - show_hourly_forecst = true, - show_daily_forecast = true, - }), - -- logout_menu_widget(), - mytextclock, - s.mylayoutbox, - }, - } + -- Add widgets to the wibox + s.mywibox:setup { + layout = wibox.layout.align.horizontal, + { -- Left widgets + layout = wibox.layout.fixed.horizontal, + --mylauncher, + s.mytaglist, + s.mypromptbox, + }, + s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + wibox.widget.systray(), + cpu_widget(), + ram_widget(), + net_speed_widget(), + spotify_widget({ + dim_when_paused = true, + dim_opacity = 0.5, + max_lenght = -1, + }), + batteryarc_widget({ + show_current_level = true, + size = 32, + }), + brightness_widget { + program = 'brightnessctl', + step = 5, + base = 60, + tooltip = true, + }, + weather_widget({ + api_key = API, + coordinates = { latitude, longitude }, + show_hourly_forecst = true, + show_daily_forecast = true, + }), + -- logout_menu_widget(), + mytextclock, + s.mylayoutbox, + }, + } end) -- }}} -- {{{ Mouse bindings root.buttons(gears.table.join( - awful.button({}, 3, function() mymainmenu:toggle() end), - awful.button({}, 4, awful.tag.viewnext), - awful.button({}, 5, awful.tag.viewprev) + awful.button({}, 3, function() mymainmenu:toggle() end), + awful.button({}, 4, awful.tag.viewnext), + awful.button({}, 5, awful.tag.viewprev) )) -- }}} -- {{{ Key bindings globalkeys = gears.table.join( - awful.key({}, "#233", function() brightness_widget:inc() end), -- increase brightness - awful.key({}, "#232", function() brightness_widget:dec() end), -- decrease brightness + awful.key({}, "#233", function() brightness_widget:inc() end), -- increase brightness + awful.key({}, "#232", function() brightness_widget:dec() end), -- decrease brightness - awful.key({}, "#123", function() awful.spawn.with_shell("pulsemixer --change-volume +5") end), -- increase volume - awful.key({}, "#122", function() awful.spawn.with_shell("pulsemixer --change-volume -5") end), -- decrease volume - awful.key({}, "#121", function() awful.spawn.with_shell("pulsemixer --toggle-mute") end), -- mute - awful.key({}, "#172", function() awful.spawn.with_shell("playerctl -a play-pause") end), -- play/pause + awful.key({}, "#123", function() awful.spawn.with_shell("pulsemixer --change-volume +5") end), -- increase volume + awful.key({}, "#122", function() awful.spawn.with_shell("pulsemixer --change-volume -5") end), -- decrease volume + awful.key({}, "#121", function() awful.spawn.with_shell("pulsemixer --toggle-mute") end), -- mute + awful.key({}, "#172", function() awful.spawn.with_shell("playerctl -a play-pause") end), -- play/pause - awful.key({ "Control" }, "#107", function() awful.spawn.with_shell("flameshot gui") end, - { description = "take region screenshot", group = "launcher" }), -- take region screenshot + awful.key({ "Control" }, "#107", function() awful.spawn.with_shell("flameshot gui") end, + { description = "take region screenshot", group = "launcher" }), -- take region screenshot - awful.key({ modkey, }, "s", hotkeys_popup.show_help, - { description = "show help", group = "awesome" }), - awful.key({ modkey, }, "Left", awful.tag.viewprev, - { description = "view previous", group = "tag" }), - awful.key({ modkey, }, "Right", awful.tag.viewnext, - { description = "view next", group = "tag" }), - awful.key({ modkey, }, "Escape", awful.tag.history.restore, - { description = "go back", group = "tag" }), + awful.key({ modkey, }, "s", hotkeys_popup.show_help, + { description = "show help", group = "awesome" }), + awful.key({ modkey, }, "Left", awful.tag.viewprev, + { description = "view previous", group = "tag" }), + awful.key({ modkey, }, "Right", awful.tag.viewnext, + { description = "view next", group = "tag" }), + awful.key({ modkey, }, "Escape", awful.tag.history.restore, + { description = "go back", group = "tag" }), - awful.key({ modkey, }, "j", function() awful.client.focus.byidx(1) end, - { description = "focus next by index", group = "client" } - ), - awful.key({ modkey, }, "k", function() awful.client.focus.byidx(-1) end, - { description = "focus previous by index", group = "client" } - ), - awful.key({ modkey, }, "w", function() mymainmenu:show() end, - { description = "show main menu", group = "awesome" }), + awful.key({ modkey, }, "j", function() awful.client.focus.byidx(1) end, + { description = "focus next by index", group = "client" } + ), + awful.key({ modkey, }, "k", function() awful.client.focus.byidx(-1) end, + { description = "focus previous by index", group = "client" } + ), + awful.key({ modkey, }, "w", function() mymainmenu:show() end, + { description = "show main menu", group = "awesome" }), - -- Layout manipulation - awful.key({ modkey, "Shift" }, "j", function() awful.client.swap.byidx(1) end, - { description = "swap with next client by index", group = "client" }), - awful.key({ modkey, "Shift" }, "k", function() awful.client.swap.byidx(-1) end, - { description = "swap with previous client by index", group = "client" }), - awful.key({ modkey, "Control" }, "j", function() awful.screen.focus_relative(1) end, - { description = "focus the next screen", group = "screen" }), - awful.key({ modkey, "Control" }, "k", function() awful.screen.focus_relative(-1) end, - { description = "focus the previous screen", group = "screen" }), - awful.key({ modkey, }, "u", awful.client.urgent.jumpto, - { description = "jump to urgent client", group = "client" }), - awful.key({ modkey, }, "Tab", function() awful.client.focus.history.previous() - if client.focus then - client.focus:raise() - end - end, - { description = "go back", group = "client" }), + -- Layout manipulation + awful.key({ modkey, "Shift" }, "j", function() awful.client.swap.byidx(1) end, + { description = "swap with next client by index", group = "client" }), + awful.key({ modkey, "Shift" }, "k", function() awful.client.swap.byidx(-1) end, + { description = "swap with previous client by index", group = "client" }), + awful.key({ modkey, "Control" }, "j", function() awful.screen.focus_relative(1) end, + { description = "focus the next screen", group = "screen" }), + awful.key({ modkey, "Control" }, "k", function() awful.screen.focus_relative(-1) end, + { description = "focus the previous screen", group = "screen" }), + awful.key({ modkey, }, "u", awful.client.urgent.jumpto, + { description = "jump to urgent client", group = "client" }), + awful.key({ modkey, }, "Tab", function() awful.client.focus.history.previous() + if client.focus then + client.focus:raise() + end + end, + { description = "go back", group = "client" }), - -- Standard program - awful.key({ modkey, }, "Return", function() awful.spawn(terminal) end, - { description = "open a terminal", group = "launcher" }), - awful.key({ modkey, "Control" }, "r", awesome.restart, - { description = "reload awesome", group = "awesome" }), - -- awful.key({ modkey, "Control" }, "q", awesome.quit, - -- {description = "quit awesome", group = "awesome"}), - awful.key({ modkey, }, "b", function() awful.spawn("firefox") end, - { description = "open firefox", group = "launcher" }), - awful.key({ modkey, }, "n", function() awful.spawn("spacefm") end, - { description = "open spacefm", group = "launcher" }), + -- Standard program + awful.key({ modkey, }, "Return", function() awful.spawn(terminal) end, + { description = "open a terminal", group = "launcher" }), + awful.key({ modkey, "Control" }, "r", awesome.restart, + { description = "reload awesome", group = "awesome" }), + -- awful.key({ modkey, "Control" }, "q", awesome.quit, + -- {description = "quit awesome", group = "awesome"}), + awful.key({ modkey, }, "b", function() awful.spawn("firefox") end, + { description = "open firefox", group = "launcher" }), + awful.key({ modkey, }, "n", function() awful.spawn("spacefm") end, + { description = "open spacefm", group = "launcher" }), - awful.key({ modkey, }, "l", function() awful.tag.incmwfact(0.05) end, - { description = "increase master width factor", group = "layout" }), - awful.key({ modkey, }, "h", function() awful.tag.incmwfact(-0.05) end, - { description = "decrease master width factor", group = "layout" }), - awful.key({ modkey, "Shift" }, "h", function() awful.tag.incnmaster(1, nil, true) end, - { description = "increase the number of master clients", group = "layout" }), - awful.key({ modkey, "Shift" }, "l", function() awful.tag.incnmaster(-1, nil, true) end, - { description = "decrease the number of master clients", group = "layout" }), - awful.key({ modkey, "Control" }, "h", function() awful.tag.incncol(1, nil, true) end, - { description = "increase the number of columns", group = "layout" }), - awful.key({ modkey, "Control" }, "l", function() awful.tag.incncol(-1, nil, true) end, - { description = "decrease the number of columns", group = "layout" }), - awful.key({ modkey, }, "space", function() awful.layout.inc(1) end, - { description = "select next", group = "layout" }), - awful.key({ modkey, "Shift" }, "space", function() awful.layout.inc(-1) end, - { description = "select previous", group = "layout" }), + awful.key({ modkey, }, "l", function() awful.tag.incmwfact(0.05) end, + { description = "increase master width factor", group = "layout" }), + awful.key({ modkey, }, "h", function() awful.tag.incmwfact(-0.05) end, + { description = "decrease master width factor", group = "layout" }), + awful.key({ modkey, "Shift" }, "h", function() awful.tag.incnmaster(1, nil, true) end, + { description = "increase the number of master clients", group = "layout" }), + awful.key({ modkey, "Shift" }, "l", function() awful.tag.incnmaster(-1, nil, true) end, + { description = "decrease the number of master clients", group = "layout" }), + awful.key({ modkey, "Control" }, "h", function() awful.tag.incncol(1, nil, true) end, + { description = "increase the number of columns", group = "layout" }), + awful.key({ modkey, "Control" }, "l", function() awful.tag.incncol(-1, nil, true) end, + { description = "decrease the number of columns", group = "layout" }), + awful.key({ modkey, }, "space", function() awful.layout.inc(1) end, + { description = "select next", group = "layout" }), + awful.key({ modkey, "Shift" }, "space", function() awful.layout.inc(-1) end, + { description = "select previous", group = "layout" }), - -- awful.key({ modkey, "Control" }, "n", - -- function () - -- local c = awful.client.restore() - -- -- Focus restored client - -- if c then - -- c:emit_signal( - -- "request::activate", "key.unminimize", {raise = true} - -- ) - -- end - -- end, - -- {description = "restore minimized", group = "client"}), + -- awful.key({ modkey, "Control" }, "n", + -- function () + -- local c = awful.client.restore() + -- -- Focus restored client + -- if c then + -- c:emit_signal( + -- "request::activate", "key.unminimize", {raise = true} + -- ) + -- end + -- end, + -- {description = "restore minimized", group = "client"}), - -- Prompt - awful.key({ modkey }, "r", function() awful.screen.focused().mypromptbox:run() end, - { description = "run prompt", group = "launcher" }), + -- Prompt + awful.key({ modkey }, "r", function() awful.screen.focused().mypromptbox:run() end, + { description = "run prompt", group = "launcher" }), - awful.key({ modkey }, "x", - function() - awful.prompt.run { - prompt = "Run Lua code: ", - textbox = awful.screen.focused().mypromptbox.widget, - exe_callback = awful.util.eval, - history_path = awful.util.get_cache_dir() .. "/history_eval" - } - end, - { description = "lua execute prompt", group = "awesome" }), - -- Menubar - awful.key({ modkey }, "p", function() menubar.show() end, - { description = "show the menubar", group = "launcher" }) + awful.key({ modkey }, "x", + function() + awful.prompt.run { + prompt = "Run Lua code: ", + textbox = awful.screen.focused().mypromptbox.widget, + exe_callback = awful.util.eval, + history_path = awful.util.get_cache_dir() .. "/history_eval" + } + end, + { description = "lua execute prompt", group = "awesome" }), + -- Menubar + awful.key({ modkey }, "p", function() menubar.show() end, + { description = "show the menubar", group = "launcher" }) ) clientkeys = gears.table.join( - awful.key({ modkey, }, "f", - function(c) - c.fullscreen = not c.fullscreen - c:raise() - end, - { description = "toggle fullscreen", group = "client" }), - awful.key({ modkey, "Shift" }, "q", function(c) c:kill() end, - { description = "close", group = "client" }), - awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle, - { description = "toggle floating", group = "client" }), - awful.key({ modkey, "Control" }, "Return", function(c) c:swap(awful.client.getmaster()) end, - { description = "move to master", group = "client" }), - awful.key({ modkey, }, "o", function(c) c:move_to_screen() end, - { description = "move to screen", group = "client" }), - awful.key({ modkey, }, "t", function(c) c.ontop = not c.ontop end, - { description = "toggle keep on top", group = "client" }), - awful.key({ modkey, }, "n", - function(c) - -- The client currently has the input focus, so it cannot be - -- minimized, since minimized clients can't have the focus. - c.minimized = true - end, - { description = "minimize", group = "client" }), - awful.key({ modkey, }, "m", - function(c) - c.maximized = not c.maximized - c:raise() - end, - { description = "(un)maximize", group = "client" }), - awful.key({ modkey, "Control" }, "m", - function(c) - c.maximized_vertical = not c.maximized_vertical - c:raise() - end, - { description = "(un)maximize vertically", group = "client" }), - awful.key({ modkey, "Shift" }, "m", - function(c) - c.maximized_horizontal = not c.maximized_horizontal - c:raise() - end, - { description = "(un)maximize horizontally", group = "client" }) + awful.key({ modkey, }, "f", + function(c) + c.fullscreen = not c.fullscreen + c:raise() + end, + { description = "toggle fullscreen", group = "client" }), + awful.key({ modkey, "Shift" }, "q", function(c) c:kill() end, + { description = "close", group = "client" }), + awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle, + { description = "toggle floating", group = "client" }), + awful.key({ modkey, "Control" }, "Return", function(c) c:swap(awful.client.getmaster()) end, + { description = "move to master", group = "client" }), + awful.key({ modkey, }, "o", function(c) c:move_to_screen() end, + { description = "move to screen", group = "client" }), + awful.key({ modkey, }, "t", function(c) c.ontop = not c.ontop end, + { description = "toggle keep on top", group = "client" }), + awful.key({ modkey, }, "n", + function(c) + -- The client currently has the input focus, so it cannot be + -- minimized, since minimized clients can't have the focus. + c.minimized = true + end, + { description = "minimize", group = "client" }), + awful.key({ modkey, }, "m", + function(c) + c.maximized = not c.maximized + c:raise() + end, + { description = "(un)maximize", group = "client" }), + awful.key({ modkey, "Control" }, "m", + function(c) + c.maximized_vertical = not c.maximized_vertical + c:raise() + end, + { description = "(un)maximize vertically", group = "client" }), + awful.key({ modkey, "Shift" }, "m", + function(c) + c.maximized_horizontal = not c.maximized_horizontal + c:raise() + end, + { description = "(un)maximize horizontally", group = "client" }) ) -- Bind all key numbers to tags. -- Be careful: we use keycodes to make it work on any keyboard layout. -- This should map on the top row of your keyboard, usually 1 to 9. for i = 1, 9 do - globalkeys = gears.table.join(globalkeys, - -- View tag only. - awful.key({ modkey }, "#" .. i + 9, - function() - local screen = awful.screen.focused() - local tag = screen.tags[i] - if tag then - tag:view_only() - end - end, - { description = "view tag #" .. i, group = "tag" }), - -- Toggle tag display. - awful.key({ modkey, "Control" }, "#" .. i + 9, - function() - local screen = awful.screen.focused() - local tag = screen.tags[i] - if tag then - awful.tag.viewtoggle(tag) - end - end, - { description = "toggle tag #" .. i, group = "tag" }), - -- Move client to tag. - awful.key({ modkey, "Shift" }, "#" .. i + 9, - function() - if client.focus then - local tag = client.focus.screen.tags[i] - if tag then - client.focus:move_to_tag(tag) - end - end - end, - { description = "move focused client to tag #" .. i, group = "tag" }), - -- Toggle tag on focused client. - awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, - function() - if client.focus then - local tag = client.focus.screen.tags[i] - if tag then - client.focus:toggle_tag(tag) - end - end - end, - { description = "toggle focused client on tag #" .. i, group = "tag" }) - ) + globalkeys = gears.table.join(globalkeys, + -- View tag only. + awful.key({ modkey }, "#" .. i + 9, + function() + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + tag:view_only() + end + end, + { description = "view tag #" .. i, group = "tag" }), + -- Toggle tag display. + awful.key({ modkey, "Control" }, "#" .. i + 9, + function() + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + awful.tag.viewtoggle(tag) + end + end, + { description = "toggle tag #" .. i, group = "tag" }), + -- Move client to tag. + awful.key({ modkey, "Shift" }, "#" .. i + 9, + function() + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:move_to_tag(tag) + end + end + end, + { description = "move focused client to tag #" .. i, group = "tag" }), + -- Toggle tag on focused client. + awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, + function() + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:toggle_tag(tag) + end + end + end, + { description = "toggle focused client on tag #" .. i, group = "tag" }) + ) end clientbuttons = gears.table.join( - awful.button({}, 1, function(c) - c:emit_signal("request::activate", "mouse_click", { raise = true }) - end), - awful.button({ modkey }, 1, function(c) - c:emit_signal("request::activate", "mouse_click", { raise = true }) - awful.mouse.client.move(c) - end), - awful.button({ modkey }, 3, function(c) - c:emit_signal("request::activate", "mouse_click", { raise = true }) - awful.mouse.client.resize(c) - end) + awful.button({}, 1, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + end), + awful.button({ modkey }, 1, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + awful.mouse.client.move(c) + end), + awful.button({ modkey }, 3, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + awful.mouse.client.resize(c) + end) ) -- Set keys @@ -528,131 +528,131 @@ root.keys(globalkeys) -- {{{ Rules -- Rules to apply to new clients (through the "manage" signal). awful.rules.rules = { - -- All clients will match this rule. - { rule = {}, - properties = { border_width = beautiful.border_width, - border_color = beautiful.border_normal, - focus = awful.client.focus.filter, - raise = true, - keys = clientkeys, - -- buttons = clientbuttons, - screen = awful.screen.preferred, - --placement = awful.placement.no_overlap+awful.placement.no_offscreen - } - }, + -- All clients will match this rule. + { rule = {}, + properties = { border_width = beautiful.border_width, + border_color = beautiful.border_normal, + focus = awful.client.focus.filter, + raise = true, + keys = clientkeys, + -- buttons = clientbuttons, + screen = awful.screen.preferred, + --placement = awful.placement.no_overlap+awful.placement.no_offscreen + } + }, - -- Floating clients. - { rule_any = { - instance = { - "DTA", -- Firefox addon DownThemAll. - "copyq", -- Includes session name in class. - "pinentry", - }, - class = { - "Blueman-manager", - "MessageWin", -- kalarm. - "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size. - "Wpa_gui", - "veromix", - "xtightvncviewer" }, + -- Floating clients. + { rule_any = { + instance = { + "DTA", -- Firefox addon DownThemAll. + "copyq", -- Includes session name in class. + "pinentry", + }, + class = { + "Blueman-manager", + "MessageWin", -- kalarm. + "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size. + "Wpa_gui", + "veromix", + "xtightvncviewer" }, - -- Note that the name property shown in xprop might be set slightly after creation of the client - -- and the name shown there might not match defined rules here. - name = { - "Event Tester", -- xev. - }, - role = { - "AlarmWindow", -- Thunderbird's calendar. - "ConfigManager", -- Thunderbird's about:config. - "pop-up", -- e.g. Google Chrome's (detached) Developer Tools. - } - }, properties = { floating = true, beautiful.useless } }, + -- Note that the name property shown in xprop might be set slightly after creation of the client + -- and the name shown there might not match defined rules here. + name = { + "Event Tester", -- xev. + }, + role = { + "AlarmWindow", -- Thunderbird's calendar. + "ConfigManager", -- Thunderbird's about:config. + "pop-up", -- e.g. Google Chrome's (detached) Developer Tools. + } + }, properties = { floating = true, beautiful.useless } }, - -- Add titlebars to normal clients and dialogs - { rule_any = { type = { "normal", "dialog" } - }, properties = { titlebars_enabled = false } - }, + -- Add titlebars to normal clients and dialogs + { rule_any = { type = { "normal", "dialog" } + }, properties = { titlebars_enabled = false } + }, { rule_any = { class = { "tuxedo-control-center", "corectrl" } }, properties = { screen = 1, tag = "7" } }, - { - rule_any = { - class = { "Thunderbird", "discord", "ripcord", "TelegramDesktop" } - }, properties = { screen = 1, tag = "8" } - }, + { + rule_any = { + class = { "Thunderbird", "discord", "ripcord", "TelegramDesktop" } + }, properties = { screen = 1, tag = "8" } + }, { rule_any = { class = { "spotify", "Spotify" }, }, properties = { screen = 1, tag = "9" } }, - -- Set Firefox to always map on the tag named "2" on screen 1. - -- { rule = { class = "Firefox" }, - -- properties = { screen = 1, tag = "2" } }, + -- Set Firefox to always map on the tag named "2" on screen 1. + -- { rule = { class = "Firefox" }, + -- properties = { screen = 1, tag = "2" } }, } -- }}} -- {{{ Signals -- Signal function to execute when a new client appears. client.connect_signal("manage", function(c) - -- Set the windows at the slave, - -- i.e. put it at the end of others instead of setting it master. - -- if not awesome.startup then awful.client.setslave(c) end + -- Set the windows at the slave, + -- i.e. put it at the end of others instead of setting it master. + -- if not awesome.startup then awful.client.setslave(c) end - if awesome.startup - and not c.size_hints.user_position - and not c.size_hints.program_position then - -- Prevent clients from being unreachable after screen count changes. - awful.placement.no_offscreen(c) - end + if awesome.startup + and not c.size_hints.user_position + and not c.size_hints.program_position then + -- Prevent clients from being unreachable after screen count changes. + awful.placement.no_offscreen(c) + end end) -- Add a titlebar if titlebars_enabled is set to true in the rules. client.connect_signal("request::titlebars", function(c) - -- buttons for the titlebar - local buttons = gears.table.join( - awful.button({}, 1, function() - c:emit_signal("request::activate", "titlebar", { raise = true }) - awful.mouse.client.move(c) - end), - awful.button({}, 3, function() - c:emit_signal("request::activate", "titlebar", { raise = true }) - awful.mouse.client.resize(c) - end) - ) + -- buttons for the titlebar + local buttons = gears.table.join( + awful.button({}, 1, function() + c:emit_signal("request::activate", "titlebar", { raise = true }) + awful.mouse.client.move(c) + end), + awful.button({}, 3, function() + c:emit_signal("request::activate", "titlebar", { raise = true }) + awful.mouse.client.resize(c) + end) + ) - awful.titlebar(c):setup { - { -- Left - awful.titlebar.widget.iconwidget(c), - buttons = buttons, - layout = wibox.layout.fixed.horizontal - }, - { -- Middle - { -- Title - align = "center", - widget = awful.titlebar.widget.titlewidget(c) - }, - buttons = buttons, - layout = wibox.layout.flex.horizontal - }, - { -- Right - awful.titlebar.widget.floatingbutton(c), - awful.titlebar.widget.maximizedbutton(c), - awful.titlebar.widget.stickybutton(c), - awful.titlebar.widget.ontopbutton(c), - awful.titlebar.widget.closebutton(c), - layout = wibox.layout.fixed.horizontal() - }, - layout = wibox.layout.align.horizontal - } + awful.titlebar(c):setup { + { -- Left + awful.titlebar.widget.iconwidget(c), + buttons = buttons, + layout = wibox.layout.fixed.horizontal + }, + { -- Middle + { -- Title + align = "center", + widget = awful.titlebar.widget.titlewidget(c) + }, + buttons = buttons, + layout = wibox.layout.flex.horizontal + }, + { -- Right + awful.titlebar.widget.floatingbutton(c), + awful.titlebar.widget.maximizedbutton(c), + awful.titlebar.widget.stickybutton(c), + awful.titlebar.widget.ontopbutton(c), + awful.titlebar.widget.closebutton(c), + layout = wibox.layout.fixed.horizontal() + }, + layout = wibox.layout.align.horizontal + } end) -- Enable sloppy focus, so that focus follows mouse. client.connect_signal("mouse::enter", function(c) - c:emit_signal("request::activate", "mouse_enter", { raise = false }) + c:emit_signal("request::activate", "mouse_enter", { raise = false }) end) client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index e8bcc5e0..59c126a9 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -29,12 +29,10 @@ call plug#begin() Plug 'andweeb/presence.nvim' Plug 'ap/vim-css-color' -Plug 'hrsh7th/nvim-cmp' Plug 'jiangmiao/auto-pairs' Plug 'kyazdani42/nvim-web-devicons' Plug 'L3MON4D3/LuaSnip' Plug 'lewis6991/gitsigns.nvim' -Plug 'lewis6991/gitsigns.nvim' Plug 'lukas-reineke/indent-blankline.nvim' Plug 'mattn/emmet-vim' Plug 'Mofiqul/dracula.nvim' @@ -48,9 +46,9 @@ Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'preservim/nerdtree' Plug 'rafi/awesome-vim-colorschemes' Plug 'ryanoasis/vim-devicons' -Plug 'saadparwaiz1/cmp_luasnip' Plug 'sbdchd/neoformat' Plug 'vimwiki/vimwiki' +Plug 'saecki/crates.nvim' " cmp Plug 'williamboman/nvim-lsp-installer' Plug 'neovim/nvim-lspconfig' @@ -59,6 +57,8 @@ Plug 'hrsh7th/cmp-buffer' Plug 'hrsh7th/cmp-path' Plug 'hrsh7th/cmp-cmdline' Plug 'hrsh7th/nvim-cmp' +Plug 'saadparwaiz1/cmp_luasnip' + call plug#end() @@ -129,44 +129,54 @@ lua << END require('gitsigns').setup() require('Comment').setup() require 'colorizer'.setup() +require('crates').setup() +vim.opt.list = true +vim.opt.listchars:append "eol:↴" +vim.opt.listchars:append "space:⋅" +require('indent_blankline').setup({ + space_char_blankline = " ", + show_end_of_line = true, + show_current_context = true, + show_current_context_start = true, +}) require("nvim-lsp-installer").setup({ - automatic_installation = true, -- automatically detect which servers to install (based on which servers are set up via lspconfig) - ui = { - icons = { - server_installed = "✓", - server_pending = "➜", - server_uninstalled = "✗" - } - } + automatic_installation = true, -- automatically detect which servers to install (based on which servers are set up via lspconfig) + ui = { + icons = { + server_installed = "✓", + server_pending = "➜", + server_uninstalled = "✗" + } + } }) require('lualine').setup { - options = { - icons_enabled = true, - theme = 'dracula', - component_separators = { left = '', right = ''}, - section_separators = { left = '', right = ''}, - disabled_filetypes = {}, - always_divide_middle = true, - globalstatus = false, - }, - sections = { - lualine_a = {'mode'}, - lualine_b = {'branch', 'diff', 'diagnostics'}, - lualine_c = {'filename'}, - lualine_x = {'encoding', 'fileformat', 'filetype'}, - lualine_y = {'progress'}, - lualine_z = {'location'} - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = {'filename'}, - lualine_x = {'location'}, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - extensions = {} + options = { + icons_enabled = true, + theme = 'dracula', + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = {}, + always_divide_middle = true, + globalstatus = false, + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'fileformat', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + extensions = {} } require('telescope').setup{ defaults = { @@ -199,32 +209,32 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer local on_attach = function(client, bufnr) - -- Enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local bufopts = { noremap=true, silent=true, buffer=bufnr } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) - vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) - vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) - vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) - vim.keymap.set('n', 'wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, bufopts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) - vim.keymap.set('n', 'f', vim.lsp.buf.formatting, bufopts) + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local bufopts = { noremap=true, silent=true, buffer=bufnr } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', 'f', vim.lsp.buf.formatting, bufopts) end local lsp_flags = { - -- This is the default in Nvim 0.7+ - debounce_text_changes = 150, + -- This is the default in Nvim 0.7+ + debounce_text_changes = 150, } END @@ -238,40 +248,40 @@ local cmp = require'cmp' cmp.setup({ snippet = { - -- REQUIRED - you must specify a snippet engine - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. - -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. - -- require('snippy').expand_snippet(args.body) -- For `snippy` users. - -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. - end, + -- REQUIRED - you must specify a snippet engine + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + -- require('snippy').expand_snippet(args.body) -- For `snippy` users. + -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. + end, }, window = { - -- completion = cmp.config.window.bordered(), - -- documentation = cmp.config.window.bordered(), + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), }, mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }), sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'vsnip' }, -- For vsnip users. - -- { name = 'luasnip' }, -- For luasnip users. - -- { name = 'ultisnips' }, -- For ultisnips users. - -- { name = 'snippy' }, -- For snippy users. + { name = 'nvim_lsp' }, + { name = 'vsnip' }, -- For vsnip users. + -- { name = 'luasnip' }, -- For luasnip users. + -- { name = 'ultisnips' }, -- For ultisnips users. + -- { name = 'snippy' }, -- For snippy users. }, { - { name = 'buffer' }, + { name = 'buffer' }, }) }) -- Set configuration for specific filetype. cmp.setup.filetype('gitcommit', { sources = cmp.config.sources({ - { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. + { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. }, { { name = 'buffer' }, }) @@ -281,7 +291,7 @@ sources = cmp.config.sources({ cmp.setup.cmdline('/', { mapping = cmp.mapping.preset.cmdline(), sources = { - { name = 'buffer' } + { name = 'buffer' } } }) @@ -289,9 +299,9 @@ sources = { cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ - { name = 'path' } + { name = 'path' } }, { - { name = 'cmdline' } + { name = 'cmdline' } }) })