updates to nvim and scripts

This commit is contained in:
Solomon Laing 2023-04-27 07:27:27 +09:30
parent 3d1dad6d2f
commit dd31193cef
13 changed files with 57 additions and 33 deletions

View File

@ -33,6 +33,7 @@ export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quo
bind '"\C-o":"lfcd\n"' bind '"\C-o":"lfcd\n"'
bind '"\C-t":"tms\n"' bind '"\C-t":"tms\n"'
bind '"\C-T":"tms $(pwd)\n"'
bind '"\C-n":"zk edit --interactive --sort modified-\n"' bind '"\C-n":"zk edit --interactive --sort modified-\n"'
bind '"\C-f":"cd $(dirname "$(fzf)")\n"' bind '"\C-f":"cd $(dirname "$(fzf)")\n"'

View File

@ -23,7 +23,7 @@ require("lazyvim.config").setup()
if not vim.g.vscode then if not vim.g.vscode then
require("lazy").setup({ require("lazy").setup({
spec = "lazyvim.plugins", spec = "lazyvim.plugins",
defaults = { lazy = true, version = "*" }, defaults = { lazy = true, version = false },
checker = { enabled = true }, checker = { enabled = true },
}) })
end end

View File

@ -19,8 +19,10 @@ return {
virtual_text = { spacing = 4, prefix = "" }, virtual_text = { spacing = 4, prefix = "" },
severity_sort = true, severity_sort = true,
}, },
autoformat = true,
servers = { servers = {
lua_ls = { lua_ls = {
mason = true,
settings = { settings = {
Lua = { Lua = {
workspace = { workspace = {
@ -45,11 +47,13 @@ return {
}, },
}, },
config = function(plugin, opts) config = function(plugin, opts)
local Util = require("lazyvim.utils")
-- setup autoformat
require("lazyvim.plugins.lsp.format").autoformat = opts.autoformat
-- setup formatting and keymaps -- setup formatting and keymaps
require("lazyvim.utils").on_attach(function(client, buffer) Util.on_attach(function(client, buffer)
require("lazyvim.plugins.lsp.format").on_attach(client, buffer) require("lazyvim.plugins.lsp.format").on_attach(client, buffer)
require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer) require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
require("lazyvim.plugins.lsp.misc").on_attach(client, buffer)
end) end)
-- diagnostics -- diagnostics
@ -58,11 +62,28 @@ return {
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
end end
vim.diagnostic.config(opts.diagnostics) if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then
opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and ""
or function(diagnostic)
local icons = require("lazyvim.config").icons.diagnostics
for d, icon in pairs(icons) do
if diagnostic.severity == vim.diagnostic.severity[d:upper()] then
return icon
end
end
end
end
vim.diagnostic.config(vim.deepcopy(opts.diagnostics))
local servers = opts.servers local servers = opts.servers
local capabilities = local capabilities = vim.tbl_deep_extend(
require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) "force",
{},
vim.lsp.protocol.make_client_capabilities(),
require("cmp_nvim_lsp").default_capabilities(),
opts.capabilities or {}
)
local function setup(server) local function setup(server)
local server_opts = vim.tbl_deep_extend("force", { local server_opts = vim.tbl_deep_extend("force", {
@ -81,15 +102,19 @@ return {
require("lspconfig")[server].setup(server_opts) require("lspconfig")[server].setup(server_opts)
end end
local mlsp = require("mason-lspconfig") -- get all the servers that are available thourgh mason-lspconfig
local available = mlsp.get_available_servers() local have_mason, mlsp = pcall(require, "mason-lspconfig")
local all_mslp_servers = {}
if have_mason then
all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package)
end
local ensure_installed = {} ---@type string[] local ensure_installed = {} ---@type string[]
for server, server_opts in pairs(servers) do for server, server_opts in pairs(servers) do
if server_opts then if server_opts then
server_opts = server_opts == true and {} or server_opts server_opts = server_opts == true and {} or server_opts
-- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig -- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig
if server_opts.mason == false or not vim.tbl_contains(available, server) then if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then
setup(server) setup(server)
else else
ensure_installed[#ensure_installed + 1] = server ensure_installed[#ensure_installed + 1] = server
@ -97,8 +122,10 @@ return {
end end
end end
require("mason-lspconfig").setup({ ensure_installed = ensure_installed }) if have_mason then
require("mason-lspconfig").setup_handlers({ setup }) mlsp.setup({ ensure_installed = ensure_installed })
mlsp.setup_handlers({ setup })
end
end, end,
}, },
@ -110,6 +137,7 @@ return {
opts = function() opts = function()
local nls = require("null-ls") local nls = require("null-ls")
return { return {
root_dir = require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git"),
debug = false, debug = false,
sources = { sources = {
nls.builtins.formatting.stylua, nls.builtins.formatting.stylua,
@ -143,7 +171,6 @@ return {
"stylua", "stylua",
"shellcheck", "shellcheck",
"shfmt", "shfmt",
"flake8",
}, },
}, },
config = function(plugin, opts) config = function(plugin, opts)

View File

@ -182,10 +182,12 @@ return {
on_open = function() on_open = function()
vim.g.cmp_active = false vim.g.cmp_active = false
vim.cmd([[LspStop]]) vim.cmd([[LspStop]])
vim.opt.sidescrolloff = 0
end, end,
on_close = function() on_close = function()
vim.g.cmp_active = true vim.g.cmp_active = true
vim.cmd([[LspStart]]) vim.cmd([[LspStart]])
vim.opt.sidescrolloff = 8
end, end,
}) })
end, end,

View File

@ -55,7 +55,6 @@ alias \
tmn="tmux new" \ tmn="tmux new" \
tma="tmux-worker" \ tma="tmux-worker" \
tms="tmux-sessioniser" \ tms="tmux-sessioniser" \
tm.="tmux-sessioniser ."
# Alias some extra things for ease of use # Alias some extra things for ease of use
alias \ alias \

View File

@ -37,10 +37,6 @@ set -g mouse on
# Key Binds # Key Binds
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# forget the find window. That is for chumps
bind-key -r f run-shell "tmux neww tmux-sessionizer"
bind-key -r i run-shell "tmux neww cht.sh"
# Reload the tmux config. # Reload the tmux config.
bind-key r source-file ~/.config/tmux/tmux.conf bind-key r source-file ~/.config/tmux/tmux.conf

View File

@ -1,13 +1,7 @@
#!/bin/bash #!/bin/bash
default_loc="$HOME/.cache/pactl-default-sink"
if [ ! -f "$default_loc" ] ; then
set-default-sink
fi
default=$(<"$default_loc")
value=${1-$(echo -e "" | dmenu -bw 0 -i -p "Set vol to what?")} value=${1-$(echo -e "" | dmenu -bw 0 -i -p "Set vol to what?")}
pactl set-sink-volume "$default" "$value%" wpctl set-volume @DEFAULT_AUDIO_SINK@ "$value%"
pkill -RTMIN+3 dwmblocks

View File

@ -1,7 +1,8 @@
#!/bin/bash #!/bin/bash
case $BUTTON in case $BUTTON in
3) notify-send "Scroll to change adjust backlight." ;; 3) notify-send "Battery Module" "Shows battery status info
- Scroll to adjust the backlight.";;
4) mod_backlight up ;; 4) mod_backlight up ;;
5) mod_backlight down ;; 5) mod_backlight down ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;; 6) "$TERMINAL" -e "$EDITOR" "$0" ;;

View File

@ -3,7 +3,8 @@
case $BUTTON in case $BUTTON in
1) notify-send "This Month" "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s|..27m|</span></b>|")" && notify-send "Appointments" "$(calcurse -d3)" ;; 1) notify-send "This Month" "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s|..27m|</span></b>|")" && notify-send "Appointments" "$(calcurse -d3)" ;;
2) setsid -f "$TERMINAL" -e calcurse ;; 2) setsid -f "$TERMINAL" -e calcurse ;;
3) notify-send "Time/date module" "\- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\` 3) notify-send "Time/date module" "Shows calendar and appointments
- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\`
- Middle click opens calcurse if installed" ;; - Middle click opens calcurse if installed" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;; 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac esac

View File

@ -4,7 +4,8 @@ homeval=$(df -h -B 1048576 | grep "/home")
case $BUTTON in case $BUTTON in
1) notify-send "Disk space" "$(df -h --output=target,used,size)" ;; 1) notify-send "Disk space" "$(df -h --output=target,used,size)" ;;
3) notify-send "Disk module" "Click to show all disk info." ;; 3) notify-send "Disk module" "Shows disk usage information
- Click to show all disk info." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;; 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac esac

View File

@ -3,7 +3,7 @@
case $BUTTON in case $BUTTON in
1) notify-send "Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;; 1) notify-send "Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;;
2) setsid -f "$TERMINAL" -e htop ;; 2) setsid -f "$TERMINAL" -e htop ;;
3) notify-send "Memory module" "\- Shows Memory Used/Total. 3) notify-send "Memory module" "Shows Memory Used/Total.
- Click to show memory hogs. - Click to show memory hogs.
- Middle click to open htop." ;; - Middle click to open htop." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;; 6) "$TERMINAL" -e "$EDITOR" "$0" ;;

View File

@ -4,9 +4,10 @@
# Show  if connected to ethernet or ❎ if none. # Show  if connected to ethernet or ❎ if none.
# Show 🔒 if a vpn connection is active # Show 🔒 if a vpn connection is active
case $BLOCK_BUTTON in case $BUTTON in
1) "$TERMINAL" -e nmtui; pkill -RTMIN+15 dwmblocks ;; 1) "$TERMINAL" -e nmtui; pkill -RTMIN+15 dwmblocks ;;
3) notify-send "Internet module" "\- Click to connect 3) notify-send "Internet module" "Shows network status
- Click to connect
❌: wifi disabled ❌: wifi disabled
󰖪 : no wifi connection 󰖪 : no wifi connection
 : wifi connection with quality  : wifi connection with quality

View File

@ -7,7 +7,8 @@ case $BUTTON in
2) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;; 2) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;;
4) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+ ;; 4) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+ ;;
5) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%- ;; 5) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%- ;;
3) notify-send "Volume module" "\- Shows volume,  if muted. 3) notify-send "Volume module" "Shows current volume
- Shows volume,  if muted.
- Middle click to mute. - Middle click to mute.
- Scroll to change." ;; - Scroll to change." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;; 6) "$TERMINAL" -e "$EDITOR" "$0" ;;