Updated scripts

This commit is contained in:
Christoffer Martinsson 2025-05-14 07:03:31 +02:00
parent b3497e71e7
commit b40d6c8ea4
6 changed files with 725 additions and 696 deletions

View File

@ -1,7 +1,7 @@
# linuxbox
## WSL Ubuntu
Script and dotfiles for setting up complete dev environment based on Ubuntu 22.04 (and 24.04)
Script and dotfiles for setting up complete dev environment based on Ubuntu 22.04 (and 24.04)
If Win11 is used as main terminal/client then pleas configure following:
* Windows Terminal (Preview)

View File

@ -5,7 +5,8 @@ normal={family="RobotoMonoNerdFont", style="Regular"}
[colors.primary]
foreground="#c6c6c6"
background="#262626"
# background="#262626"
background="#000000"
[colors.normal]
black="#000000"
@ -36,3 +37,6 @@ padding={x=2}
[env]
TERM="xterm-256color"
[mouse]
hide_when_typing = true

View File

@ -327,6 +327,9 @@ windowrulev2 = workspace emptyn, initialTitle:^(FreeCAD.*)$
# Steam
windowrulev2 = workspace emptyn, initialTitle:^(.*Steam.*)$
# RSI
windowrulev2 = workspace emptyn, initialTitle:^(.*RSI.*)$
# Ignore maximize requests from apps. You'll probably like this.
windowrulev2 = suppressevent maximize, class:.*

View File

