Compare commits

...

3 Commits

Author SHA1 Message Date
174e7a8249 Update arch-firstinstall 2024-07-20 14:38:55 +02:00
6e17c8f6a6 nvim: Update rust-tools to rustaceanvim
Also other stuff
2024-07-20 14:38:38 +02:00
0e1f393379 eww: Improveme stuff 2024-07-20 14:38:06 +02:00
8 changed files with 239 additions and 42 deletions

View File

@ -71,6 +71,7 @@
(defwidget workspace [monitor n]
(button :visible {jq(workspaces, '.["${n}"] != null')}
:class 'workspace ${workspaces[n].active && monitor == workspaces[n].monitor ? "active" : ""}'
:onclick 'wmutils switch-workspace ${n}'
(label :text n))
)
@ -139,18 +140,17 @@
(box :orientation "v"
:valign "end"
:class "thingy"
:visible {bat_charge != ""}
:visible {EWW_BATTERY.BAT0.capacity != ""}
(label :text "BAT")
(circular-progress
:thickness 4.0
:value bat_charge
:value {EWW_BATTERY.BAT0.capacity}
:class {
bat_status == "Charging" ? "battery-gauge charging" :
bat_charge < 15 ? "battery-gauge low" :
EWW_BATTERY.BAT0.status == "Charging" ? "battery-gauge charging" :
EWW_BATTERY.BAT0.capacity < 15 ? "battery-gauge low" :
"battery-gauge"
}
)
;(label :text "${bat_charge}%")
))
(defwidget color_scheme []
@ -230,12 +230,15 @@
(defpoll workspaces :interval "1s" "wmutils workspaces")
(defpoll volume_out :interval "1s" "pamixer --get-volume")
(defpoll is_muted :interval "1s" "pamixer --get-mute")
(defpoll vpn_status :interval "1s" "mullvad-status")
(defpoll current_minute :interval "1s" "date +%M")
(defpoll current_hour :interval "1s" "date +%H")
(defpoll current_day :interval "60s" "date +%d")
(defpoll current_month :interval "60s" "date +%b")
(defpoll bat_charge :interval "15s" "cat /sys/class/power_supply/BAT0/capacity")
(defpoll bat_status :interval "15s" "cat /sys/class/power_supply/BAT0/status")
(defpoll current_temp :interval "5s" "cat /sys/class/thermal/thermal_zone*/temp")
(defpoll color_scheme :interval "5s" "get-color-scheme")
{% if disablemullvad %}
(defvar vpn_status "{'icon': '-', 'class': 'disconnected'}" )
{% else %}
(defpoll vpn_status :interval "1s" "mullvad-status")
{% end %}

View File

@ -25,9 +25,9 @@ require('fns')
require('keys')
require('theme')
require('statusline')
--require('debugger') -- TODO:
local lspconfig = require("lspconfig")
local rust_tools = require("rust-tools")
-- Mason Setup
require("mason").setup({
@ -38,31 +38,20 @@ require("mason").setup({
package_uninstalled = "",
},
},
ensure_installed = { "pylsp", "rust_analyzer", "eslint", "gopls", "wgsl_analyzer" },
ensure_installed = { "pylsp", "eslint", "gopls", "wgsl_analyzer" },
})
require("mason-lspconfig").setup_handlers {
-- rust_analyzer is managed by rustaceanvim
['rust_analyzer'] = function() end
}
require("mason-lspconfig").setup()
lspconfig.pylsp.setup {}
lspconfig.rust_analyzer.setup {}
lspconfig.eslint.setup {}
lspconfig.gopls.setup {}
lspconfig.wgsl_analyzer.setup {}
require("todo-comments").setup()
rust_tools.setup({
server = {
on_attach = function(_, bufnr)
-- Hover actions
vim.keymap.set("n", "<C-space>", rust_tools.hover_actions.hover_actions, { buffer = bufnr })
-- Code action groups
vim.keymap.set("n", "<leader>a", rust_tools.code_action_group.code_action_group, { desc = "Code actions", buffer = bufnr })
end,
settings = {
["rust-analyzer"] = {},
}
},
})
-- Format file on save
vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]]

View File

@ -0,0 +1,5 @@
{% if light %}
vim.o.background = "light"
{% else %}
vim.o.background = "dark"
{% end %}

