diff options
Diffstat (limited to 'private_dot_config/nvim')
| -rw-r--r-- | private_dot_config/nvim/after/ftdetect/.keep | 0 | ||||
| -rw-r--r-- | private_dot_config/nvim/after/ftplugin/dockerfile.vim | 1 | ||||
| -rw-r--r-- | private_dot_config/nvim/after/ftplugin/json.vim | 1 | ||||
| -rw-r--r-- | private_dot_config/nvim/after/ftplugin/markdown.vim | 1 | ||||
| -rw-r--r-- | private_dot_config/nvim/after/syntax/antlr4.vim | 93 | ||||
| -rw-r--r-- | private_dot_config/nvim/after/syntax/jolie.vim | 59 | ||||
| -rw-r--r-- | private_dot_config/nvim/after/syntax/prr.vim | 22 | ||||
| -rw-r--r-- | private_dot_config/nvim/dot_netrwhist | 5 | ||||
| -rw-r--r-- | private_dot_config/nvim/init.lua | 242 | ||||
| -rw-r--r-- | private_dot_config/nvim/lua/dap_conf.lua | 52 | ||||
| -rw-r--r-- | private_dot_config/nvim/lua/evil_lualine.lua | 152 | ||||
| -rw-r--r-- | private_dot_config/nvim/lua/git.lua | 65 | ||||
| -rw-r--r-- | private_dot_config/nvim/lua/lsp_conf.lua | 130 | ||||
| -rw-r--r-- | private_dot_config/nvim/plugin/packer_compiled.lua | 254 |
14 files changed, 1077 insertions, 0 deletions
diff --git a/private_dot_config/nvim/after/ftdetect/.keep b/private_dot_config/nvim/after/ftdetect/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/private_dot_config/nvim/after/ftdetect/.keep diff --git a/private_dot_config/nvim/after/ftplugin/dockerfile.vim b/private_dot_config/nvim/after/ftplugin/dockerfile.vim new file mode 100644 index 0000000..b388056 --- /dev/null +++ b/private_dot_config/nvim/after/ftplugin/dockerfile.vim @@ -0,0 +1 @@ +let g:indentLine_enabled = 0 diff --git a/private_dot_config/nvim/after/ftplugin/json.vim b/private_dot_config/nvim/after/ftplugin/json.vim new file mode 100644 index 0000000..b388056 --- /dev/null +++ b/private_dot_config/nvim/after/ftplugin/json.vim @@ -0,0 +1 @@ +let g:indentLine_enabled = 0 diff --git a/private_dot_config/nvim/after/ftplugin/markdown.vim b/private_dot_config/nvim/after/ftplugin/markdown.vim new file mode 100644 index 0000000..b388056 --- /dev/null +++ b/private_dot_config/nvim/after/ftplugin/markdown.vim @@ -0,0 +1 @@ +let g:indentLine_enabled = 0 diff --git a/private_dot_config/nvim/after/syntax/antlr4.vim b/private_dot_config/nvim/after/syntax/antlr4.vim new file mode 100644 index 0000000..8f6c412 --- /dev/null +++ b/private_dot_config/nvim/after/syntax/antlr4.vim @@ -0,0 +1,93 @@ +if exists('b:current_syntax') + finish +endif + +command -nargs=* HiLink highlight link <args> + +syntax match antlr4EventId +[a-zA-Z_][a-zA-Z0-9_]*+ contained +syntax match antlr4ParName +\<[a-z][a-zA-Z0-9_]*\>+ containedin=antlr4RHS +syntax match antlr4LexName +\<[A-Z][a-zA-Z0-9_]*\>+ containedin=antlr4RHS +syntax match antlr4Assign /[a-zA-Z]\++\?=/ containedin=antlr4RHS + +if exists('g:antlr4_highlight_punctuation') + syntax match antlr4Punctuation +[\-():;]+ +endif + +syntax include @included syntax/java.vim + +syntax region antlr4RHS start=+:+ end=+;+ extend + +syntax region antlr4Embed start=+{+ end=+}?\?+ contains=@included,antlr4Variable keepend + \ containedin=antlr4RHS +syntax region antlr4Embed start=+\[+ end=+\]+ contains=@included,antlr4Variable keepend + + +syntax match antlr4Repeat +[+*]+ containedin=antlr4RHS +syntax match antlr4Condition +?+ containedin=antlr4RHS +syntax match antlr4Option "|" containedin=antlr4RHS + +" Use specifically containedin=javaParenT so it will be highlighted inside +" parens +syntax match antlr4Variable contained +\$[a-zA-Z_][a-zA-Z0-9_]*+ containedin=javaParenT + +syntax match antlr4Keyword /@\(\(parser\|lexer\)::\)\?\(header\|members\)/ +syntax match antlr4Keyword /@after/ + +syntax match antlr4Escape +\\[nrvt]+ +syntax match antlr4Escape +\\u[0-9a-fA-F]\{4}+ +syntax match antlr4Escape +\\u{[0-9a-fA-F]\{4}}+ +syntax match antlr4Escape +\\p{.\{-}}+ + +syntax match antlr4SetEscape +\\-+ containedin=antlr4RHS + +syntax keyword antlr4Keyword grammar +syntax keyword antlr4Keyword lexer parser options +syntax keyword antlr4Keyword fragment tokens +syntax keyword antlr4Keyword returns locals throws catch finally mode options + +syntax keyword antlr4Import import + +syntax keyword antlr4Operation skip more popMode mode pushMode type channel + \ containedin=antlr4RHS + +syntax region antlr4Set start=+\[+ end=+\]+ contained + \ contains=antlr4Escape,antlr4SetEscape containedin=antlr4RHS +syntax region antlr4Attr start="<" end=">" + \ containedin=antlr4RHS +syntax region antlr4String start=+'+ end=+'+ containedin=antlr4RHS contains=antlr4Escape + +syntax region antlr4Comment start=+/\*+ end=+\*/+ + \ containedin=antlr4RHS +syntax region antlr4Comment start=+//+ end=+$+ + \ containedin=antlr4RHS + +syntax region antlr4Event start=+#+ end=+$+ + \ containedin=antlr4RHS contains=antlr4EventId + +HiLink antlr4Comment Comment +HiLink antlr4Keyword KeyWord +HiLink antlr4ParName Type +HiLink antlr4LexName Macro +HiLink antlr4Attr Special +HiLink antlr4Assign Statement +HiLink antlr4Set Character +HiLink antlr4String String + +if exists('g:antlr4_highlight_punctuation') + HiLink antlr4Punctuation Operator +endif + +HiLink antlr4Repeat Repeat +HiLink antlr4Condition Conditional +HiLink antlr4Option Delimiter +HiLink antlr4Import PreProc +HiLink antlr4Escape Special +HiLink antlr4SetEscape antlr4Escape +HiLink antlr4Operation Function +HiLink antlr4EventId Function +HiLink antlr4Annotation KeyWord +HiLink antlr4Variable Special + +delcommand HiLink + +let b:current_syntax = 'antlr4' diff --git a/private_dot_config/nvim/after/syntax/jolie.vim b/private_dot_config/nvim/after/syntax/jolie.vim new file mode 100644 index 0000000..c7b3a21 --- /dev/null +++ b/private_dot_config/nvim/after/syntax/jolie.vim @@ -0,0 +1,59 @@ +if exists("b:current_syntax") + finish +endif + +syn keyword jolieBoolean true false +syn keyword jolieDefinitionTypes inputPort outputPort interface type define service +syn keyword jolieKeyword location Location protocol Protocol interfaces Interfaces aggregates Aggregates redirects Redirects class Jolie JavaScript Java OneWay oneWay RequestResponse requestResponse execution +syn keyword jolieOtherKeyword constants cH instanceof execution comp concurrent nullProcess single sequential main foreign java init cset is_defined embed embedded extender courier forward install undef include synchronized throws throw from import as +syn keyword jolieConditional if else +syn keyword jolieRepeat while for foreach until in +syn keyword jolieException throw +syn keyword jolieStatement forward scope provide +syn keyword jolieType void bool int string long double any raw +syn keyword jolieKeywordModifiers csets global +syn match jolieOperators "(<<|&&|\|\||+|-|/|*|=|==|++|-|+=|-=|*=|/=|!|%=|%)" + +syn match jolieSpecialChar contained "\\." + +syn region jolieString start=+"+ end=+"+ contains=jolieSpecialChar + +syn match jolieNumber "\<\d\+\>" + +syn match jolieMethodInvocation "\<\(\w\+\)@\(\w\+\)\>" contains=jolieMethodName,jolieClassName + +syn match jolieMethodName "\w\+@"me=e-1 contained +syn match jolieClassName "@\w\+\>"ms=s+1 contained + +syn match jolieMethodName2 "\(\w\+\)(" + +syn keyword jolieTodo contained TODO FIXME +syn region jolieComment start="/\*" end="\*/" contains=jolieTodo +syn match jolieLineComment "//.*" + +let b:current_syntax = "jolie" + +hi def link jolieBoolean Boolean +hi def link jolieComment Comment +hi def link jolieLineComment Comment +hi def link jolieDefinitionTypes Keyword +hi def link jolieKeyword Keyword +hi def link jolieOtherKeyword Keyword + +hi def link jolieOperators Operator + +hi def link jolieConditional Conditional +hi def link jolieRepeat Repeat +hi def link jolieException Exception +hi def link jolieStatement Statement +hi def link jolieType Type + +hi def link jolieKeywordModifiers StorageClass + +hi def link jolieString String + +hi def link jolieNumber Number + +hi def link jolieMethodName Function +hi def link jolieClassName Type +hi def link jolieMethodName2 Function diff --git a/private_dot_config/nvim/after/syntax/prr.vim b/private_dot_config/nvim/after/syntax/prr.vim new file mode 100644 index 0000000..43a0557 --- /dev/null +++ b/private_dot_config/nvim/after/syntax/prr.vim @@ -0,0 +1,22 @@ +" Vim syntax file +" Language: prr +" Maintainer: Daniel Xu <dxu@dxuuu.xyz> +" Last Change: 2022 Mar 25 +" Credits: Bram Moolenaar <Bram@vim.org> +" +" This version is copied and edited from diff.vim + +" Check whether an earlier file has defined a syntax already +if exists("b:current_syntax") + finish +endif + +syn match diffAdded "^> +.*" +syn match diffRemoved "^> -.*" + +" Define the default highlighting. +" Only used when an item doesn't have highlighting yet +hi def link diffAdded Type +hi def link diffRemoved Statement + +let b:current_syntax = "prr" diff --git a/private_dot_config/nvim/dot_netrwhist b/private_dot_config/nvim/dot_netrwhist new file mode 100644 index 0000000..987ad58 --- /dev/null +++ b/private_dot_config/nvim/dot_netrwhist @@ -0,0 +1,5 @@ +let g:netrw_dirhistmax =10 +let g:netrw_dirhistcnt =3 +let g:netrw_dirhist_3='/var/www/html/riflessi/img/base' +let g:netrw_dirhist_2='/var/www/html/riflessi/img' +let g:netrw_dirhist_1='/var/www/html/riflessi/img/base' diff --git a/private_dot_config/nvim/init.lua b/private_dot_config/nvim/init.lua new file mode 100644 index 0000000..29608d4 --- /dev/null +++ b/private_dot_config/nvim/init.lua @@ -0,0 +1,242 @@ +-- Auto-reload Neovim configuration on save +vim.cmd [[ + augroup packer_user_config + autocmd! + autocmd BufWritePost init.lua source <afile> | PackerCompile + augroup end +]] + +require('packer').startup(function(use) + -- Packer can manage itself + use 'wbthomason/packer.nvim' + + -- use 'cespare/vim-toml' -- TOML syntax highlighting + use 'rust-lang/rust.vim' -- Rust language support + use 'nvim-lua/plenary.nvim' -- Lua utilities for plugins + use 'lewis6991/gitsigns.nvim' -- Git integration (show signs in gutter) + use 'kyazdani42/nvim-web-devicons'-- File icons + use 'mg979/vim-visual-multi' -- Multi-cursor support + use 'tpope/vim-fugitive' -- Git wrapper for commands like :Git + use 'ap/vim-css-color' -- Show color preview for CSS colors + -- use 'lukas-reineke/indent-blankline.nvim' -- Display vertical indentation lines + use 'google/vim-searchindex' -- Show search match count + use 'numToStr/Comment.nvim' -- Easily comment/uncomment lines + -- use 'togglebyte/togglerust' -- Rust debugging tools + -- use 'chriskempson/base16-vim' -- Base16 color schemes + use 'NLKNguyen/papercolor-theme' -- PaperColor theme + -- use 'projekt0n/github-nvim-theme' + use 'Shatur/neovim-ayu' + use 'nvim-telescope/telescope.nvim' -- Fuzzy finder + use 'neovim/nvim-lspconfig' -- LSP configuration for multiple languages + use 'hrsh7th/nvim-cmp' -- Autocompletion engine + use 'hrsh7th/cmp-nvim-lsp' -- LSP source for nvim-cmp + use 'saadparwaiz1/cmp_luasnip' -- Snippet completion for nvim-cmp + use 'L3MON4D3/LuaSnip' -- Snippet engine + use 'kyazdani42/nvim-tree.lua' -- File explorer + use 'ray-x/lsp_signature.nvim' -- Show function signatures as you type + use 'folke/todo-comments.nvim' -- Highlight and search TODO comments + use 'saecki/crates.nvim' -- Rust crate version management + use { + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate' -- Update treesitter parsers + } + use 'folke/trouble.nvim' -- Diagnostics and references list + use 'folke/lsp-colors.nvim' -- Adds missing LSP diagnostics highlight groups + use 'sindrets/diffview.nvim' -- Git diff and history viewer + + use 'mfussenegger/nvim-dap' -- Debug Adapter Protocol client implementation + use 'leoluz/nvim-dap-go' -- Neovim DAP extension for Go + use 'nvim-neotest/nvim-nio' + use 'rcarriga/nvim-dap-ui' + + use 'koraa/proverif.vim' + + use { + 'nvim-lualine/lualine.nvim', + requires = { 'nvim-tree/nvim-web-devicons', opt = true } + } + + -- Automatically set up the configuration after cloning packer.nvim + if packer_bootstrap then + require('packer').sync() + end +end) + +-- General Neovim settings + +-- Configure completion options (menu, menuone, noselect) +vim.opt.completeopt = "menu,menuone,noselect" + +-- Enable system clipboard access +vim.opt.clipboard = "unnamedplus" + +-- Enable mouse support in all modes +vim.opt.mouse = "a" + +-- Enable command-line completion features +vim.opt.wildmenu = true +vim.opt.wildmode = { "longest", "list", "full" } + +-- Ignore certain file types when using wildmenu for file navigation +vim.opt.wildignore = "*.png,*.jpg,*.gif,*.swp,*.o,*.pyc,vendor" + +-- Show absolute line numbers +-- vim.opt.number = true + +-- Show relative line numbers +-- vim.opt.relativenumber = true + +-- Set text width to 80 characters +vim.opt.textwidth = 80 + +-- Highlight a column at 80 characters +vim.opt.colorcolumn = "80" + +-- Disable line wrapping +vim.opt.wrap = false + +-- Set tab width and shift width to 4 spaces +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 + +-- Use spaces instead of tabs +vim.opt.expandtab = true + +-- Automatically indent new lines to match the previous line +vim.opt.autoindent = true + +-- Automatically reload files if they are modified outside of Neovim +vim.opt.autoread = true + +-- Set UTF-8 as the default encoding +vim.opt.encoding = "UTF-8" + +-- Set the history size for command line and search +vim.opt.history = 1000 + +-- Highlight search matches +vim.opt.hlsearch = true + +-- Incrementally search while typing +vim.opt.incsearch = true + +-- Disable backup file creation +vim.opt.backup = false + +-- Set the status line to always be visible +vim.opt.laststatus = 2 + +-- Show invisible characters (e.g., tabs, spaces, etc.) +vim.opt.list = true + +vim.opt.showmatch = true + +-- Define characters for different invisible characters +vim.opt.listchars = { eol = '⏎', tab = '» ', trail = 'ˑ', nbsp = '⎵' } +vim.cmd([[match Error /\s\+$/]]) +vim.api.nvim_create_autocmd("FileType", { + pattern = { "go", "c", "cpp" }, + callback = function() + vim.opt.autoindent = true + vim.opt.expandtab = false + vim.opt.tabstop = 4 + vim.opt.shiftwidth = 4 + end, +}) + + +-- Use indent-based folding +vim.opt.foldmethod = "indent" + +-- Open vertical splits to the right of the current window +vim.opt.splitright = true + +-- Open horizontal splits below the current window +vim.opt.splitbelow = true + +-- Optimize screen redrawing for performance +vim.opt.lazyredraw = true + +-- Disable swapfile creation +vim.opt.swapfile = false + +-- Enable 24-bit RGB color in the terminal +vim.opt.termguicolors = true + +-- Set background to dark mode +vim.opt.background = "dark" + +-- Highlight the current line +vim.opt.cursorline = true + +-- **Highlight settings** +-- Set custom highlights for various UI components +-- vim.cmd('colorscheme github_dark_default') +vim.cmd('colorscheme ayu') +vim.cmd [[ + highlight Normal guibg=NONE + " highlight NormalNC guibg=#111111 + highlight NonText guibg=NONE + highlight LineNr guibg=NONE + highlight CursorLine guibg=NONE + highlight CursorLineNr guibg=NONE guifg=Yellow + highlight StatusLineNC guibg=#0d1117 guifg=#cacaca + highlight Error guibg=red guifg=#000000 + "highlight StatusLine guibg=#000000 guifg=Yellow + "highlight StatusLineNC guibg=#000000 guifg=Yellow + highlight SignColumn guibg=NONE + highlight GitGutterChange guifg=#f1c40f guibg=#000000 + highlight GitGutterAdd guifg=#2ecc71 guibg=#000000 + highlight GitGutterDelete guifg=#e74c3c guibg=#000000 +]] + +-- Keybindings +vim.g.mapleader = "," -- Set the leader key to "," +vim.api.nvim_set_keymap('n', 'j', 'gj', { noremap = true }) -- Move down visually wrapped lines +vim.api.nvim_set_keymap('n', 'k', 'gk', { noremap = true }) -- Move up visually wrapped lines + +---- Buffers +vim.api.nvim_set_keymap('n', ']b', ':bnext<CR>', { noremap = true, silent = true }) -- Move to the next buffer +vim.api.nvim_set_keymap('n', '[b', ':bprev<CR>', { noremap = true, silent = true }) -- Move to the previous buffer +vim.api.nvim_set_keymap('n', '<leader>b', '<cmd>Telescope buffers<CR>', { noremap = true, silent = true }) -- List and switch to buffers using Telescope + +---- Tabs +vim.api.nvim_set_keymap('n', 'tn', ':tabnew<CR>', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', ']t', ':tabn<CR>', { noremap = true, silent = true }) -- Move to the next tab +vim.api.nvim_set_keymap('n', '[t', ':tabp<CR>', { noremap = true, silent = true }) -- Move to the previous tab + +vim.api.nvim_set_keymap('n', '<leader>o', ':only<CR>', { noremap = true }) -- Close all other windows +vim.api.nvim_set_keymap('n', '<A-t>', ':NvimTreeToggle<CR>', { noremap = true }) -- Toggle NvimTree file explorer +vim.api.nvim_set_keymap('n', '<leader>pa', ':set paste<CR>', { noremap = true }) -- Enable paste mode +vim.api.nvim_set_keymap('n', '<leader>npa', ':set nopaste<CR>', { noremap = true }) -- Disable paste mode +vim.api.nvim_set_keymap('n', '<leader>cr', ':Cargo run<CR>', { noremap = true }) -- Run `cargo run` for Rust projects +vim.api.nvim_set_keymap('n', '<space>d', '<cmd>Trouble diagnostics<cr>', { noremap = true }) -- Toggle Trouble diagnostic window +vim.api.nvim_set_keymap('n', '<leader>ff', '<cmd>Telescope find_files<cr>', { noremap = true }) -- Find files with Telescope +vim.api.nvim_set_keymap('n', '<leader>fg', '<cmd>Telescope live_grep<cr>', { noremap = true }) -- Live grep with Telescope +vim.api.nvim_set_keymap('n', '<leader>fh', '<cmd>Telescope help_tags<cr>', { noremap = true }) -- Search help tags with Telescope +vim.api.nvim_set_keymap('n', '<C-i>', ':lua vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())<CR>', { noremap = true }) + +-- Custom command aliases for Diffview +vim.api.nvim_create_user_command('Do', 'DiffviewOpen', {}) +vim.api.nvim_create_user_command('Dc', 'DiffviewClose', {}) +vim.api.nvim_create_user_command('Dh', 'DiffviewFileHistory', {}) + + +-- Plugin configuration +require('nvim-tree').setup { actions = { open_file = { quit_on_open = true } } } +require('todo-comments').setup {} +require('crates').setup {} +require('nvim-treesitter.configs').setup { highlight = { enable = true } } +require('lsp-colors').setup {} +require('Comment').setup() +-- require("ibl").setup { indent = {char = "¦"} } +-- vim.cmd.highlight('clear @ibl.scope.underline.1') + +-- General settings from ~/.config/nvim/lua/ +require('git') -- Load git-related settings +require('lsp_conf') -- Load LSP configuration +require('dap_conf') +require('evil_lualine') + +-- Set up language client for Go +vim.g.LanguageClient_serverCommands = { go = { 'gopls' } } diff --git a/private_dot_config/nvim/lua/dap_conf.lua b/private_dot_config/nvim/lua/dap_conf.lua new file mode 100644 index 0000000..2346e6a --- /dev/null +++ b/private_dot_config/nvim/lua/dap_conf.lua @@ -0,0 +1,52 @@ +local dap, dapui = require('dap'), require('dapui') +local dapgo = require('dap-go') +dapui.setup() +dapgo.setup() +dap.listeners.before.attach.dapui_config = function() + dapui.open() +end +dap.listeners.before.launch.dapui_config = function() + dapui.open() +end + +dap.adapters.gdb = { + type = "executable", + command = "gdb", + args = { "--interpreter=dap", "--eval-command", "set print pretty on" } +} + +local configurations = {'c', 'cpp', 'rust'} + +for _, conf in ipairs(configurations) do + dap.configurations[conf] = { + { + name = "Launch", + type = "gdb", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = "${workspaceFolder}", + stopAtBeginningOfMainSubprogram = false, + }, + } +end + +-- Include the next few lines until the comment only if you feel you need it +dap.listeners.before.event_terminated.dapui_config = function() + dapui.close() +end +dap.listeners.before.event_exited.dapui_config = function() + dapui.close() +end +-- Include everything after this + + +vim.keymap.set('n', '<F12>', function() require('dap').continue() end) +vim.keymap.set('n', '<F5>', function() require('dap').step_over() end) +vim.keymap.set('n', '<F6>', function() require('dap').step_into() end) +vim.keymap.set('n', '<F7>', function() require('dap').step_out() end) +vim.keymap.set('n', '<C-K>', function() require('dap').toggle_breakpoint() end) +vim.api.nvim_create_user_command('DapRepeat',function() require('dap').run_last() end, {}) +vim.api.nvim_create_user_command('DapOpen',function() dapui.open() end, {}) +vim.api.nvim_create_user_command('DapClose',function() dapui.close() end, {}) diff --git a/private_dot_config/nvim/lua/evil_lualine.lua b/private_dot_config/nvim/lua/evil_lualine.lua new file mode 100644 index 0000000..b38e283 --- /dev/null +++ b/private_dot_config/nvim/lua/evil_lualine.lua @@ -0,0 +1,152 @@ +-- Eviline config for lualine +-- Author: shadmansaleh +-- Credit: glepnir +local lualine = require('lualine') + +-- Color table for highlights +-- stylua: ignore +local colors = { + bg = '#202328', + fg = '#bbc2cf', + yellow = '#ECBE7B', + cyan = '#008080', + darkblue = '#081633', + green = '#98be65', + orange = '#FF8800', + violet = '#a9a1e1', + magenta = '#c678dd', + blue = '#51afef', + red = '#ec5f67', +} + +local conditions = { + buffer_not_empty = function() + return vim.fn.empty(vim.fn.expand('%:t')) ~= 1 + end, + hide_in_width = function() + return vim.fn.winwidth(0) > 80 + end, + check_git_workspace = function() + local filepath = vim.fn.expand('%:p:h') + local gitdir = vim.fn.finddir('.git', filepath .. ';') + return gitdir and #gitdir > 0 and #gitdir < #filepath + end, +} + +-- Config +local config = { + options = { + -- Disable sections and component separators + component_separators = '', + section_separators = '', + theme = { + -- We are going to use lualine_c an lualine_x as left and + -- right section. Both are highlighted by c theme . So we + -- are just setting default looks o statusline + normal = { c = { fg = colors.fg, bg = colors.bg } }, + inactive = { c = { fg = colors.fg, bg = colors.bg } }, + }, + }, + sections = { + -- these are to remove the defaults + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + -- These will be filled later + lualine_c = {}, + lualine_x = {}, + }, + inactive_sections = { + -- these are to remove the defaults + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + lualine_c = {}, + lualine_x = {}, + }, +} + +-- Inserts a component in lualine_c at left section +local function ins_left(component) + table.insert(config.sections.lualine_c, component) +end + +-- Inserts a component in lualine_x at right section +local function ins_right(component) + table.insert(config.sections.lualine_x, component) +end + +ins_left { + 'filename', + cond = conditions.buffer_not_empty, + path = 3, + color = { fg = colors.magenta, gui = 'bold' }, +} + +ins_left { + -- filesize component + 'filesize', + cond = conditions.buffer_not_empty, +} + +ins_left { 'location' } + +ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } } +ins_left { + 'diagnostics', + sources = { 'nvim_diagnostic' }, + symbols = { error = ' ', warn = ' ', info = ' ' }, + diagnostics_color = { + error = { fg = colors.red }, + warn = { fg = colors.yellow }, + info = { fg = colors.cyan }, + }, +} + +-- Insert mid section. You can make any number of sections in neovim :) +-- for lualine it's any number greater then 2 +ins_left { + function() + return '%=' + end, +} + +-- Add components to right sections +ins_right { 'lsp_status' } + +ins_right { + 'o:encoding', -- option component same as &encoding in viml + fmt = string.upper, -- I'm not sure why it's upper case either ;) + cond = conditions.hide_in_width, + color = { fg = colors.green, gui = 'bold' }, +} + +ins_right { + 'fileformat', + fmt = string.upper, + icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh + color = { fg = colors.green, gui = 'bold' }, +} + +ins_right { + 'branch', + icon = '', + color = { fg = colors.violet, gui = 'bold' }, +} + +ins_right { + 'diff', + -- Is it me or the symbol for modified us really weird + symbols = { added = ' ', modified = ' ', removed = ' ' }, + diff_color = { + added = { fg = colors.green }, + modified = { fg = colors.orange }, + removed = { fg = colors.red }, + }, + cond = conditions.hide_in_width, +} + +-- Now don't forget to initialize lualine +lualine.setup(config) diff --git a/private_dot_config/nvim/lua/git.lua b/private_dot_config/nvim/lua/git.lua new file mode 100644 index 0000000..da6bbdd --- /dev/null +++ b/private_dot_config/nvim/lua/git.lua @@ -0,0 +1,65 @@ +require('gitsigns').setup { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '-' }, + topdelete = { text = '-' }, + changedelete = { text = '~' }, + untracked = { text = '┆' }, + }, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + follow_files = true + }, + attach_to_untracked = true, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + }, + current_line_blame_formatter = '<author>, <author_time:%Y-%m-%d> - <summary>', + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, -- Disable if file is longer than this (in lines) + preview_config = { + -- Options passed to nvim_open_win + border = 'single', + style = 'minimal', + relative = 'cursor', + row = 0, + col = 1 + }, + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + map('n', ']c', function() + if vim.wo.diff then return ']c' end + vim.schedule(function() gs.next_hunk() end) + return '<Ignore>' + end, {expr=true}) + + map('n', '[c', function() + if vim.wo.diff then return '[c' end + vim.schedule(function() gs.prev_hunk() end) + return '<Ignore>' + end, {expr=true}) + + map('n', 'hs', gs.stage_hunk) + map('v', 'hs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end) + map('n', 'hS', gs.stage_buffer) + map('n', 'hu', gs.undo_stage_hunk) + map('n', 'hp', gs.preview_hunk) + map('n', 'hB', gs.blame_line) + end +} diff --git a/private_dot_config/nvim/lua/lsp_conf.lua b/private_dot_config/nvim/lua/lsp_conf.lua new file mode 100644 index 0000000..15fa695 --- /dev/null +++ b/private_dot_config/nvim/lua/lsp_conf.lua @@ -0,0 +1,130 @@ +local nvim_lsp = require('lspconfig') +local trouble = require("trouble") + +local capabilities = require("cmp_nvim_lsp").default_capabilities() + +-- Redefine LSP diagnostic signs +-- local signs = { Error = 'E', Warning = 'W', Hint = 'H', Information = 'I' } +-- +-- for type, icon in pairs(signs) do +-- local hl = 'DiagnosticSign' .. type +-- vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) +-- end + +local opts = { noremap=true, silent=true } + +-- Setup lsp_signature for function signature help +require "lsp_signature".setup() + +-- Common on_attach function to handle keymaps and settings for all LSPs +local common_on_attach = function(client, bufnr) + -- Key mappings + vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "ga", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) + -- Use vim.diagnostic.open_float for showing line diagnostics (replacing deprecated call) + vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>e", "<cmd>lua vim.diagnostic.open_float()<CR>", opts) + vim.keymap.set('n', '<A-f>', '<cmd>lua vim.lsp.buf.format {async = true}<cr>', opts) + + -- Autoformat on save + vim.cmd("autocmd BufWritePre <buffer> lua vim.lsp.buf.format {async = true}") +end + +-- LSP servers setup +local servers = { + 'clangd', + 'gopls', + 'jdtls', + 'metals', + 'ocamllsp', + 'ruff', + 'rust_analyzer', + -- 'hls', +} + +capabilities.offsetEncoding = { "utf-16" } + +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { + capabilities = capabilities, + on_attach = common_on_attach, + flags = { + debounce_text_changes = 150, + } + } +end + +nvim_lsp.ts_ls.setup { + capabilities = capabilities, + on_attach = common_on_attach, + filetypes = { "typescript", "typescriptreact", "typescript.tsx" }, + cmd = { "typescript-language-server", "--stdio" } +} + +-- nvim_lsp.pyright.setup { +-- settings = { +-- pyright = { +-- -- Using Ruff's import organizer +-- disableOrganizeImports = true, +-- }, +-- python = { +-- analysis = { +-- -- Ignore all files for analysis to exclusively use Ruff for linting +-- ignore = { '*' }, +-- }, +-- }, +-- }, +-- } + +vim.lsp.inlay_hint.enable(true, { 0 }) + +-- Trouble setup +trouble.setup({ + use_diagnostic_signs = true, + auto_close = true, + auto_open = false +}) + +-- nvim-cmp setup for autocompletion +local luasnip = require 'luasnip' +local cmp = require 'cmp' +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + ['<C-d>'] = cmp.mapping.scroll_docs(-4), + ['<C-f>'] = cmp.mapping.scroll_docs(4), + ['<C-Space>'] = cmp.mapping.complete(), + ['<CR>'] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + ['<Tab>'] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_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.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }), + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, +} diff --git a/private_dot_config/nvim/plugin/packer_compiled.lua b/private_dot_config/nvim/plugin/packer_compiled.lua new file mode 100644 index 0000000..9d220c4 --- /dev/null +++ b/private_dot_config/nvim/plugin/packer_compiled.lua @@ -0,0 +1,254 @@ +-- Automatically generated packer.nvim plugin loader code + +if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then + vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') + return +end + +vim.api.nvim_command('packadd packer.nvim') + +local no_errors, error_msg = pcall(function() + +_G._packer = _G._packer or {} +_G._packer.inside_compile = true + +local time +local profile_info +local should_profile = false +if should_profile then + local hrtime = vim.loop.hrtime + profile_info = {} + time = function(chunk, start) + if start then + profile_info[chunk] = hrtime() + else + profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 + end + end +else + time = function(chunk, start) end +end + +local function save_profiles(threshold) + local sorted_times = {} + for chunk_name, time_taken in pairs(profile_info) do + sorted_times[#sorted_times + 1] = {chunk_name, time_taken} + end + table.sort(sorted_times, function(a, b) return a[2] > b[2] end) + local results = {} + for i, elem in ipairs(sorted_times) do + if not threshold or threshold and elem[2] > threshold then + results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' + end + end + if threshold then + table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)') + end + + _G._packer.profile_output = results +end + +time([[Luarocks path setup]], true) +local package_path_str = "/home/santo/.cache/nvim/packer_hererocks/2.1.1741730670/share/lua/5.1/?.lua;/home/santo/.cache/nvim/packer_hererocks/2.1.1741730670/share/lua/5.1/?/init.lua;/home/santo/.cache/nvim/packer_hererocks/2.1.1741730670/lib/luarocks/rocks-5.1/?.lua;/home/santo/.cache/nvim/packer_hererocks/2.1.1741730670/lib/luarocks/rocks-5.1/?/init.lua" +local install_cpath_pattern = "/home/santo/.cache/nvim/packer_hererocks/2.1.1741730670/lib/lua/5.1/?.so" +if not string.find(package.path, package_path_str, 1, true) then + package.path = package.path .. ';' .. package_path_str +end + +if not string.find(package.cpath, install_cpath_pattern, 1, true) then + package.cpath = package.cpath .. ';' .. install_cpath_pattern +end + +time([[Luarocks path setup]], false) +time([[try_loadstring definition]], true) +local function try_loadstring(s, component, name) + local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) + if not success then + vim.schedule(function() + vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) + end) + end + return result +end + +time([[try_loadstring definition]], false) +time([[Defining packer_plugins]], true) +_G.packer_plugins = { + ["Comment.nvim"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/Comment.nvim", + url = "https://github.com/numToStr/Comment.nvim" + }, + LuaSnip = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/LuaSnip", + url = "https://github.com/L3MON4D3/LuaSnip" + }, + ["cmp-nvim-lsp"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", + url = "https://github.com/hrsh7th/cmp-nvim-lsp" + }, + cmp_luasnip = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/cmp_luasnip", + url = "https://github.com/saadparwaiz1/cmp_luasnip" + }, + ["crates.nvim"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/crates.nvim", + url = "https://github.com/saecki/crates.nvim" + }, + ["diffview.nvim"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/diffview.nvim", + url = "https://github.com/sindrets/diffview.nvim" + }, + ["gitsigns.nvim"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/gitsigns.nvim", + url = "https://github.com/lewis6991/gitsigns.nvim" + }, + ["lsp-colors.nvim"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/lsp-colors.nvim", + url = "https://github.com/folke/lsp-colors.nvim" + }, + ["lsp_signature.nvim"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/lsp_signature.nvim", + url = "https://github.com/ray-x/lsp_signature.nvim" + }, + ["lualine.nvim"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/lualine.nvim", + url = "https://github.com/nvim-lualine/lualine.nvim" + }, + ["neovim-ayu"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/neovim-ayu", + url = "https://github.com/Shatur/neovim-ayu" + }, + ["nvim-cmp"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/nvim-cmp", + url = "https://github.com/hrsh7th/nvim-cmp" + }, + ["nvim-dap"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/nvim-dap", + url = "https://github.com/mfussenegger/nvim-dap" + }, + ["nvim-dap-go"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/nvim-dap-go", + url = "https://github.com/leoluz/nvim-dap-go" + }, + ["nvim-dap-ui"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/nvim-dap-ui", + url = "https://github.com/rcarriga/nvim-dap-ui" + }, + ["nvim-lspconfig"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", + url = "https://github.com/neovim/nvim-lspconfig" + }, + ["nvim-nio"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/nvim-nio", + url = "https://github.com/nvim-neotest/nvim-nio" + }, + ["nvim-tree.lua"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/nvim-tree.lua", + url = "https://github.com/kyazdani42/nvim-tree.lua" + }, + ["nvim-treesitter"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/nvim-treesitter", + url = "https://github.com/nvim-treesitter/nvim-treesitter" + }, + ["nvim-web-devicons"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", + url = "https://github.com/kyazdani42/nvim-web-devicons" + }, + ["packer.nvim"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/packer.nvim", + url = "https://github.com/wbthomason/packer.nvim" + }, + ["papercolor-theme"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/papercolor-theme", + url = "https://github.com/NLKNguyen/papercolor-theme" + }, + ["plenary.nvim"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/plenary.nvim", + url = "https://github.com/nvim-lua/plenary.nvim" + }, + ["proverif.vim"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/proverif.vim", + url = "https://github.com/koraa/proverif.vim" + }, + ["rust.vim"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/rust.vim", + url = "https://github.com/rust-lang/rust.vim" + }, + ["telescope.nvim"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/telescope.nvim", + url = "https://github.com/nvim-telescope/telescope.nvim" + }, + ["todo-comments.nvim"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/todo-comments.nvim", + url = "https://github.com/folke/todo-comments.nvim" + }, + ["trouble.nvim"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/trouble.nvim", + url = "https://github.com/folke/trouble.nvim" + }, + ["vim-css-color"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/vim-css-color", + url = "https://github.com/ap/vim-css-color" + }, + ["vim-fugitive"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/vim-fugitive", + url = "https://github.com/tpope/vim-fugitive" + }, + ["vim-searchindex"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/vim-searchindex", + url = "https://github.com/google/vim-searchindex" + }, + ["vim-visual-multi"] = { + loaded = true, + path = "/home/santo/.local/share/nvim/site/pack/packer/start/vim-visual-multi", + url = "https://github.com/mg979/vim-visual-multi" + } +} + +time([[Defining packer_plugins]], false) + +_G._packer.inside_compile = false +if _G._packer.needs_bufread == true then + vim.cmd("doautocmd BufRead") +end +_G._packer.needs_bufread = false + +if should_profile then save_profiles() end + +end) + +if not no_errors then + error_msg = error_msg:gsub('"', '\\"') + vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') +end |