Various changes to neovim, awesome

- Better handling of new terminals
- Miscellaneous neovim tweaks
This commit is contained in:
Adam Cooper 2024-04-02 08:28:14 -04:00
parent 9b360075c9
commit 1f3249a316
4 changed files with 97 additions and 72 deletions

View File

@ -7,10 +7,8 @@ run() {
fi
}
# Currently not working
# run "(pgrep alacritty && alacritty msg create-window --title bottom -e btm --battery || alacritty --title bottom -e btm --battery)"
/usr/sbin/alacritty --title bottom --command btm --battery &
/usr/sbin/alacritty --title awesome-startup &
/usr/sbin/alacritty --socket "$XDG_RUNTIME_DIR/alacritty-main.sock" --title awesome-startup &
/usr/sbin/alacritty --title bottom --option font.size=6.5 --command btm --battery &
run "cbatticon"
run "blueman-applet"

View File

@ -54,9 +54,9 @@ beautiful.init(gears.filesystem.get_configuration_dir() .. "mytheme.lua")
terminal = function()
local is_running = os.execute("pgrep alacritty")
if is_running == nil then
return "/usr/sbin/alacritty"
return "/usr/sbin/alacritty --socket /run/user/1000/alacritty-main.sock"
else
return "/usr/sbin/alacritty msg create-window"
return "/usr/sbin/alacritty msg --socket /run/user/1000/alacritty-main.sock create-window"
end
end
editor = os.getenv("EDITOR") or "nano"

View File