View File

@ -0,0 +1,176 @@
local dap = require('dap')
local codelldb_bin = "/usr/bin/codelldb"
-- Rust, C++, C
dap.adapters.codelldb = {
type = 'server',
port = "${port}",
executable = {
command = codelldb_bin,
args = {"--port", "${port}"},
}
}
local function get_default_rust_program_path()
local workspace = vim.fn.getcwd()
local program_name = vim.fn.fnamemodify(workspace, ":t")
return workspace .. '/target/debug/' .. program_name
end
dap.configurations.cpp = {
{
port = 1234,
host = '127.0.0.1',
name = "Attach to name",
type = "codelldb",
request = "attach",
pid = function()
-- Lets user enter the name of a running process instead of looking up the pid themselves
local name = vim.fn.input('Enter pidof name: ')
local handle = io.popen("pidof " .. name)
local pid = handle:read("*a")
handle:close()
-- Trim the result
pid = pid:match( "^%s*(.-)%s*$" )
return pid
end,
stopOnEntry = true,
},
{
port = 1234,
host = '127.0.0.1',
name = "Attach to PID",
type = "codelldb",
request = "attach",
pid = function()
return tonumber(vim.fn.input('Enter PID: '))
end,
stopOnEntry = true,
},
{
port = 1234,
host = '127.0.0.1',
name = "Manually launch file",
type = "codelldb",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = true,
},
{
-- To debug programs that need to run as root you can run a remote lldb-server as root
-- sudo lldb-server platform --server --listen '*:1234'
name = "Remote attach to name",
type = "codelldb",
request = "attach",
pid = function()
-- Lets user enter the name of a running process instead of looking up the pid themselves
local name = vim.fn.input('Enter pidof name: ')
local handle = io.popen("pidof " .. name)
local pid = handle:read("*a")
handle:close()
-- Trim the result
pid = pid:match( "^%s*(.-)%s*$" )
return pid
end,
initCommands = {
"platform select remote-linux",
"platform connect connect://127.0.0.1:1234",
"settings set target.inherit-env false",
},
},
{
-- To debug programs that need to run as root you can run a remote lldb-server as root
-- sudo lldb-server platform --server --listen '*:1234'
name = "Remote launch",
type = "codelldb",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
initCommands = {
"platform select remote-linux",
"platform connect connect://127.0.0.1:1234",
"settings set target.inherit-env false",
},
},
}
dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp
-- Insert this config as a rust specific one before the C++ configs
table.insert(dap.configurations.rust, 1, {
port = 1234,
host = '127.0.0.1',
name = "Launch Default Rust Program",
type = "codelldb",
request = "launch",
program = get_default_rust_program_path,
cwd = '${workspaceFolder}',
stopOnEntry = true,
})
-- Python
--dap.adapters.python = function(cb, config)
-- if config.request == 'attach' then
-- ---@diagnostic disable-next-line: undefined-field
-- local port = (config.connect or config).port
-- ---@diagnostic disable-next-line: undefined-field
-- local host = (config.connect or config).host or '127.0.0.1'
-- cb({
-- type = 'server',
-- port = assert(port, '`connect.port` is required for a python `attach` configuration'),
-- host = host,
-- options = {
-- source_filetype = 'python',
-- },
-- })
-- else
-- local home = os.getenv("HOME")
-- cb({
-- type = 'executable',
-- -- You need to install debugpy in $HOME/.virtualenvs/
-- -- Like this:
-- -- $ mkdir .virtualenvs
-- -- $ cd .virtualenvs
-- -- $ python -m venv debugpy
-- -- $ debugpy/bin/python -m pip install debugpy
-- command = home .. '/.virtualenvs/debugpy/bin/python',
-- args = { '-m', 'debugpy.adapter' },
-- options = {
-- source_filetype = 'python',
-- },
-- })
-- end
--end
--dap.configurations.python = {
-- {
-- -- The first three options are required by nvim-dap
-- type = 'python'; -- the type here established the link to the adapter definition: `dap.adapters.python`
-- request = 'launch';
-- name = "Launch file";
--
-- -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
--
-- program = "${file}"; -- This configuration will launch the current file if used.
-- pythonPath = function()
-- -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself.
-- -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within.
-- -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable.
-- local cwd = vim.fn.getcwd()
-- if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then
-- return cwd .. '/venv/bin/python'
-- elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then
-- return cwd .. '/.venv/bin/python'
-- else
-- return '/usr/bin/python'
-- end
-- end;
-- },
--}