@ -1,7 +1,10 @@
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- vim.g.loaded_netrw = 1
-- vim.g.loaded_netrwPlugin = 1
-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = true
-- Set highlight on search
vim.o.hlsearch = false
@ -10,7 +13,7 @@ vim.o.hlsearch = false
vim.wo.number = true
-- Enable mouse mode
vim.o.mouse = 'a'
vim.o.mouse = "a"
-- Enable break indent
vim.o.breakindent = true
@ -23,10 +26,10 @@ vim.o.ignorecase = true
vim.o.smartcase = true
-- Keep signcolumn on by default
vim.wo.signcolumn = 'yes'
vim.wo.signcolumn = "yes"
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect,noinsert'
-- vim.o.completeopt = "menuone,noselect,noinsert"
-- Use terminal colors
vim.o.termguicolors = true
@ -38,13 +41,25 @@ vim.o.tabstop = 4
vim.o.expandtab = true
vim.o.softtabstop = 4
-- Preview substitutions live, as you type!
vim.o.inccommand = "split"
-- Show cursor line
vim.o.cursorline = true
vim.o.showmatch = true
-- Decrease update time
vim.o.updatetime = 250
-- Decrease mapped sequence wait time
vim.o.timeoutlen = 300
vim.o.pumheight = 10
vim.o.relativenumber = true
vim.o.scrolloff = 8
-- Don't show the mode, since it's already in the status line
vim.o.showmode = false
vim.o.showtabline = 0
@ -55,6 +70,27 @@ vim.o.foldmethod = "expr"
vim.o.foldexpr = "nvim_treesitter#foldexpr()"
vim.o.foldlevelstart = 99
vim.schedule(function()
vim.o.clipboard = "unnamedplus"
end)
vim.o.autoread = true
-------------------------------------------------------------------
-- Autocommands
-------------------------------------------------------------------
-- Autoset current working directory based on closest git repo
vim.api.nvim_create_autocmd("BufEnter", {
callback = function()
local git_dir = vim.fn.finddir(".git", ".;")
if git_dir ~= "" then
local git_root = vim.fn.fnamemodify(git_dir, ":h")
vim.cmd("lcd " .. git_root)
end
end,
})
-- show cursor line only in active window
local cursorLineGrp = vim.api.nvim_create_augroup("CursorLine", { clear = true })
vim.api.nvim_create_autocmd(
@ -74,31 +110,30 @@ vim.api.nvim_create_autocmd(
{ pattern = "*", command = "set nocursorline", group = cursorLineGrp }
)
-- Auto format on save
vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]]
-- Auto update on file changes
vim.o.autoread = true
vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "CursorHoldI", "FocusGained" }, {
command = "if mode() != 'c' | checktime | endif",
pattern = { "*" },
})
vim.api.nvim_create_autocmd({ "FileChangedShellPost" },
{ command = 'echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None', pattern = { "*" }, })
vim.api.nvim_create_autocmd(
{ "FileChangedShellPost" },
{ command = 'echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None', pattern = { "*" } }
)
-------------------------------------------------------------------
-- Plugin management
-------------------------------------------------------------------
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system {
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
}
})
end
vim.opt.rtp:prepend(lazypath)
@ -106,7 +141,7 @@ vim.opt.rtp:prepend(lazypath)
-------------------------------------------------------------------
-- Plugin installation
-------------------------------------------------------------------
require('lazy').setup({
require("lazy").setup({
-- Color scheme ------------------------------------------
{
@ -114,83 +149,314 @@ require('lazy').setup({
lazy = false,
priority = 1000,
config = function()
vim.cmd.colorscheme 'nightly_cm'
vim.cmd.colorscheme("nightly_cm")
end,
},
-- LSP ----------------------------------------------------
{
"neovim/nvim-lspconfig"
"folke/lazydev.nvim",
ft = "lua", -- only load on lua files
opts = {
library = {
-- See the configuration section for more details
-- Load luvit types when the `vim.uv` word is found
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
},
{
-- Main LSP Configuration
"neovim/nvim-lspconfig",
dependencies = {
{ "j-hui/fidget.nvim", opts = {} },
},
config = function()
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
callback = function(event)
-- In this case, we create a function that lets us more easily define mappings specific
-- for LSP related items. It sets the mode, buffer and description for us each time.
local map = function(keys, func, desc, mode)
mode = mode or "n"
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
end
-- Rename the variable under your cursor.
-- Most Language Servers support renaming across files, etc.
map("grn", vim.lsp.buf.rename, "[R]e[n]ame")
-- Execute a code action, usually your cursor needs to be on top of an error
-- or a suggestion from your LSP for this to activate.
map("gra", vim.lsp.buf.code_action, "[G]oto Code [A]ction", { "n", "x" })
-- Find references for the word under your cursor.
map("grr", require("fzf-lua").lsp_references, "[G]oto [R]eferences")
-- Jump to the implementation of the word under your cursor.
-- Useful when your language has ways of declaring types without an actual implementation.
map("gri", require("fzf-lua").lsp_implementations, "[G]oto [I]mplementation")
-- Jump to the definition of the word under your cursor.
-- This is where a variable was first declared, or where a function is defined, etc.
-- To jump back, press <C-t>.
map("grd", require("fzf-lua").lsp_definitions, "[G]oto [D]efinition")
-- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header.
map("grD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
-- Fuzzy find all the symbols in your current document.
-- Symbols are things like variables, functions, types, etc.
map("gO", require("fzf-lua").lsp_document_symbols, "Open Document Symbols")
-- Fuzzy find all the symbols in your current workspace.
-- Similar to document symbols, except searches over your entire project.
map("gW", require("fzf-lua").lsp_live_workspace_symbols, "Open Workspace Symbols")
-- Jump to the type of the word under your cursor.
-- Useful when you're not sure what type a variable is and you want to see
-- the definition of its *type*, not where it was *defined*.
map("grt", require("fzf-lua").lsp_typedefs, "[G]oto [T]ype Definition")
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
---@param client vim.lsp.Client
---@param method vim.lsp.protocol.Method
---@param bufnr? integer some lsp support methods only in specific files
---@return boolean
local function client_supports_method(client, method, bufnr)
if vim.fn.has("nvim-0.11") == 1 then
return client:supports_method(method, bufnr)
else
return client.supports_method(method, { bufnr = bufnr })
end
end
-- The following two autocommands are used to highlight references of the
-- word under your cursor when your cursor rests there for a little while.
-- See `:help CursorHold` for information about when this is executed
--
-- When you move your cursor, the highlights will be cleared (the second autocommand).
local client = vim.lsp.get_client_by_id(event.data.client_id)
-- if
-- client
-- and client_supports_method(
-- client,
-- vim.lsp.protocol.Methods.textDocument_documentHighlight,
-- event.buf
-- )
-- then
-- local highlight_augroup =
-- vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false })
-- vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
-- buffer = event.buf,
-- group = highlight_augroup,
-- callback = vim.lsp.buf.document_highlight,
-- })
--
-- vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
-- buffer = event.buf,
-- group = highlight_augroup,
-- callback = vim.lsp.buf.clear_references,
-- })
--
-- vim.api.nvim_create_autocmd("LspDetach", {
-- group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }),
-- callback = function(event2)
-- vim.lsp.buf.clear_references()
-- vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf })
-- end,
-- })
-- end
-- The following code creates a keymap to toggle inlay hints in your
-- code, if the language server you are using supports them
--
-- This may be unwanted, since they displace some of your code
if
client
and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf)
then
map("<leader>th", function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }))
end, "[T]oggle Inlay [H]ints")
end
end,
})
-- Diagnostic Config
-- See :help vim.diagnostic.Opts
vim.diagnostic.config({
severity_sort = true,
float = { border = "rounded", source = "if_many" },
underline = { severity = vim.diagnostic.severity.ERROR },
signs = vim.g.have_nerd_font and {
text = {
[vim.diagnostic.severity.ERROR] = "󰅚 ",
[vim.diagnostic.severity.WARN] = "󰀪 ",
[vim.diagnostic.severity.INFO] = "󰋽 ",
[vim.diagnostic.severity.HINT] = "󰌶 ",
},
} or {},
virtual_text = {
source = "if_many",
spacing = 2,
format = function(diagnostic)
local diagnostic_message = {
[vim.diagnostic.severity.ERROR] = diagnostic.message,
[vim.diagnostic.severity.WARN] = diagnostic.message,
[vim.diagnostic.severity.INFO] = diagnostic.message,
[vim.diagnostic.severity.HINT] = diagnostic.message,
}
return diagnostic_message[diagnostic.severity]
end,
},
})
local capabilities = require("blink.cmp").get_lsp_capabilities()
local servers = {
clangd = {},
html = {},
yamlls = {},
bashls = {},
pyright = {},
marksman = {},
rust_analyzer = {},
lua_ls = {
settings = {
Lua = {
completion = {
callSnippet = "Replace",
},
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } },
},
},
},
}
for server_name, server in pairs(servers) do
server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {})
require("lspconfig")[server_name].setup(server)
end
end,
},
{
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
lua = { "stylua" },
-- Conform will run multiple formatters sequentially
python = { "black" },
-- You can customize some of the format options for the filetype (:help conform.format)
rust = { "rustfmt", lsp_format = "fallback" },
-- Conform will run the first available formatter
javascript = { "prettier", stop_after_first = true },
},
format_on_save = {
-- These options will be passed to conform.format()
timeout_ms = 500,
lsp_format = "fallback",
},
},
},
{ -- Autocompletion
"saghen/blink.cmp",
event = "VimEnter",
version = "1.*",
dependencies = {
-- Snippet Engine
{
"L3MON4D3/LuaSnip",
-- follow latest release.
version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
-- install jsregexp (optional!).
build = "make install_jsregexp"
version = "2.*",
build = (function()
-- Build Step is needed for regex support in snippets.
-- This step is not supported in many windows environments.
-- Remove the below condition to re-enable on windows.
if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then
return
end
return "make install_jsregexp"
end)(),
dependencies = {},
opts = {},
},
"folke/lazydev.nvim",
},
--- @module 'blink.cmp'
--- @type blink.cmp.Config
opts = {
keymap = {
preset = "default",
},
{
'hrsh7th/nvim-cmp',
dependencies = {
'saadparwaiz1/cmp_luasnip',
'hrsh7th/cmp-nvim-lsp',
'rafamadriz/friendly-snippets',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline',
appearance = {
nerd_font_variant = "mono",
},
completion = {
-- By default, you may press `<c-space>` to show the documentation.
-- Optionally, set `auto_show = true` to show the documentation after a delay.
documentation = { auto_show = false, auto_show_delay_ms = 500 },
},
sources = {
default = { "lsp", "buffer", "path", "snippets", "lazydev" },
providers = {
lazydev = { module = "lazydev.integrations.blink", score_offset = 100 },
},
},
{
"ahmedkhalf/project.nvim",
config = function()
require("project_nvim").setup {
sync_root_with_cwd = true,
respect_buf_cwd = true,
update_focused_file = {
snippets = { preset = "luasnip" },
fuzzy = { implementation = "prefer_rust_with_warning" },
-- Shows a signature help window while you type arguments for a function
signature = { enabled = true },
},
},
{ -- Highlight, edit, and navigate code
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
main = "nvim-treesitter.configs", -- Sets main module to use for opts
opts = {
ensure_installed = {
"bash",
"c",
"diff",
"html",
"lua",
"luadoc",
"markdown",
"markdown_inline",
"query",
"vim",
"vimdoc",
"rust",
"python",
},
auto_install = true,
highlight = {
enable = true,
update_root = true
-- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
-- If you are experiencing weird indenting issues, add the language to
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
additional_vim_regex_highlighting = { "ruby" },
},
}
end
indent = { enable = true, disable = { "ruby" } },
},
{
-- Highlight, edit, and navigate code
'nvim-treesitter/nvim-treesitter',
dependencies = {
'nvim-treesitter/nvim-treesitter-textobjects',
},
build = ':TSUpdate',
},
{
"simrat39/rust-tools.nvim",
},
{
"ray-x/lsp_signature.nvim",
config = function()
require "lsp_signature".setup {
bind = true, -- This is mandatory, otherwise border config won't get registered.
handler_opts = {
border = "solid"
}
}
end
},
-- File explorer -------------------------------------------
{
"ibhagwan/fzf-lua",
-- optional for icon support
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
-- calling `setup` is optional for customization
require("fzf-lua").setup({})
end
opts = {},
},
{
@ -201,8 +467,7 @@ require('lazy').setup({
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
},
config = function()
require("neo-tree").setup {
opts = {
close_if_last_window = true,
popup_border_style = "rounded",
enable_git_status = true,
@ -212,7 +477,7 @@ require('lazy').setup({
sort_function = nil, -- use a custom function for sorting files and directories in the tree
default_component_configs = {
container = {
enable_character_fade = true
enable_character_fade = true,
},
indent = {
indent_size = 2,
@ -231,6 +496,7 @@ require('lazy').setup({
icon = {
folder_closed = "",
folder_open = "",
folder_empty_open = "",
folder_empty = "󰜌",
provider = function(icon, node, state) -- default icon provider utilizes nvim-web-devicons if available
if node.type == "file" or node.type == "terminal" then
@ -246,7 +512,7 @@ require('lazy').setup({
-- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there
-- then these will never be used.
default = "*",
highlight = "NeoTreeFileIcon"
highlight = "NeoTreeFileIcon",
},
modified = {
symbol = "[+]",
@ -270,28 +536,28 @@ require('lazy').setup({
unstaged = "󰄱",
staged = "",
conflict = "",
}
},
-- If you don't want to use these columns, you can set `enabled = false` for each of them individually
file_size = {
enabled = true,
required_width = 64, -- min width of window required to show this column
},
type = {
enabled = true,
required_width = 122, -- min width of window required to show this column
},
last_modified = {
enabled = true,
required_width = 88, -- min width of window required to show this column
},
created = {
enabled = true,
required_width = 110, -- min width of window required to show this column
},
symlink_target = {
enabled = false,
},
-- -- If you don't want to use these columns, you can set `enabled = false` for each of them individually
-- file_size = {
-- enabled = true,
-- required_width = 64, -- min width of window required to show this column
-- },
-- type = {
-- enabled = true,
-- required_width = 122, -- min width of window required to show this column
-- },
-- last_modified = {
-- enabled = true,
-- required_width = 88, -- min width of window required to show this column
-- },
-- created = {
-- enabled = true,
-- required_width = 110, -- min width of window required to show this column
-- },
-- symlink_target = {
-- enabled = false,
-- },
},
commands = {
parent_or_close = function(state)
@ -360,40 +626,38 @@ require('lazy').setup({
Y = "copy_selector",
},
},
}
end,
},
},
-- GUI ------------------------------------------------------
{
'mrjones2014/smart-splits.nvim',
"mrjones2014/smart-splits.nvim",
opts = {
at_edge = 'stop',
}
at_edge = "stop",
},
},
{
-- Set lualine as statusline
'nvim-lualine/lualine.nvim',
"nvim-lualine/lualine.nvim",
opts = {
options = {
icons_enabled = true,
theme = 'nightly_cm',
component_separators = '',
section_separators = '',
theme = "nightly_cm",
component_separators = "",
section_separators = "",
globalstatus = true,
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'branch', 'diff' },
lualine_c = { 'diagnostics', 'filename' },
lualine_a = { "mode" },
lualine_b = { "branch", "diff" },
lualine_c = { "diagnostics", "filename" },
lualine_x = {
{
-- Lsp server name .
function()
local msg = ''
local msg = ""
local clients = vim.lsp.get_clients({ bufnr = 0 })
if next(clients) == nil then
return msg
@ -401,23 +665,22 @@ require('lazy').setup({
for _, client in ipairs(clients) do
msg = msg .. client.name .. ", "
end
if msg == '' then
if msg == "" then
return msg
end
return msg:sub(1, -3)
end,
color = { fg = '#c6c6c6' },
color = { fg = "#c6c6c6" },
},
},
lualine_y = { 'filetype' },
lualine_z = { 'progress' }
lualine_y = { "filetype" },
lualine_z = { "progress" },
},
},
},
{
-- Adds git releated signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
"lewis6991/gitsigns.nvim",
opts = {
signs = {
add = { text = "" },
@ -429,51 +692,28 @@ require('lazy').setup({
},
preview_config = {
-- Options passed to nvim_open_win
border = 'solid',
style = 'minimal',
relative = 'cursor',
border = "solid",
style = "minimal",
relative = "cursor",
row = 0,
col = 1
col = 1,
},
on_attach = function(bufnr)
vim.keymap.set('n', '<leader>gp', require('gitsigns').prev_hunk,
{ buffer = bufnr, desc = '[G]o to [P]revious Hunk' })
vim.keymap.set('n', '<leader>gn', require('gitsigns').next_hunk,
{ buffer = bufnr, desc = '[G]o to [N]ext Hunk' })
vim.keymap.set('n', '<leader>ph', require('gitsigns').preview_hunk,
{ buffer = bufnr, desc = '[P]review [H]unk' })
end,
},
},
{
-- Add indentation guides even on blank lines
'lukas-reineke/indent-blankline.nvim',
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
opts = {
scope = {
show_end = false,
}
}
},
},
},
{
"norcalli/nvim-colorizer.lua",
config = function()
require("colorizer").setup()
end,
},
{
"folke/lazydev.nvim",
ft = "lua", -- only load on lua files
opts = {
library = {
-- See the configuration section for more details
-- Load luvit types when the `vim.uv` word is found
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
opts = {},
},
{
@ -483,285 +723,78 @@ require('lazy').setup({
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
opts = {},
},
{
'MeanderingProgrammer/render-markdown.nvim',
dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.nvim' }, -- if you use the mini.nvim suite
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons
---@module 'render-markdown'
---@type render.md.UserConfig
opts = {
code = {
enabled = true,
sign = true,
style = 'full',
position = 'left',
language_pad = 0,
language_name = true,
disable_background = { 'diff' },
width = 'full',
left_margin = 0,
left_pad = 0,
right_pad = 0,
min_width = 0,
border = 'thick',
above = '',
below = '',
highlight = 'RenderMarkdownCode',
highlight_inline = 'RenderMarkdownCodeInline',
highlight_language = nil,
},
},
"stevearc/dressing.nvim",
opts = {},
},
-- Utils ---------------------------------------------------
{
"max397574/better-escape.nvim",
opts = { timeout = 300 }
opts = { timeout = 300 },
},
{ 'numToStr/Comment.nvim', opts = {} },
{ "numToStr/Comment.nvim", opts = {} },
{
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
}
opts = {},
},
{
'phaazon/hop.nvim',
branch = 'v2', -- optional but strongly recommended
config = function()
require 'hop'.setup { keys = 'etovxqpdygfblzhckisuran' }
end
"phaazon/hop.nvim",
branch = "v2", -- optional but strongly recommended
opts = {
keys = "etovxqpdygfblzhckisuran",
},
},
{
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
opts = {
opts = {},
},
},
}, {})
-------------------------------------------------------------------
-- LSP Configurations
-------------------------------------------------------------------
local lspconfig = require('lspconfig')
-- Lua
lspconfig.lua_ls.setup {}
-- Rust
lspconfig.rust_analyzer.setup {
-- Server-specific settings. See `:help lspconfig-setup`
settings = {
['rust-analyzer'] = {},
},
}
-- [[ Configure nvim-cmp ]]
local cmp = require 'cmp'
local luasnip = require 'luasnip'
require('luasnip.loaders.from_vscode').lazy_load()
luasnip.config.setup {}
local cmp_opts = {
border = "solid",
winhighlight = 'Normal:Pmenu,FloatBorder:FloatBorder,Search:NONE,CursorLine:PmenuSel',
}
local has_words_before = function()
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then return false end
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_text(0, line - 1, 0, line - 1, col, {})[1]:match("^%s*$") == nil
end
cmp.setup {
preselect = cmp.PreselectMode.None,
view = {
entries = "custom" -- can be "custom", "wildmenu" or "native"
},
completion = {
completion = { completeopt = 'menu,menuone,noinsert,noselect' },
},
window = {
completion = cmp.config.window.bordered(cmp_opts),
documentation = cmp.config.window.bordered(cmp_opts),
},
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
duplicates = {
nvim_lsp = 1,
luasnip = 1,
cmp_tabnine = 1,
buffer = 1,
path = 1,
},
mapping = cmp.mapping.preset.insert {
['<C-Space>'] = cmp.mapping.complete {},
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() and has_words_before() then
cmp.select_next_item()
elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
},
sources = {
-- { name = 'copilot', priority = 2 },
{ name = 'nvim_lsp', priority = 2 },
{ name = 'buffer', priority = 2 },
{ name = 'path', priority = 2 },
{ name = 'luasnip', priority = 2 },
},
}
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(),
view = {
entries = { name = 'wildmenu', separator = '|' }
},
window = {
completion = cmp.config.window.bordered(cmp_opts),
documentation = cmp.config.window.bordered(cmp_opts),
},
sources = {
{ name = 'buffer' }
}
})
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
view = {
entries = { name = 'wildmenu', separator = '|' }
},
window = {
completion = cmp.config.window.bordered(cmp_opts),
documentation = cmp.config.window.bordered(cmp_opts),
},
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- [[ Configure Treesitter ]]
require('nvim-treesitter.configs').setup {
-- Add languages to be installed here that you want installed for treesitter
auto_install = true,
highlight = { enable = true },
indent = { enable = true },
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<c-space>',
node_incremental = '<c-space>',
scope_incremental = '<c-s>',
node_decremental = '<M-space>',
},
},
textobjects = {
select = {
enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = {
-- You can use the capture groups defined in textobjects.scm
['aa'] = '@parameter.outer',
['ia'] = '@parameter.inner',
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@class.outer',
['ic'] = '@class.inner',
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
[']m'] = '@function.outer',
[']]'] = '@class.outer',
},
goto_previous_start = {
['[m'] = '@function.outer',
['[['] = '@class.outer',
},
goto_next_end = {
[']M'] = '@function.outer',
[']['] = '@class.outer',
},
goto_previous_end = {
['[M'] = '@function.outer',
['[]'] = '@class.outer',
},
},
swap = {
enable = true,
swap_next = {
['<leader>a'] = '@parameter.inner',
},
swap_previous = {
['<leader>A'] = '@parameter.inner',
},
},
},
}
-- resizing splits
vim.keymap.set({ 'n', 't' }, '<A-h>', require('smart-splits').resize_left, { desc = 'Resize left' })
vim.keymap.set({ 'n', 't' }, '<A-j>', require('smart-splits').resize_down, { desc = 'Resize down' })
vim.keymap.set({ 'n', 't' }, '<A-k>', require('smart-splits').resize_up, { desc = 'Resize up' })
vim.keymap.set({ 'n', 't' }, '<A-l>', require('smart-splits').resize_right, { desc = 'Resize right' })
vim.keymap.set({ "n", "t" }, "<C-A-h>", require("smart-splits").resize_left, { desc = "Resize left" })
vim.keymap.set({ "n", "t" }, "<C-A-j>", require("smart-splits").resize_down, { desc = "Resize down" })
vim.keymap.set({ "n", "t" }, "<C-A-k>", require("smart-splits").resize_up, { desc = "Resize up" })
vim.keymap.set({ "n", "t" }, "<C-A-l>", require("smart-splits").resize_right, { desc = "Resize right" })
-- moving between splits
vim.keymap.set({ 'n', 't' }, '<C-h>', require('smart-splits').move_cursor_left, { desc = 'Move cursor left' })
vim.keymap.set({ 'n', 't' }, '<C-j>', require('smart-splits').move_cursor_down, { desc = 'Move cursor down' })
vim.keymap.set({ 'n', 't' }, '<C-k>', require('smart-splits').move_cursor_up, { desc = 'Move cursor up' })
vim.keymap.set({ 'n', 't' }, '<C-l>', require('smart-splits').move_cursor_right, { desc = 'Move cursor right' })
vim.keymap.set({ "n", "t" }, "<A-h>", require("smart-splits").move_cursor_left, { desc = "Move cursor left" })
vim.keymap.set({ "n", "t" }, "<A-j>", require("smart-splits").move_cursor_down, { desc = "Move cursor down" })
vim.keymap.set({ "n", "t" }, "<A-k>", require("smart-splits").move_cursor_up, { desc = "Move cursor up" })
vim.keymap.set({ "n", "t" }, "<A-l>", require("smart-splits").move_cursor_right, { desc = "Move cursor right" })
-- swapping buffers between windows
vim.keymap.set('n', '<leader><leader>h', require('smart-splits').swap_buf_left, { desc = 'Swap buffer left' })
vim.keymap.set('n', '<leader><leader>j', require('smart-splits').swap_buf_down, { desc = 'Swap buffer down' })
vim.keymap.set('n', '<leader><leader>k', require('smart-splits').swap_buf_up, { desc = 'Swap buffer up' })
vim.keymap.set('n', '<leader><leader>l', require('smart-splits').swap_buf_right, { desc = 'Swap buffer right' })
vim.keymap.set("n", "<leader><leader>h", require("smart-splits").swap_buf_left, { desc = "Swap buffer left" })
vim.keymap.set("n", "<leader><leader>j", require("smart-splits").swap_buf_down, { desc = "Swap buffer down" })
vim.keymap.set("n", "<leader><leader>k", require("smart-splits").swap_buf_up, { desc = "Swap buffer up" })
vim.keymap.set("n", "<leader><leader>l", require("smart-splits").swap_buf_right, { desc = "Swap buffer right" })
-- Yank, delete, and paste always use system clipboard
vim.keymap.set({ 'n', 'v' }, 'y', '"+y', { noremap = true, silent = true })
vim.keymap.set({ 'n', 'v' }, 'Y', '"+Y', { noremap = true, silent = true })
vim.keymap.set({ 'n', 'v' }, 'd', '"+d', { noremap = true, silent = true })
vim.keymap.set({ "n", "v" }, "y", '"+y', { noremap = true, silent = true })
vim.keymap.set({ "n", "v" }, "Y", '"+Y', { noremap = true, silent = true })
vim.keymap.set({ "n", "v" }, "d", '"+d', { noremap = true, silent = true })
-- vim.keymap.set({ 'n', 'v' }, 'x', '"+x', { noremap = true, silent = true })
vim.keymap.set({ 'n', 'v' }, 'p', '"+p', { noremap = true, silent = true })
vim.keymap.set({ 'n', 'v' }, 'P', '"+P', { noremap = true, silent = true })
vim.keymap.set({ "n", "v" }, "p", '"+p', { noremap = true, silent = true })
vim.keymap.set({ "n", "v" }, "P", '"+P', { noremap = true, silent = true })
-- Clear highlights on search when pressing <Esc> in normal mode
-- See `:help hlsearch`
vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>")
--Other
vim.keymap.set('n', 's', ":HopWord<cr>", { desc = 'hop', silent = true })
vim.keymap.set('n', '<tab>', ":tabNext<cr>", { desc = 'Next tab', silent = true })
vim.keymap.set('n', '<A-f>', ":Format<cr>", { desc = 'Format code', silent = true })
vim.keymap.set('n', '<C-m>', ":make<cr>", { desc = 'Format code', silent = true })
vim.keymap.set('n', '<C-n>', ":make clean<cr>", { desc = 'Format code', silent = true })
vim.keymap.set('n', '<C-s>', ":write<cr>", { desc = 'Save', silent = true })
vim.keymap.set('n', '<C-q>', ":quit<cr>", { desc = 'Quit', silent = true })
vim.keymap.set('n', '<leader>e', ":Neotree filesystem reveal float toggle<cr>", { desc = 'File explorer', silent = true })
vim.keymap.set('n', '<leader>d', ":Trouble diagnostics toggle<cr>", { desc = 'Diagnostic view', silent = true })
vim.keymap.set('n', '<leader>f', ":FzfLua files<cr>", { desc = 'Find file', silent = true })
vim.keymap.set("n", "s", ":HopWord<cr>", { desc = "hop", silent = true })
vim.keymap.set("n", "<tab>", ":tabNext<cr>", { desc = "Next tab", silent = true })
vim.keymap.set("n", "<C-s>", ":write<cr>", { desc = "Save", silent = true })
vim.keymap.set("n", "<C-q>", ":quit<cr>", { desc = "Quit", silent = true })
vim.keymap.set(
"n",
"<leader>e",
":Neotree filesystem reveal float toggle<cr>",
{ desc = "File explorer", silent = true }
)
vim.keymap.set("n", "<leader>d", ":Trouble diagnostics toggle<cr>", { desc = "Diagnostic view", silent = true })
vim.keymap.set("n", "<leader>f", ":FzfLua files cwd=~/<cr>", { desc = "Find file", silent = true })

View File

@ -1,6 +1,7 @@
# Plugind
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'mrjones2014/smart-splits.nvim'
# Install `tpm` if needed.
if "test ! -d ~/.tmux/plugins/tpm" \
@ -17,36 +18,40 @@ set -g pane-base-index 1
set-window-option -g pane-base-index 1
set-option -g renumber-windows on
# VIM and FZF navigation bindings
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
is_fzf="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'"
bind -n C-h run "($is_vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "($is_vim && tmux send-keys C-j) || ($is_fzf && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "($is_vim && tmux send-keys C-k) || ($is_fzf && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "($is_vim && tmux send-keys C-l) || tmux select-pane -R"
# bind -n 'C-\' if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
bind -n M-h run "($is_vim && tmux send-keys M-h) || tmux resize-pane -L 1"
bind -n M-j run "($is_vim && tmux send-keys M-j) || tmux resize-pane -D 1"
bind -n M-k run "($is_vim && tmux send-keys M-k) || tmux resize-pane -U 1"
bind -n M-l run "($is_vim && tmux send-keys M-l) || tmux resize-pane -R 1"
# Optional configurations with their default values if omitted:
set -g @smart-splits_no_wrap '' # to disable wrapping. (any value disables wrapping)
set -g @smart-splits_move_left_key 'M-h' # key-mapping for navigation.
set -g @smart-splits_move_down_key 'M-j' # --"--
set -g @smart-splits_move_up_key 'M-k' # --"--
set -g @smart-splits_move_right_key 'M-l' # --"--
set -g @smart-splits_resize_left_key 'C-M-h' # key-mapping for resizing.
set -g @smart-splits_resize_down_key 'C-M-j' # --"--
set -g @smart-splits_resize_up_key 'C-M-k' # --"--
set -g @smart-splits_resize_right_key 'C-M-l' # --"--
set -g @smart-splits_resize_step_size '3' # change the step-size for resizing.
bind -n M-Left split-window -h -b -c "#{pane_current_path}"
bind -n M-Right split-window -h -c "#{pane_current_path}"
bind -n M-Down split-window -v -c "#{pane_current_path}"
bind -n M-Up split-window -v -b -c "#{pane_current_path}"
bind -n M-1 select-window -t 1
bind -n M-2 select-window -t 2
bind -n M-3 select-window -t 3
bind -n M-4 select-window -t 4
bind -n M-5 select-window -t 5
bind -n C-M-n select-window -n
bind -n M-n select-window -n
bind -n C-M-c new-window
bind -n C-M-x confirm kill-pane
bind -n M-c new-window
bind -n M-x confirm kill-pane
bind -n C-M-v split-window -h -c "#{pane_current_path}"
bind -n C-M-s split-window -v -c "#{pane_current_path}"
bind -n C-g display-popup -d "#{pane_current_path}" -E -w 90% -h 90% "lazygit"
bind -n C-t display-popup -d "#{pane_current_path}" -E -w 90% -h 90% "btop"
bind -n C-f display-popup -d "#{pane_current_path}" -E -w 90% -h 90% "EDITOR=nvim ranger"
bind -n M-g display-popup -d "#{pane_current_path}" -E -w 90% -h 90% "lazygit"
bind -n M-t display-popup -d "#{pane_current_path}" -E -w 90% -h 90% "btop"
bind -n M-f display-popup -d "#{pane_current_path}" -E -w 90% -h 90% "EDITOR=nvim ranger"
set-option -g status-position top
set-option -g default-terminal "tmux-256color"
@ -56,8 +61,6 @@ set-option -g focus-events on
set-option -g status-right-length 100
set-option -g set-clipboard on
# set -g allow-passthrough on
# set -g extended-keys on
set -g status-interval 2
set -g status-bg "#303030"
set -g status-fg "#c6c6c6"

View File

@ -274,16 +274,11 @@ if [ "${ROLES[TERMINAL]}" == "yes" ]; then
make -C ble.sh install
if [ -d ~/ble.sh ]; then rm -rf ~/ble.sh; fi
ln -sf ~/linuxbox/blerc ~/.blerc
# fi
#
# # Install code utility
# if [ "${ROLES[CODE]}" == "yes" ]; then
# printf -- '\033[33m Installing code utilities\n\033[37m'
# sudo pacman --noconfirm --needed -S code platformio-core
printf -- '\033[33m Installing LSP servers\n\033[37m'
sudo pacman --noconfirm --needed -S rust-analyzer lua-language-server bash-language-server ccls vscode-html-languageserver vscode-json-languageserver marksman pyright yaml-language-server vscode-css-languageserver clang
sudo pacman --noconfirm --needed -S prettier stylua python-black shfmt lua-language-server bash-language-server ccls vscode-html-languageserver vscode-json-languageserver marksman pyright yaml-language-server vscode-css-languageserver clang
yay --noconfirm -S --needed --aur dockerfile-language-server
rustup component add rust-analyzer clippy rustfmt
printf -- '\033[33m Installing Rust embedded rp2040\n\033[37m'
cd ~
@ -293,15 +288,6 @@ if [ "${ROLES[TERMINAL]}" == "yes" ]; then
mkdir -p ~/.local/bin
ln -sf ~/linuxbox/pico-load.sh ~/.local/bin/pico-load
# printf -- '\033[33m Installing teensy udev rules\n\033[37m'
# if [ ! -f /.dockerenv ]; then
# sudo rm -f /tmp/00-teensy.rules /etc/udev/rules.d/00-teensy.rules /lib/udev/rules.d/00-teensy.rules
# sudo wget -O /tmp/00-teensy.rules https://www.pjrc.com/teensy/00-teensy.rules
# sudo install -o root -g root -m 0664 /tmp/00-teensy.rules /lib/udev/rules.d/00-teensy.rules
# sudo udevadm control --reload-rules
# sudo udevadm trigger
# fi
printf -- '\033[33m Installing VirtualHere client\n\033[37m'
cd ~
wget https://www.virtualhere.com/sites/default/files/usbclient/scripts/virtualhereclient.service