@ -1,7 +1,8 @@
-- Minimal init.lua to test out nvim-dap (for Node.js, really NestJS)
local js_based_languages = { "javascript", "typescript" }
-- lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
@ -14,12 +15,15 @@ if not vim.loop.fs_stat(lazypath) then
end
vim.opt.rtp:prepend(lazypath)
local js_based_languages = { "javascript", "typescript" }
require("lazy").setup({
{ "rcarriga/nvim-dap-ui", requires = "mfussenegger/nvim-dap" },
{
"rcarriga/nvim-dap-ui",
event = "VeryLazy",
requires = "mfussenegger/nvim-dap"
},
{
"mfussenegger/nvim-dap",
event = "VeryLazy",
config = function()
local dap = require("dap")
@ -28,11 +32,11 @@ require("lazy").setup({
--[[
for name, sign in pairs(Config.icons.dap) do
sign = type(sign) == "table" and sign or { sign }
vim.fn.sign_define(
"Dap" .. name,
{ text = sign[1], texthl = sign[2] or "DiagnosticInfo", linehl = sign[3], numhl = sign[3] }
)
sign = type(sign) == "table" and sign or { sign }
vim.fn.sign_define(
"Dap" .. name,
{ text = sign[1], texthl = sign[2] or "DiagnosticInfo", linehl = sign[3], numhl = sign[3] }
)
end
--]]
@ -91,20 +95,6 @@ require("lazy").setup({
end
end,
keys = {
{
"<leader>dO",
function()
require("dap").step_out()
end,
desc = "Step Out",
},
{
"<leader>do",
function()
require("dap").step_over()
end,
desc = "Step Over",
},
{
"<leader>da",
function()
@ -118,7 +108,7 @@ require("lazy").setup({
end
require("dap").continue()
end,
desc = "Run with Args",
desc = "DAP: Run with Args",
},
},
dependencies = {
@ -170,9 +160,9 @@ require("lazy").setup({
},
},
},
"leoluz/nvim-dap-go",
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
{ "leoluz/nvim-dap-go", event = "VeryLazy" },
{ "williamboman/mason.nvim", event = "VeryLazy" },
{ "williamboman/mason-lspconfig.nvim", event = "VeryLazy" },
})
--[[ mason
@ -183,43 +173,21 @@ integration.
require('mason').setup()
require('mason-lspconfig').setup()
-- setup adapters
--[[
require('dap-vscode-js').setup({
node_path = 'node',
debugger_path = vim.fn.stdpath('data') .. '/mason/packages/js-debug-adapter',
debugger_cmd = { 'js-debug-adapter' },
adapters = { 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost' },
log_file_path = vim.fn.stdpath('cache') .. '/dap_vscode_js.log',
log_file_level = 1,
log_console_level = vim.log.levels.TRACE,
})
local dap = require('dap')
for _, language in ipairs({ "typescript", "javascript" }) do
dap.configurations[language] = {
{
type = "pwa-node",
request = "launch",
name = "Launch file",
program = "${file}",
cwd = "${workspaceFolder}",
},
{
type = "pwa-node",
request = "launch",
name = "Debug Nest Framework",
args = { "${workspaceFolder}/src/main.ts" },
runtimeArgs = { "--nolazy", "-r", "ts-node/register" },
sourceMaps = true,
cwd = "${workspaceRoot}",
protocol = "inspector",
}
}
end
--]]
require('dap-go').setup()
require('dapui').setup()
local dap, dapui = require("dap"), require("dapui")
dapui.setup()
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open()
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close()
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
end
-- Switch syntax highlighting on
vim.cmd("syntax enable")

View File

@ -48,6 +48,7 @@ vim.keymap.set("n", "<c-j>", "<c-w>j", { noremap = true, desc = 'Go to window be
vim.keymap.set("n", "<c-k>", "<c-w>k", { noremap = true, desc = 'Go to window above' })
vim.keymap.set("n", "<c-h>", "<c-w>h", { noremap = true, desc = 'Go to window to the left' })
-- N.B. This conflicts with the NetRW directory refresh command. Use the alternative `:e .`.
-- TODO: This seems not to work for netrw.
vim.keymap.set("n", "<c-l>", "<c-w>l", { noremap = true, desc = 'Go to window to the right' })
vim.keymap.set("t", "<c-j>", "<c-\\><c-n><c-w>j", { noremap = true, desc = 'Go to window below' })
@ -67,6 +68,16 @@ vim.keymap.set(
{ desc = "Revert window layout" }
)
local terminalgroup = vim.api.nvim_create_augroup("TerminalGroup", { clear = true })
vim.api.nvim_create_autocmd(
{"TermOpen", "TermEnter"},
{
group = terminalgroup,
pattern = "*",
command = "set nonumber"
}
)
-- lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
@ -128,10 +139,10 @@ require("lazy").setup({
opts = {},
config = function(_, opts) require'lsp_signature'.setup(opts) end
},
{ "folke/neodev.nvim", opts = {} },
{
"rcarriga/nvim-dap-ui",
event = "VeryLazy",
requires = "mfussenegger/nvim-dap"
dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
},
{
"mfussenegger/nvim-dap",
@ -484,6 +495,14 @@ lspconfig.rust_analyzer.setup {
},
}
-- Enable (broadcasting) snippet capability for completion
local capabilities_html = vim.lsp.protocol.make_client_capabilities()
capabilities_html.textDocument.completion.completionItem.snippetSupport = true
require'lspconfig'.html.setup {
capabilities = capabilities_html,
}
-- Global mappings : Diagnostics
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, { desc = 'Diagnostic: open float' })
@ -668,6 +687,46 @@ dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
end
-- Handlebars: One way to get syntax highlighting in Handlebars files
--[[
local syntax_highlighting_tweaks = vim.api.nvim_create_augroup("SyntaxHighlightingTweaks", { clear = true })
vim.api.nvim_create_autocmd(
{ "BufRead", "BufNewFile" },
{
group = syntax_highlighting_tweaks,
pattern = "*.hbs",
command = "set filetype=html"
}
)
--]]
-- Treesitter
require('nvim-treesitter.configs').setup({
modules = {},
highlight = {
enable = true,
loaded = true,
module_path = "nvim-treesitter.highlight",
additional_vim_regex_highlighting = true,
},
indent = {
enable = true,
module_path = "nvim-treesitter.indent",
},
ensure_installed = { "bash", "comment", "html", "javascript", "json", "lua", "typescript", "yaml" },
sync_install = false,
auto_install = false,
ignore_install = {},
})
vim.treesitter.language.register("html", "handlebars")
-- Neodev
require("neodev").setup({
library = { plugins = { "nvim-dap-ui" }, types = true },
...
})
-- Tweak GitSigns blame color
-- This differentiates the cursorline from the git blame text
vim.cmd("highlight GitSignsCurrentLineBlame gui=bold guifg=#339944")