View File

@ -36,11 +36,33 @@ vim.api.nvim_create_autocmd('LspAttach', {
end, { desc = "List workspace folders", buffer = ev.buf })
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { desc = "Rename symbol", buffer = ev.buf })
vim.keymap.set('n', "<leader>a", function()
vim.cmd.RustLsp('codeAction') -- supports rust-analyzer's grouping
-- or vim.lsp.buf.codeAction() if you don't want grouping.
end,
{ silent = true, buffer = ev.buf })
--vim.keymap.set({ 'n', 'v' }, '<leader>la', vim.lsp.buf.code_action, { desc = "Code actions", buffer = ev.buf }) -- TODO: figure out how to fall back to this option lang isnt rust
wk.add({
{ "<leader>l", desc = "Language server stuff" },
{ "<leader>w", desc = "Workspace stuff" },
})
--vim.keymap.set({ 'n', 'v' }, '<leader>la', vim.lsp.buf.code_action, { desc = "Code actions", buffer = ev.buf }) -- TODO: figure out how to fall back to this option lang isnt rust
end,
})
--local rust_tools = require("rust-tools")
--rust_tools.setup({
-- server = {
-- on_attach = function(_, bufnr)
-- -- Hover actions
-- vim.keymap.set("n", "<C-space>", rust_tools.hover_actions.hover_actions, { buffer = bufnr })
-- -- Code action groups
-- vim.keymap.set("n", "<leader>a", rust_tools.code_action_group.code_action_group, { desc = "Code actions", buffer = bufnr })
-- end,
-- settings = {
-- ["rust-analyzer"] = {},
-- }
-- },
--})

View File

@ -22,12 +22,18 @@ require("lazy").setup({
-- refer to the configuration section below
}
},
{ 'rktjmp/fwatch.nvim' },
-- -- language server stuff
{'williamboman/mason.nvim' },
{'williamboman/mason-lspconfig.nvim' },
{'neovim/nvim-lspconfig' },
{'simrat39/rust-tools.nvim' },
{ 'williamboman/mason.nvim' },
{ 'williamboman/mason-lspconfig.nvim' },
{ 'neovim/nvim-lspconfig' },
{
'mrcjkb/rustaceanvim',
version = '^4',
lazy = false, -- This plugin is already lazy
},
{ 'mfussenegger/nvim-dap' },
-- -- nushell support
-- --use { 'LhKipp/nvim-nu', run = function() vim.fn[':TSInstall nu'] end} }

View File

@ -25,10 +25,9 @@ require("gruvbox").setup({
transparent_mode = false,
})
{% if light %}
vim.o.background = "light"
{% else %}
vim.o.background = "dark"
{% end %}
require('color-scheme')
local color_scheme_file = "~/.cache/dotfiles/.config/nvim/lua/color-scheme.lua"
require('fwatch').watch(color_scheme_file, "luafile " .. color_scheme_file)
vim.cmd([[colorscheme gruvbox]])

View File

@ -29,6 +29,7 @@ sudo pacman --needed -S \
luarocks \
neovim \
nerd-fonts \
niri \
noto-fonts \
noto-fonts-emoji \
noto-fonts-extra \
@ -48,11 +49,6 @@ sudo pacman --needed -S \
wl-clipboard \
zathura
# install nvim packer
git clone --depth 1 https://github.com/wbthomason/packer.nvim \
~/.local/share/nvim/site/pack/packer/start/packer.nvim \
|| true # command will fail if packer is already installed
rustup default stable
if ! command -v paru &> /dev/null; then
@ -65,8 +61,9 @@ if ! command -v paru &> /dev/null; then
makepkg -si
fi
paru -S wdisplays eww-wayland
paru -S wdisplays eww
cargo install --locked --git https://git.nubo.sh/hulthe/wmutils.git
cargo install --locked --git https://git.nubo.sh/hulthe/lockscreen-blur.git
cargo install --locked --git https://git.nubo.sh/hulthe/volume_indicator.git