finish(?) lsp config for nvim; add bt battery status to waybar; change wallpaper ellemayo

main
Ayush Mukherjee 2 years ago
parent f65bfbadb5
commit 5ff0fa7e71

@ -24,6 +24,7 @@ require('packer').startup(function()
use {
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
'RubixDev/mason-update-all',
'neovim/nvim-lspconfig'
}
use 'joshdick/onedark.vim'

@ -60,15 +60,15 @@ local function lsp_keymaps(bufnr)
keymap(bufnr, "n", "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
keymap(bufnr, "n", "gl", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
keymap(bufnr, "n", "\\lf", "<cmd>lua vim.lsp.buf.format<cr>", opts)
keymap(bufnr, "n", "\\li", "<cmd>LspInfo<cr>", opts)
keymap(bufnr, "n", "\\lI", "<cmd>LspInstallInfo<cr>", opts)
keymap(bufnr, "n", "\\la", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts)
keymap(bufnr, "n", "\\lj", "<cmd>lua vim.diagnostic.goto_next({buffer=0})<cr>", opts)
keymap(bufnr, "n", "\\lk", "<cmd>lua vim.diagnostic.goto_prev({buffer=0})<cr>", opts)
keymap(bufnr, "n", "\\lr", "<cmd>lua vim.lsp.buf.rename()<cr>", opts)
keymap(bufnr, "n", "\\ls", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
keymap(bufnr, "n", "\\lq", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
keymap(bufnr, "n", "<leader>lf", "<cmd>lua vim.lsp.buf.format<cr>", opts)
keymap(bufnr, "n", "<leader>li", "<cmd>LspInfo<cr>", opts)
keymap(bufnr, "n", "<leader>lI", "<cmd>LspInstallInfo<cr>", opts)
keymap(bufnr, "n", "<leadr>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts)
keymap(bufnr, "n", "<leader>lj", "<cmd>lua vim.diagnostic.goto_next({buffer=0})<cr>", opts)
keymap(bufnr, "n", "<leader>lk", "<cmd>lua vim.diagnostic.goto_prev({buffer=0})<cr>", opts)
keymap(bufnr, "n", "<leader>lr", "<cmd>lua vim.lsp.buf.rename()<cr>", opts)
keymap(bufnr, "n", "<leader>ls", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
keymap(bufnr, "n", "<leader>lq", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
end
M.on_attach = function(client, bufnr)

@ -9,6 +9,14 @@ require('mason-lspconfig').setup({
ensure_installed = servers,
automatic_installation = true,
})
require('mason-update-all').setup()
vim.api.nvim_create_autocmd('User', {
pattern = 'MasonUpdateAllComplete',
callback = function()
print('mason-update-all has finished')
end,
})
local lsp_status_ok, lspconfig = pcall(require, 'lspconfig')
if not lsp_status_ok then

@ -0,0 +1,8 @@
return {
settings = {
init_options = {
["language_server_phpstan.enabled"] = false,
["language_server_psalm.enabled"] = false,
}
},
}

@ -1,7 +1,7 @@
# set edp
output eDP-1 {
mode 1920x1080@60.004Hz
# mode 1920x1080@144.003Hz
#mode 1920x1080@60.004Hz
mode 1920x1080@144.003Hz
scale 1.25
adaptive_sync on
}
@ -29,6 +29,9 @@ exec_always {
gsettings set org.gnome.desktop.interface font-name "Cantarell"
}
# polkit
exec /usr/bin/lxpolkit
# set mod to super
set $mod Mod4
@ -207,7 +210,7 @@ gaps inner 20
#smart_gaps on
# set desktop bg
exec_always --no-startup-id swaybg -i ~/.config/sway/wall.jpg -m stretch
exec_always swaybg -i ~/.config/sway/wall.jpg -m stretch
# start picom, config: .config/picom.conf
#exec --no-startup-id dbus-launch picom --experimental-backend
@ -254,12 +257,13 @@ bindsym XF86MonBrightnessDown exec sudo /usr/bin/light -U 10
# Custom Bindings for Applications
# Mod + n firefox
bindsym $mod+n exec firefox
bindsym $mod+n exec firefox -p
#bindsym $mod+n exec "brave --enable-features=VaapiVideoDecoder --use-gl=desktop --disable-features=UseChromeOSDirectVideoDecoder --disable-gpu-memory-buffer-compositor-resources --disable-gpu-memory-buffer-video-frames --enable-hardware-overlays"
#bindsym $mod+n exec "brave --enable-features=VaapiVideoEncoder,VaapiVideoDecoder,CanvasOopRasterization --enable-video-acceleration --enable-zero-copy --use-gl=desktop --ignore-gpu-blocklist --ignore-gpu-blacklist --enable-oop-rasterization --enable-raw-draw --enable-gpu-rasterization --use-vulkan --disable-reading-from-canvas --disable-sync-preferences"
# Mod + b min
bindsym $mod+b exec "min --use-gl=desktop --enable-features=VaapiVideoDecoder,VaapiVideoEncoder,CanvasOopRasterization --ozone-platform-hint=auto --ignore-gpu-blocklist --enable-gpu-rasterization --enable-zero-copy --disable-features=UseSkiaRenderer,UseChromeOSDirectVideoDecoder --canvas-oop-rasterization"
# Mod + b (old: min) notesnook
#bindsym $mod+b exec "min --use-gl=desktop --enable-features=VaapiVideoDecoder,VaapiVideoEncoder,CanvasOopRasterization --ozone-platform-hint=auto --ignore-gpu-blocklist --enable-gpu-rasterization --enable-zero-copy --disable-features=UseSkiaRenderer,UseChromeOSDirectVideoDecoder --canvas-oop-rasterization"
bindsym $mod+b exec "notesnook --ozone-platform=wayland --ozone-platform-hint=wayland"
# Mod + m pantheon files
bindsym $mod+m exec io.elementary.files
@ -275,6 +279,7 @@ assign [class="discord"] 10
# make notification windows floating
for_window [window_role="pop-up"] floating enable
for_window [window_role="task_dialog"] floating enable
for_window [title="\ -\ Sharing\ Indicator$"] floating enable, sticky enable
# fix notifs for ms teams
for_window [title="Microsoft Teams Notification"] floating enable

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 MiB

After

Width:  |  Height:  |  Size: 2.0 MiB

@ -6,7 +6,7 @@
// Choose the order of the modules
"modules-left": ["sway/workspaces", "sway/mode"],
"modules-center": [],
"modules-right": ["battery", "pulseaudio", "cpu", "temperature", "memory", "backlight", "clock", "tray"],
"modules-right": ["custom/bluetooth-battery", "battery", "pulseaudio", "cpu", "temperature", "memory", "backlight", "clock", "tray"],
"fixed-center": true,
"sway/mode": {
"format": "<span style=\"italic\">{}</span>"
@ -47,6 +47,14 @@
"format-alt": "{icon} {time}",
"format-icons": ["", "", "", "", ""]
},
"custom/bluetooth-battery": {
"format": "{}",
"return-type": "json",
"interval": 5,
"exec": "~/.config/waybar/scripts/bt-bat-waybar-module.sh",
"exec-if": "~/.config/waybar/scripts/bt-bat-status.sh >/dev/null 2>&1",
"signal": 9
},
"network": {
// "interface": "wlp2*", // (Optional) To force the use of this interface
"format-wifi": "{essid} ({signalStrength}%) ",

@ -0,0 +1,54 @@
#!/bin/bash
SCRIPTS_DIR=~/.config/waybar/scripts
get_battery_status() {
device_uuid=$1
device_uuid_slug=$(echo "$device_uuid" | sed 's/:/_/g')
device_upower_path=$(upower -e | grep "$device_uuid_slug")
if [[ "$?" != 0 ]]; then
return 1
fi
upower_out=$(upower -i "$device_upower_path")
percentage=$(echo "$upower_out" | grep 'percentage:' | grep -oe '[0-9]*%')
if [[ "$?" != 0 ]]; then
return 1
fi
echo $percentage
}
# prepare devices to process
connected_devices=$1
if [[ "$connected_devices" == "" ]]; then
connected_devices=$($SCRIPTS_DIR/bt-connected.sh)
fi
if [[ "$connected_devices" == "" ]]; then
echo "no bluetooth devices connected" >&2
exit 1
fi
n=0
declare -A device_batteries
for device in ${connected_devices//\\n/ }; do
device_battery_percentage=$(get_battery_status "$device")
if [[ $? != 0 ]]; then
continue
fi
n=$((n+1))
device_batteries[$device]=$device_battery_percentage
# echo "$device: $device_battery_percentage"
done
if [[ $n -eq 0 ]]; then
echo "cannot get battery status for any specified bluetooth device" >&2
exit 1
fi
# TODO: do something else?
for device in ${!device_batteries[*]}; do
echo "$device ${device_batteries[$device]}"
done

@ -0,0 +1,52 @@
#!/bin/bash
ICON_BLUETOOTH=""
ICON_BATTERY_FULL=" "
ICON_BATTERY_THREE_QUARTERS=" "
ICON_BATTERY_HALF=" "
ICON_BATTERY_QUARTER=" "
ICON_BATTERY_EMPTY=" "
BLUETOOTH_BATTERY_STATUS=~/.config/waybar/scripts/bt-bat-status.sh
tooltip=""
statuses="$($BLUETOOTH_BATTERY_STATUS)"
if [[ $? != 0 ]]; then
exit 1
fi
n=0
sum=0
IFS=$'\n'
for status in $statuses; do
uuid=$(echo "$status" | cut -d' ' -f1)
name=$(bluetoothctl info "$uuid" | grep -oe 'Name: .*' | awk 'match($0, "Name: (.*)", m){print m[1]}')
percent=$(echo "$status" | cut -d' ' -f2 | grep -oe '[0-9]*')
tooltip="$tooltip$name: $percent%\n"
n=$((n+1))
sum=$((sum+percent))
done
IFS=' '
avg=$((sum / n))
ICON_BATTERY=""
if [[ $avg -ge 90 ]]; then
ICON_BATTERY=$ICON_BATTERY_FULL
elif [[ $avg -ge 75 ]]; then
ICON_BATTERY=$ICON_BATTERY_THREE_QUARTERS
elif [[ $avg -ge 50 ]]; then
ICON_BATTERY=$ICON_BATTERY_HALF
elif [[ $avg -ge 25 ]]; then
ICON_BATTERY=$ICON_BATTERY_QUARTER
else
ICON_BATTERY=$ICON_BATTERY_EMPTY
fi
tooltip=${tooltip%\\n}
echo "{\"text\": \"$ICON_BLUETOOTH $ICON_BATTERY\", \"tooltip\": \"$tooltip\"}"

@ -0,0 +1,3 @@
#!/bin/bash
bluetoothctl devices | cut -f2 -d' ' | while read uuid; do bluetoothctl info $uuid | grep -B9 -e 'Connected: yes' | grep -e 'Device' | cut -f2 -d' '; done
Loading…
Cancel
Save