feat: new config

This commit is contained in:
2024-02-20 21:19:43 +08:00
parent 3fad1b11f4
commit b49026c12e
45 changed files with 1072 additions and 427 deletions
-1
View File
@@ -1 +0,0 @@
setl ts=2 sw=2
-1
View File
@@ -1 +0,0 @@
require('lang.go')
-1
View File
@@ -1 +0,0 @@
setl ts=2 sw=2
-1
View File
@@ -1 +0,0 @@
setl ts=2 sw=2
-1
View File
@@ -1 +0,0 @@
setl commentstring={/*%s*/} ts=2 sw=2
-1
View File
@@ -1 +0,0 @@
require('lang.js-ts')
-3
View File
@@ -1,3 +0,0 @@
vim.cmd('set ts=2') -- Insert 2 spaces for a tab
vim.cmd('set sw=2') -- Change the number of space characters inserted for indentation
require('lang/lua')
-2
View File
@@ -1,2 +0,0 @@
require('lang.bash')
-1
View File
@@ -1 +0,0 @@
require('lang.js-ts')
-2
View File
@@ -1,2 +0,0 @@
vim.cmd('set ts=2') -- Insert 2 spaces for a tab
vim.cmd('set sw=2') -- Change the number of space characters inserted for indentation
-2
View File
@@ -1,2 +0,0 @@
vim.cmd('set ts=2') -- Insert 2 spaces for a tab
vim.cmd('set sw=2') -- Change the number of space characters inserted for indentation
-1
View File
@@ -1 +0,0 @@
setl ts=2 sw=2 ts=2 ai et
+28 -28
View File
@@ -1,33 +1,33 @@
CONFIG_PATH = vim.fn.stdpath('config')
DATA_PATH = vim.fn.stdpath('data')
CACHE_PATH = vim.fn.stdpath('cache')
P = vim.inspect
if vim.loader then
vim.loader.enable()
end
require('lv-globals')
vim.cmd('luafile '..CONFIG_PATH..'/settings.lua')
require('settings')
require('plugins')
require('utils')
require('pluginconfig')
require('autocommands')
require('keymappings')
require('colorscheme') -- This plugin must be required somewhere after nvimtree. Placing it before will break navigation keymappings
_G.dd = function(...)
require("util.debug").dump(...)
end
vim.print = _G.dd
-- TODO is there a way to do this without vimscript
vim.cmd('source '..CONFIG_PATH..'/vimscript/functions.vim')
require("config.lazy")
-- LSP
require('lsp')
--[[
require('lsp.css-ls')
require('lsp.docker-ls')
require('lsp.emmet-ls')
require('lsp.html-ls')
require('lsp.json-ls')
require('lsp.latex-ls')
require('lsp.python-ls')
require('lsp.rust-ls')
require('lsp.yaml-ls')
]]
-- CONFIG_PATH = vim.fn.stdpath('config')
-- DATA_PATH = vim.fn.stdpath('data')
-- CACHE_PATH = vim.fn.stdpath('cache')
-- P = vim.inspect
-- require('lv-globals')
-- vim.cmd('luafile '..CONFIG_PATH..'/settings.lua')
-- require('settings')
-- require('plugins')
-- require('utils')
-- require('pluginconfig')
-- require('autocommands')
-- require('keymappings')
-- require('colorscheme') -- This plugin must be required somewhere after nvimtree. Placing it before will break navigation keymappings
-- -- TODO is there a way to do this without vimscript
-- vim.cmd('source '..CONFIG_PATH..'/vimscript/functions.vim')
-- -- LSP
-- require('lsp')
+56
View File
@@ -0,0 +1,56 @@
{
"LazyVim": { "branch": "main", "commit": "a50f92f7550fb6e9f21c0852e6cb190e6fcd50f5" },
"LuaSnip": { "branch": "master", "commit": "f3b3d3446bcbfa62d638b1903ff00a78b2b730a1" },
"bufferline.nvim": { "branch": "main", "commit": "b15c6daf5a64426c69732b31a951f4e438cb6590" },
"catppuccin": { "branch": "main", "commit": "9703f227bfab20d04bcee62d2f08f1795723b4ae" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "00f50d4bb17b849bac62cb1b75368333c0a80c96" },
"dashboard-nvim": { "branch": "master", "commit": "413442b12d85315fc626c44a0ce4929b213ef604" },
"dressing.nvim": { "branch": "master", "commit": "6f212262061a2120e42da0d1e87326e8a41c0478" },
"flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" },
"friendly-snippets": { "branch": "main", "commit": "dbd45e9ba76d535e4cba88afa1b7aa43bb765336" },
"gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" },
"indent-blankline.nvim": { "branch": "master", "commit": "821a7acd88587d966f7e464b0b3031dfe7f5680c" },
"lazy.nvim": { "branch": "main", "commit": "28126922c9b54e35a192ac415788f202c3944c9f" },
"lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "7897c45e8f0f7fefe3b3ee00d8e89dc67a113e25" },
"mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
"mini.ai": { "branch": "main", "commit": "ee9446a17c160aba6a04ff22097389c41872c878" },
"mini.bufremove": { "branch": "main", "commit": "931a3bb514147d9e812767275c4beba6b779b1d3" },
"mini.comment": { "branch": "main", "commit": "a4b7e46deb9ad2feb8902cc5dbf087eced112ee5" },
"mini.indentscope": { "branch": "main", "commit": "cf07f19e718ebb0bcc5b00999083ce11c37b8d40" },
"mini.pairs": { "branch": "main", "commit": "04f58f2545ed80ac3b52dd4826e93f33e15b2af6" },
"mini.surround": { "branch": "main", "commit": "a1b590cc3b676512de507328d6bbab5e43794720" },
"neo-tree.nvim": { "branch": "v3.x", "commit": "f3941c57ec85d7bdb44fa53fd858fd80f159018f" },
"neoconf.nvim": { "branch": "main", "commit": "4ef6c6c5882e7e16209173fb8c47414202843384" },
"neodev.nvim": { "branch": "main", "commit": "bbe17de89345ce40725e721d347c596dc4a02b32" },
"noice.nvim": { "branch": "main", "commit": "bf67d70bd7265d075191e7812d8eb42b9791f737" },
"nui.nvim": { "branch": "main", "commit": "c3c7fd618dcb5a89e443a2e1033e7d11fdb0596b" },
"nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" },
"nvim-lint": { "branch": "master", "commit": "31be66c27214174a28fc092ffcf4bb3e8f6cfd43" },
"nvim-lspconfig": { "branch": "master", "commit": "1699ce10c3aaf861cfa0c1303fcd19d2ed93e7ad" },
"nvim-notify": { "branch": "master", "commit": "5371f4bfc1f6d3adf4fe9d62cd3a9d44356bfd15" },
"nvim-spectre": { "branch": "master", "commit": "3712ff0cdf4f9f877d9ca708d835a877d9a0abaf" },
"nvim-tree.lua": { "branch": "master", "commit": "030defdb6522f5f716d8201d20ca1a2baa57ca66" },
"nvim-treesitter": { "branch": "master", "commit": "d87074a06b3dfef0f8ed6bbf5953fca96abd312a" },
"nvim-treesitter-context": { "branch": "master", "commit": "fbeff2a60d073f73fef23a2c707e4f12c9c53359" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "7f00d94543f1fd37cab2afa2e9a6cd54e1c6b9ef" },
"nvim-ts-autotag": { "branch": "main", "commit": "531f48334c422222aebc888fd36e7d109cb354cd" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "7ab799a9792f7cf3883cf28c6a00ad431f3d382a" },
"nvim-web-devicons": { "branch": "master", "commit": "14ac5887110b06b89a96881d534230dac3ed134d" },
"persistence.nvim": { "branch": "main", "commit": "4982499c1636eac254b72923ab826ee7827b3084" },
"playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" },
"plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" },
"telescope-file-browser.nvim": { "branch": "master", "commit": "48ffb8de688a22942940f50411d5928631368848" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
"telescope.nvim": { "branch": "master", "commit": "b744cf59752aaa01561afb4223006de26f3836fd" },
"todo-comments.nvim": { "branch": "main", "commit": "833d8dd8b07eeda37a09e99460f72a02616935cb" },
"tokyonight.nvim": { "branch": "main", "commit": "610179f7f12db3d08540b6cc61434db2eaecbcff" },
"trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" },
"vim-illuminate": { "branch": "master", "commit": "305bf07b919ac526deb5193280379e2f8b599926" },
"vim-startuptime": { "branch": "master", "commit": "308b0088a864c4711a96e45b6734cf9294074f65" },
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
}
+9
View File
@@ -0,0 +1,9 @@
{
"extras": [
],
"news": {
"NEWS.md": "2123"
},
"version": 2
}
-76
View File
@@ -1,76 +0,0 @@
local utils = require('utils')
local auto_formatters = { }
local python_autoformat = {'BufWritePre', '*.py', 'lua vim.lsp.buf.format({async=false})'}
if O.python.autoformat then table.insert(auto_formatters, python_autoformat) end
local javascript_autoformat = {'BufWritePre', '*.js', 'lua vim.lsp.buf.format({async=false})'}
local javascriptreact_autoformat = {'BufWritePre', '*.jsx', 'lua vim.lsp.buf.format({async=false})'}
local typescript_autoformat = {'BufWritePre', '*.ts', 'lua vim.lsp.buf.format({async=false})'}
local typescriptreact_autoformat = {'BufWritePre', '*.tsx', 'lua vim.lsp.buf.format({async=false})'}
if O.tsserver.autoformat then
table.insert(auto_formatters, javascript_autoformat)
table.insert(auto_formatters, javascriptreact_autoformat)
table.insert(auto_formatters, typescript_autoformat)
table.insert(auto_formatters, typescriptreact_autoformat)
end
local lua_format = {'BufWritePre', '*.lua', 'lua vim.lsp.buf.format({async=false})'}
if O.lua.autoformat then table.insert(auto_formatters, lua_format) end
local json_format = {'BufWritePre', '*.json', 'lua vim.lsp.buf.format({async=false})'}
if O.json.autoformat then table.insert(auto_formatters, json_format) end
local ruby_format = {'BufWritePre', '*.rb', 'lua vim.lsp.buf.format({async=false})'}
if O.ruby.autoformat then table.insert(auto_formatters, ruby_format) end
local go_format = {'BufWritePre', '*.go', 'lua vim.lsp.buf.format({async=false})'}
if O.go.autoformat then table.insert(auto_formatters, go_format) end
utils.define_augroups({
_general_settings = {
{'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', timeout = 200})'},
{'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
{'BufRead', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
{'BufNewFile', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
{'VimLeavePre', '*', 'set title set titleold='},
{'FileType', 'qf', 'set nobuflisted'},
-- {'User', 'GoyoLeave', 'lua require(\'galaxyline\').disable_galaxyline()'},
-- {'User', 'GoyoEnter', 'lua require(\'galaxyline\').galaxyline_augroup()'},
},
_java = {
{'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'},
{'FileType', 'java', 'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>'}
},
_go = {
-- Go generally requires Tabs instead of spaces.
{'FileType', 'go', 'setlocal tabstop=4'},
{'FileType', 'go', 'setlocal shiftwidth=4'},
{'FileType', 'go', 'setlocal softtabstop=4'},
{'FileType', 'go', 'setlocal noexpandtab'},
},
_dashboard = {
-- seems to be nobuflisted that makes my stuff disapear will do more testing
{
'FileType', 'dashboard',
'setlocal nocursorline noswapfile synmaxcol& signcolumn=no norelativenumber nocursorcolumn nospell nolist nonumber bufhidden=wipe colorcolumn= foldcolumn=0 matchpairs= '
}, {'FileType', 'dashboard', 'set showtabline=0 | autocmd BufLeave <buffer> set showtabline=2'}
},
_markdown = {{'FileType', 'markdown', 'setlocal wrap'}, {'FileType', 'markdown', 'setlocal spell'}},
_solidity = {
{'BufWinEnter', '.sol', 'setlocal filetype=solidity'}, {'BufRead', '*.sol', 'setlocal filetype=solidity'},
{'BufNewFile', '*.sol', 'setlocal filetype=solidity'}
},
_gemini = {
{'BufWinEnter', '.gmi', 'setlocal filetype=markdown'}, {'BufRead', '*.gmi', 'setlocal filetype=markdown'},
{'BufNewFile', '*.gmi', 'setlocal filetype=markdown'}
},
_buffer_bindings = {
{'FileType', 'dashboard', 'nnoremap <silent> <buffer> q :q<CR>'},
{'FileType', 'lspinfo', 'nnoremap <silent> <buffer> q :q<CR>'},
{'FileType', 'floaterm', 'nnoremap <silent> <buffer> q :q<CR>'},
},
_auto_formatters = auto_formatters
})
+14
View File
@@ -0,0 +1,14 @@
-- Turn off paste mode when leaving insert
vim.api.nvim_create_autocmd("InsertLeave", {
pattern = "*",
command = "set nopaste",
})
-- Disable the concealing in some file formats
-- The default conceallevel is 3 in LazyVim
vim.api.nvim_create_autocmd("FileType", {
pattern = { "json", "jsonc", "markdown" },
callback = function()
vim.opt.conceallevel = 0
end,
})
+256
View File
@@ -0,0 +1,256 @@
local opts = {
mode = "n", -- NORMAL mode
prefix = "<leader>",
buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
silent = true, -- use `silent` when creating keymaps
noremap = true, -- use `noremap` when creating keymaps
nowait = false -- use `nowait` when creating keymaps
}
local mappings = {
-- ["/"] = "Comment",
-- ["c"] = "Close Buffer",
["e"] = "Explorer",
-- ["f"] = "Find File",
["h"] = "No Highlight",
a = {
name = "+Action",
a = { "<cmd>@:<cr>", "execute last command again" }
},
b = {
name = "+Buffer",
n = { "<cmd>BufferNext<cr>", "next buffer" },
p = { "<cmd>BufferPrevious<cr>", "previous buffer" },
q = { "<cmd>q<cr>", "quit" },
s = { "<cmd>w<cr>", "save" },
r = { "<cmd>e!<cr>", "reload" },
d = { "<cmd>BufferClose<cr>", "close buffer" },
z = { "<cmd>CommentToggle<CR>", "toggle comment" },
},
D = {
name = "+Diagnostics",
t = { "<cmd>TroubleToggle<cr>", "trouble" },
w = { "<cmd>TroubleToggle lsp_workspace_diagnostics<cr>", "workspace" },
d = { "<cmd>TroubleToggle lsp_document_diagnostics<cr>", "document" },
q = { "<cmd>TroubleToggle quickfix<cr>", "quickfix" },
l = { "<cmd>TroubleToggle loclist<cr>", "loclist" },
r = { "<cmd>TroubleToggle lsp_references<cr>", "references" },
},
d = {
name = "+Debug",
-- b = {"<cmd>DebugToggleBreakpoint<cr>", "Toggle Breakpoint"},
-- c = {"<cmd>DebugContinue<cr>", "Continue"},
-- i = {"<cmd>DebugStepInto<cr>", "Step Into"},
-- o = {"<cmd>DebugStepOver<cr>", "Step Over"},
-- r = {"<cmd>DebugToggleRepl<cr>", "Toggle Repl"},
-- s = {"<cmd>DebugStart<cr>", "Start"}
d = { "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<cr>", "show diagnostics" },
c = { "<cmd>lua require'dap'.continue()<cr>", "continue" },
b = { ':lua require"dap".toggle_breakpoint()<CR>', "Toggle Breadpoint" },
j = { ':lua require"dap".step_over()<CR>', "step over" },
k = { ':lua require"dap".step_out()<CR>', "step out" },
l = { ':lua require"dap".step_into()<CR>', "step into" },
--<c-h>', ':lua require"dap".continue()<CR>')
u = { ':lua require"dap".up()<CR>', "up" },
-- d = {':lua require"dap".down()<CR>', "down"},
_ = { ':lua require"dap".disconnect();require"dap".stop();require"dap".run_last()<CR>', "disconnect" },
--r = {':lua require"dap".repl.open({}, "vsplit")<CR><C-w>l', "repl open"},
i = { ':lua require"dap.ui.variables".visual_hover()<CR>', "visual_hover" },
--? = {':lua require"dap.ui.variables".scopes()<CR>',"scopes"},
-- e = {':lua require"dap".set_exception_breakpoints({"all"})<CR>',"esception bp"},
-- a = {':lua require"debugHelper".attach()<CR>',"attach"},
-- A = {':lua require"debugHelper".attachToRemote()<CR>',"attach to remote"},
s = { ':lua local widgets=require"dap.ui.widgets";widgets.centered_float(widgets.scopes)<CR>', "centered_float" },
},
f = {
name = "+File",
m = { "<cmd>lua require'utils'.open_md()<cr>", "open a markdown file in vscode" },
s = { "<cmd>w<cr>", "save file" },
t = { "<cmd>NvimTreeToggle<cr>", "toggle nvim tree" },
r = { "<cmd>RnvimrToggle<cr>", "toggle rnvimr" },
y = { "<cmd>lua require'utils'.yank_filepath()<cr>", "copy the file path" },
d = { "<cmd>lua require'utils'.yank_file_dir()<cr>", "copy the file path" },
l = { "<cmd>NvimTreeFindFile<CR>", "find file" },
-- T = {"<cmd>let @+ = 'go test -v -run='+expand('<cword>')<cr>", "get current word in go test"},
},
g = {
name = "+Git",
m = {"<cmd>Gvdiff master:%<cr>", "Diff with master"},
j = { "<cmd>lua require 'gitsigns'.next_hunk()<cr>", "Next Hunk" },
k = { "<cmd>lua require 'gitsigns'.prev_hunk()<cr>", "Prev Hunk" },
l = { "<cmd>lua require 'gitsigns'.blame_line()<cr>", "Blame" },
p = { "<cmd>lua require 'gitsigns'.preview_hunk()<cr>", "Preview Hunk" },
r = { "<cmd>lua require 'gitsigns'.reset_hunk()<cr>", "Reset Hunk" },
R = { "<cmd>lua require 'gitsigns'.reset_buffer()<cr>", "Reset Buffer" },
s = { "<cmd>lua require 'gitsigns'.stage_hunk()<cr>", "Stage Hunk" },
S = { "<cmd>lua require 'gitsigns'.stage_buffer()<cr>", "Stage Buffer" },
u = {
"<cmd>lua require 'gitsigns'.undo_stage_hunk()<cr>",
"Undo Stage Hunk",
},
o = { "<cmd>Telescope git_status<cr>", "Open changed file" },
b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" },
c = { "<cmd>Telescope git_commits<cr>", "Checkout commit" },
C = {
"<cmd>Telescope git_bcommits<cr>",
"Checkout commit(for current file)",
},
d = {
"<cmd>Gitsigns diffthis HEAD<cr>",
"Git Diff",
},
},
l = {
name = "+Language",
a = { "<cmd>Lspsaga code_action<cr>", "Code Action" },
A = { "<cmd>Lspsaga range_code_action<cr>", "Selected Action" },
d = { "<cmd>Telescope lsp_document_diagnostics<cr>", "Document Diagnostics" },
D = { "<cmd>Telescope lsp_workspace_diagnostics<cr>", "Workspace Diagnostics" },
f = { "<cmd>LspFormatting<cr>", "Format" },
F = { "<cmd>Lspsaga lsp_finder<cr>", "LSP Finder" },
-- i = {"<cmd>Telescope lsp_implementations<cr>", "implement"},
i = { "<cmd>lua vim.lsp.buf.implementation()<cr>", "implement" },
l = { "<cmd>lua vim.lsp.buf.hover()<cr>", "hover" },
L = { "<cmd>Lspsaga show_line_diagnostics<cr>", "Line Diagnostics" },
k = { "<cmd>: LspRestart<cr>", "restart lsp server" },
n = { "<cmd>lua vim.lsp.diagnostic.goto_next()<cr>", "next diagnostic" },
o = { "<cmd>: SymbolsOutline<cr>", "symbols outline" },
p = { "<cmd>lua vim.lsp.diagnostic.goto_prev()<cr>", "prev diagnostic" },
P = { "<cmd>Lspsaga preview_definition<cr>", "Preview Definition" },
q = { "<cmd>Telescope quickfix<cr>", "Quickfix" },
r = { "<cmd>lua vim.lsp.buf.references()<cr>", "references" },
R = { "<cmd>Lspsaga rename<cr>", "Rename" },
t = { "<cmd>LspTypeDefinition<cr>", "Type Definition" },
x = { "<cmd>cclose<cr>", "Close Quickfix" },
s = { "<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols" },
S = { "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>", "Workspace Symbols" },
z = { "<cmd>LspInfo<cr>", "Info" },
[","] = { "<cmd>LspInstallInfo<cr>", "LSP servers" }
},
p = {
name = "Packer",
c = { "<cmd>PackerCompile<cr>", "Compile" },
i = { "<cmd>PackerInstall<cr>", "Install" },
s = { "<cmd>PackerSync<cr>", "Sync" },
S = { "<cmd>PackerStatus<cr>", "Status" },
u = { "<cmd>PackerUpdate<cr>", "Update" },
},
q = {
name = "quit",
q = { "<cmd>qall<cr>", "quit" },
},
s = {
name = "+Search",
b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" },
-- c = {"<cmd>Telescope colorscheme<cr>", "Colorscheme"},
c = { "<cmd>:nohl<cr>", "no highlight" },
d = { "<cmd>Telescope lsp_document_diagnostics<cr>", "Document Diagnostics" },
D = { "<cmd>Telescope lsp_workspace_diagnostics<cr>", "Workspace Diagnostics" },
f = { "<cmd>Fzflua files<cr>", "Find File" },
m = { "<cmd>Telescope marks<cr>", "Marks" },
M = { "<cmd>Telescope man_pages<cr>", "Man Pages" },
r = { "<cmd>FzfLua oldfiles<cr>", "Open Recent File" },
R = { "<cmd>Telescope registers<cr>", "Registers" },
t = { "<cmd>FzfLua live_grep<cr>", "Text" },
["#"] = { "<cmd>FzfLua grep_cword<cr>", "Search word under cursor" },
},
S = {
name = "+Session",
s = { "<cmd>SessionSave<cr>", "Save Session" },
l = { "<cmd>SessionLoad<cr>", "Load Session" },
},
t = {
name = "+Test",
a = { "<cmd>TestSuite -v -cover<cr>", "TestSuite" },
t = { "<cmd>lua require('neotest').run.run() <cr>", "TestNearest" },
f = { '<cmd>lua require("neotest").run.run(vim.fn.expand("%"))<cr>', "TestFile" },
c = { "<cmd>GoCover<cr>", "go coverage" },
C = { "<cmd>GoCoverClear<cr>", "go coverage clear" },
b = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "set break point" },
r = { "<cmd>lua require'dap'.continue()<cr>", "continue" },
},
-- extras
z = {
name = "+Zen",
s = { "<cmd>TZBottom<cr>", "toggle status line" },
t = { "<cmd>TZTop<cr>", "toggle tab bar" },
z = { "<cmd>TZAtaraxis<cr>", "toggle zen" },
}
}
local wk = require("which-key")
wk.register(mappings, opts)
local keymap = vim.keymap
local opts = { noremap = true, silent = true }
-- no hl
keymap.set('n', '<Leader>h', ':set hlsearch!<CR>', { noremap = true, silent = true })
-- explorer
keymap.set('n', '<Leader>e', ':NvimTreeToggle<CR>', { noremap = true, silent = true })
-- telescope
-- keymap.set('n', '<C-p>', ":lua require'telescope.builtin'.find_files()<CR>", {noremap = true, silent = true})
keymap.set('n', '<C-p>', ":FzfLua files<CR>", { noremap = true, silent = true })
-- dashboard
keymap.set('n', '<Leader>;', ':Dashboard<CR>', { noremap = true, silent = true })
-- Comments
keymap.set("n", "<Leader>b/", ":CommentToggle<CR>", { noremap = true, silent = true })
keymap.set("v", "<Leader>b/", ":CommentToggle<CR>", { noremap = true, silent = true })
-- close buffer
keymap.set("n", "<leader>c", ":BufferClose<CR>", { noremap = true, silent = true })
keymap.set('n', '-', ':RnvimrToggle<CR>', opts )
-- better window movement
keymap.set('n', '<C-h>', '<C-w>h', { silent = true })
keymap.set('n', '<C-j>', '<C-w>j', { silent = true })
keymap.set('n', '<C-k>', '<C-w>k', { silent = true })
keymap.set('n', '<C-l>', '<C-w>l', { silent = true })
-- better edit
keymap.set('n', 'Y', 'y$', {})
-- resize with arrows
keymap.set('n', '<C-Up>', ':resize -2<CR>', { silent = true })
keymap.set('n', '<C-Down>', ':resize +2<CR>', { silent = true })
keymap.set('n', '<C-Left>', ':vertical resize -2<CR>', { silent = true })
keymap.set('n', '<C-Right>', ':vertical resize +2<CR>', { silent = true })
-- better indenting
keymap.set('v', '<', '<gv', { noremap = true, silent = true })
keymap.set('v', '>', '>gv', { noremap = true, silent = true })
-- I hate escape
keymap.set('i', 'jk', '<ESC>', { noremap = true, silent = true })
keymap.set('i', 'kj', '<ESC>', { noremap = true, silent = true })
keymap.set('i', 'jj', '<ESC>', { noremap = true, silent = true })
-- Tab switch buffer
keymap.set('n', '<TAB>', ':bnext<CR>', { noremap = true, silent = true })
keymap.set('n', '<S-TAB>', ':bprevious<CR>', { noremap = true, silent = true })
-- Move selected line / block of text in visual mode
keymap.set('x', 'K', ':move \'<-2<CR>gv-gv', { noremap = true, silent = true })
keymap.set('x', 'J', ':move \'>+1<CR>gv-gv', { noremap = true, silent = true })
keymap.set('', '<C-q>', ':call QuickFixToggle()<CR>', { noremap = true, silent = true })
-- -- Better nav for omnicomplete
-- vim.cmd('inoremap <expr> <c-j> (\"\\<C-n>\")')
-- vim.cmd('inoremap <expr> <c-k> (\"\\<C-p>\")')
-- vim.cmd('vnoremap p "0p')
-- vim.cmd('vnoremap P "0P')
+46
View File
@@ -0,0 +1,46 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
-- bootstrap lazy.nvim
-- stylua: ignore
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
require("lazy").setup({
spec = {
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- import any extras modules here
-- { import = "lazyvim.plugins.extras.lang.typescript" },
-- { import = "lazyvim.plugins.extras.lang.json" },
-- { import = "lazyvim.plugins.extras.ui.mini-animate" },
-- import/override with your plugins
{ import = "plugins" },
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
lazy = false,
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
-- have outdated releases, which may break your Neovim install.
version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver
},
install = { colorscheme = { "tokyonight", "habamax" } },
checker = { enabled = true }, -- automatically check for plugin updates
performance = {
rtp = {
-- disable some rtp plugins
disabled_plugins = {
"gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})
+56
View File
@@ -0,0 +1,56 @@
vim.cmd('set iskeyword+=-') -- treat dash separated words as a word text object"
vim.cmd('set shortmess+=c') -- Don't pass messages to |ins-completion-menu|.
vim.cmd('set inccommand=split') -- Make substitution work in realtime
vim.o.hidden = true -- Required to keep multiple buffers open multiple buffers
vim.o.title = true
TERMINAL = vim.fn.expand('$TERMINAL')
vim.cmd('let &titleold="'..TERMINAL..'"')
vim.o.titlestring="%<%F%=%l/%L - nvim"
vim.wo.wrap = true -- Display long lines as just one line
vim.cmd('set whichwrap+=<,>,[,],h,l') -- move to next line with theses keys
vim.cmd('syntax on') -- syntax highlighting
vim.o.pumheight = 10 -- Makes popup menu smaller
vim.o.fileencoding = "utf-8" -- The encoding written to file
vim.o.cmdheight = 2 -- More space for displaying messages
vim.cmd('set colorcolumn=99999') -- fix indentline for now
vim.o.mouse = "a" -- Enable your mouse
vim.o.splitbelow = true -- Horizontal splits will automatically be below
vim.o.termguicolors = true -- set term gui colors most terminals support this
vim.o.splitright = true -- Vertical splits will automatically be to the right
-- vim.o.t_Co = "256" -- Support 256 colors
vim.o.conceallevel = 0 -- So that I can see `` in markdown files
-- vim.cmd('set ts=4') -- Insert 2 spaces for a tab
-- vim.cmd('set sw=4') -- Change the number of space characters inserted for indentation
-- vim.cmd('set expandtab') -- Converts tabs to spaces
vim.bo.smartindent = true -- Makes indenting smart
vim.wo.number = true -- set numbered lines
vim.wo.relativenumber = true -- set relative number
vim.wo.cursorline = true -- Enable highlighting of the current line
vim.o.showtabline = 2 -- Always show tabs
vim.o.showmode = false -- We don't need to see things like -- INSERT -- anymore
vim.o.backup = false -- This is recommended by coc
vim.o.writebackup = false -- This is recommended by coc
vim.wo.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
vim.o.updatetime = 300 -- Faster completion
vim.o.timeoutlen = 100 -- By default timeoutlen is 1000 ms
vim.o.clipboard = "unnamedplus" -- Copy paste between vim and everything else
vim.cmd('filetype plugin on') -- filetype detection
-- vim.o.guifont = "JetBrainsMono\\ Nerd\\ Font\\ Mono:h18"
-- vim.o.guifont = "Hack\\ Nerd\\ Font\\ Mono"
-- vim.o.guifont = "SauceCodePro Nerd Font:h17"
vim.o.guifont = "FiraCode Nerd Font:h17"
-- vim.o.guifont = "JetBrains\\ Mono\\ Regular\\ Nerd\\ Font\\ Complete"
vim.g.vim_markdown_folding_disabled = 1
vim.g.vimspector_enable_mappings = 'HUMAN'
vim.g['test#go#rspec#options'] = { nearest= '--v', suite= '--v' }
-- git blame
vim.cmd('highlight default link gitblame SpecialComment')
vim.g.gitblame_enabled = 0
-- last position jump
vim.cmd([[
autocmd BufReadPost * if line("'\"") >= 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
]])
-81
View File
@@ -1,81 +0,0 @@
vim.api.nvim_set_keymap('n', '-', ':RnvimrToggle<CR>', { noremap = true, silent = true })
-- better window movement
vim.api.nvim_set_keymap('n', '<C-h>', '<C-w>h', { silent = true })
vim.api.nvim_set_keymap('n', '<C-j>', '<C-w>j', { silent = true })
vim.api.nvim_set_keymap('n', '<C-k>', '<C-w>k', { silent = true })
vim.api.nvim_set_keymap('n', '<C-l>', '<C-w>l', { silent = true })
-- better edit
vim.api.nvim_set_keymap('n', 'Y', 'y$', {})
-- TODO fix this
-- Terminal window navigation
-- vim.cmd([[
-- tnoremap <C-h> <C-\><C-N><C-w>h
-- tnoremap <C-j> <C-\><C-N><C-w>j
-- tnoremap <C-k> <C-\><C-N><C-w>k
-- tnoremap <C-l> <C-\><C-N><C-w>l
-- inoremap <C-h> <C-\><C-N><C-w>h
-- inoremap <C-j> <C-\><C-N><C-w>j
-- inoremap <C-k> <C-\><C-N><C-w>k
-- inoremap <C-l> <C-\><C-N><C-w>l
-- tnoremap <Esc> <C-\><C-n>
-- ]])
-- TODO fix this
-- resize with arrows
vim.api.nvim_set_keymap('n', '<C-Up>', ':resize -2<CR>', { silent = true })
vim.api.nvim_set_keymap('n', '<C-Down>', ':resize +2<CR>', { silent = true })
vim.api.nvim_set_keymap('n', '<C-Left>', ':vertical resize -2<CR>', { silent = true })
vim.api.nvim_set_keymap('n', '<C-Right>', ':vertical resize +2<CR>', { silent = true })
-- better indenting
vim.api.nvim_set_keymap('v', '<', '<gv', { noremap = true, silent = true })
vim.api.nvim_set_keymap('v', '>', '>gv', { noremap = true, silent = true })
-- I hate escape
vim.api.nvim_set_keymap('i', 'jk', '<ESC>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('i', 'kj', '<ESC>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('i', 'jj', '<ESC>', { noremap = true, silent = true })
-- Tab switch buffer
vim.api.nvim_set_keymap('n', '<TAB>', ':bnext<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<S-TAB>', ':bprevious<CR>', { noremap = true, silent = true })
-- Move selected line / block of text in visual mode
vim.api.nvim_set_keymap('x', 'K', ':move \'<-2<CR>gv-gv', { noremap = true, silent = true })
vim.api.nvim_set_keymap('x', 'J', ':move \'>+1<CR>gv-gv', { noremap = true, silent = true })
-- Better nav for omnicomplete
vim.cmd('inoremap <expr> <c-j> (\"\\<C-n>\")')
vim.cmd('inoremap <expr> <c-k> (\"\\<C-p>\")')
vim.cmd('vnoremap p "0p')
vim.cmd('vnoremap P "0P')
-- vim.api.nvim_set_keymap('v', 'p', '"0p', {silent = true})
-- vim.api.nvim_set_keymap('v', 'P', '"0P', {silent = true})
-- vim.cmd('inoremap <expr> <TAB> (\"\\<C-n>\")')
-- vim.cmd('inoremap <expr> <S-TAB> (\"\\<C-p>\")')
-- vim.api.nvim_set_keymap('i', '<C-TAB>', 'compe#complete()', {noremap = true, silent = true, expr = true})
-- vim.cmd([[
-- map p <Plug>(miniyank-autoput)
-- map P <Plug>(miniyank-autoPut)
-- map <leader>n <Plug>(miniyank-cycle)
-- map <leader>N <Plug>(miniyank-cycleback)
-- ]])
-- Toggle the QuickFix window
vim.api.nvim_set_keymap('', '<C-q>', ':call QuickFixToggle()<CR>', { noremap = true, silent = true })
-- nvim-compe key map
-- vim.cmd('inoremap <silent><expr> <C-Space> compe#complete()')
-- vim.cmd("inoremap <silent><expr> <CR> compe#confirm('<CR>')")
-- vim.cmd("inoremap <silent><expr> <C-e> compe#close('<C-e>')")
-- vim.cmd("inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })")
-- vim.cmd("inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })")
+225
View File
@@ -0,0 +1,225 @@
local function my_on_attach(bufnr)
local api = require "nvim-tree.api"
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
-- default mappings
api.config.mappings.default_on_attach(bufnr)
-- custom mappings
vim.keymap.set('n', '<C-t>', api.tree.change_root_to_parent, opts('Up'))
vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help'))
vim.keymap.set('n', 'l', api.node.open.edit, opts('Edit'))
vim.keymap.set('n', 'h', api.node.navigate.parent_close, opts('Parent Close'))
vim.keymap.set('n', 's', api.node.open.horizontal, opts('Horizontal Split'))
vim.keymap.set('n', 'v', api.node.open.vertical, opts('Vertical Split'))
end
vim.g.nvim_tree_indent_markers = 1 -- "0 by default, this option shows indent markers when folders are open
vim.g.nvim_tree_auto_ignore_ft = 'startify' --empty by default, don't auto open tree on specific filetypes.
vim.g.nvim_tree_icons = {
default = '',
symlink = '',
git = {unstaged = "", staged = "✓", unmerged = "", renamed = "➜", untracked = ""},
folder = {default = "", open = "", empty = "", empty_open = "", symlink = ""}
}
return {
{
'nvim-tree/nvim-tree.lua',
dependencies = {
'nvim-tree/nvim-web-devicons', -- optional
},
opts = {
on_attach = my_on_attach,
disable_netrw = true,
hijack_netrw = true,
--auto_close = false,
filters = {
dotfiles = false,
custom = {}
},
git = {
enable = true,
ignore = false,
timeout = 500,
},
update_focused_file = {
-- enables the feature
enable = true,
-- update the root directory of the tree to the one of the folder containing the file if the file is not under the current root directory
-- only relevant when `update_focused_file.enable` is true
update_cwd = false,
-- list of buffer names / filetypes that will not update the cwd if the file isn't found under the current root directory
-- only relevant when `update_focused_file.update_cwd` is true and `update_focused_file.enable` is true
ignore_list = {}
},
},
},
{
"telescope.nvim",
dependencies = {
{
"nvim-telescope/telescope-fzf-native.nvim",
build = "make",
},
"nvim-telescope/telescope-file-browser.nvim",
},
keys = {
{
"<leader>fP",
function()
require("telescope.builtin").find_files({
cwd = require("lazy.core.config").options.root,
})
end,
desc = "Find Plugin File",
},
{
";f",
function()
local builtin = require("telescope.builtin")
builtin.find_files({
no_ignore = false,
hidden = true,
})
end,
desc = "Lists files in your current working directory, respects .gitignore",
},
{
";r",
function()
local builtin = require("telescope.builtin")
builtin.live_grep({
additional_args = { "--hidden" },
})
end,
desc = "Search for a string in your current working directory and get results live as you type, respects .gitignore",
},
{
"\\\\",
function()
local builtin = require("telescope.builtin")
builtin.buffers()
end,
desc = "Lists open buffers",
},
{
";t",
function()
local builtin = require("telescope.builtin")
builtin.help_tags()
end,
desc = "Lists available help tags and opens a new window with the relevant help info on <cr>",
},
{
";;",
function()
local builtin = require("telescope.builtin")
builtin.resume()
end,
desc = "Resume the previous telescope picker",
},
{
";e",
function()
local builtin = require("telescope.builtin")
builtin.diagnostics()
end,
desc = "Lists Diagnostics for all open buffers or a specific buffer",
},
{
";s",
function()
local builtin = require("telescope.builtin")
builtin.treesitter()
end,
desc = "Lists Function names, variables, from Treesitter",
},
{
"sf",
function()
local telescope = require("telescope")
local function telescope_buffer_dir()
return vim.fn.expand("%:p:h")
end
telescope.extensions.file_browser.file_browser({
path = "%:p:h",
cwd = telescope_buffer_dir(),
respect_gitignore = false,
hidden = true,
grouped = true,
previewer = false,
initial_mode = "normal",
layout_config = { height = 40 },
})
end,
desc = "Open File Browser with the path of the current buffer",
},
},
config = function(_, opts)
local telescope = require("telescope")
local actions = require("telescope.actions")
local fb_actions = require("telescope").extensions.file_browser.actions
opts.defaults = vim.tbl_deep_extend("force", opts.defaults, {
wrap_results = true,
layout_strategy = "horizontal",
layout_config = { prompt_position = "top" },
sorting_strategy = "ascending",
winblend = 0,
mappings = {
n = {},
},
})
opts.pickers = {
diagnostics = {
theme = "ivy",
initial_mode = "normal",
layout_config = {
preview_cutoff = 9999,
},
},
}
opts.extensions = {
file_browser = {
theme = "dropdown",
-- disables netrw and use telescope-file-browser in its place
hijack_netrw = true,
mappings = {
-- your custom insert mode mappings
["n"] = {
-- your custom normal mode mappings
["N"] = fb_actions.create,
["h"] = fb_actions.goto_parent_dir,
["/"] = function()
vim.cmd("startinsert")
end,
["<C-u>"] = function(prompt_bufnr)
for i = 1, 10 do
actions.move_selection_previous(prompt_bufnr)
end
end,
["<C-d>"] = function(prompt_bufnr)
for i = 1, 10 do
actions.move_selection_next(prompt_bufnr)
end
end,
["<PageUp>"] = actions.preview_scrolling_up,
["<PageDown>"] = actions.preview_scrolling_down,
},
},
},
}
telescope.setup(opts)
require("telescope").load_extension("fzf")
require("telescope").load_extension("file_browser")
end,
},
}
+157
View File
@@ -0,0 +1,157 @@
return {
-- tools
{
"williamboman/mason.nvim",
opts = function(_, opts)
vim.list_extend(opts.ensure_installed, {
"stylua",
"selene",
"luacheck",
"shellcheck",
"shfmt",
"tailwindcss-language-server",
"typescript-language-server",
"css-lsp",
})
end,
},
-- lsp servers
{
"neovim/nvim-lspconfig",
opts = {
inlay_hints = { enabled = false },
---@type lspconfig.options
servers = {
cssls = {},
tailwindcss = {
root_dir = function(...)
return require("lspconfig.util").root_pattern(".git")(...)
end,
},
tsserver = {
root_dir = function(...)
return require("lspconfig.util").root_pattern(".git")(...)
end,
single_file_support = false,
settings = {
typescript = {
inlayHints = {
includeInlayParameterNameHints = "literal",
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = false,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
},
},
javascript = {
inlayHints = {
includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
},
},
},
},
html = {},
yamlls = {
settings = {
yaml = {
keyOrdering = false,
},
},
},
lua_ls = {
-- enabled = false,
single_file_support = true,
settings = {
Lua = {
workspace = {
checkThirdParty = false,
},
completion = {
workspaceWord = true,
callSnippet = "Both",
},
misc = {
parameters = {
-- "--log-level=trace",
},
},
hint = {
enable = true,
setType = false,
paramType = true,
paramName = "Disable",
semicolon = "Disable",
arrayIndex = "Disable",
},
doc = {
privateName = { "^_" },
},
type = {
castNumberToInteger = true,
},
diagnostics = {
disable = { "incomplete-signature-doc", "trailing-space" },
-- enable = false,
groupSeverity = {
strong = "Warning",
strict = "Warning",
},
groupFileStatus = {
["ambiguity"] = "Opened",
["await"] = "Opened",
["codestyle"] = "None",
["duplicate"] = "Opened",
["global"] = "Opened",
["luadoc"] = "Opened",
["redefined"] = "Opened",
["strict"] = "Opened",
["strong"] = "Opened",
["type-check"] = "Opened",
["unbalanced"] = "Opened",
["unused"] = "Opened",
},
unusedLocalExclude = { "_*" },
},
format = {
enable = false,
defaultConfig = {
indent_style = "space",
indent_size = "2",
continuation_indent_size = "2",
},
},
},
},
},
gopls = {
setup = {
cmd = { "gopls", "serve" }, -- use cmd in path, I can update it easily
settings = {
gopls = {
analyses = {
nilness = true,
unusedparams = true,
unusedwrite = true,
useany = true,
},
staticcheck = false
}
},
root_dir = require 'lspconfig'.util.root_pattern(".git", "go.mod", "go.work"),
init_options = { usePlaceholders = true, completeUnimported = true },
},
},
},
setup = {},
},
},
}
+67
View File
@@ -0,0 +1,67 @@
return {
{ "nvim-treesitter/playground", cmd = "TSPlaygroundToggle" },
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = {
"astro",
"cmake",
"cpp",
"css",
"fish",
"gitignore",
"go",
"graphql",
"http",
"java",
"php",
"rust",
"scss",
"sql",
"svelte",
},
-- matchup = {
-- enable = true,
-- },
-- https://github.com/nvim-treesitter/playground#query-linter
query_linter = {
enable = true,
use_virtual_text = true,
lint_events = { "BufWrite", "CursorHold" },
},
playground = {
enable = true,
disable = {},
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
persist_queries = true, -- Whether the query persists across vim sessions
keybindings = {
toggle_query_editor = "o",
toggle_hl_groups = "i",
toggle_injected_languages = "t",
toggle_anonymous_nodes = "a",
toggle_language_display = "I",
focus_language = "f",
unfocus_language = "F",
update = "R",
goto_node = "<cr>",
show_help = "?",
},
},
},
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
-- MDX
vim.filetype.add({
extension = {
mdx = "mdx",
},
})
vim.treesitter.language.register("markdown", "mdx")
end,
},
}
+158
View File
@@ -0,0 +1,158 @@
-- selene: allow(global_usage)
local M = {}
function M.get_loc()
local me = debug.getinfo(1, "S")
local level = 2
local info = debug.getinfo(level, "S")
while info and (info.source == me.source or info.source == "@" .. vim.env.MYVIMRC or info.what ~= "Lua") do
level = level + 1
info = debug.getinfo(level, "S")
end
info = info or me
local source = info.source:sub(2)
source = vim.loop.fs_realpath(source) or source
return source .. ":" .. info.linedefined
end
---@param value any
---@param opts? {loc:string}
function M._dump(value, opts)
opts = opts or {}
opts.loc = opts.loc or M.get_loc()
if vim.in_fast_event() then
return vim.schedule(function()
M._dump(value, opts)
end)
end
opts.loc = vim.fn.fnamemodify(opts.loc, ":~:.")
local msg = vim.inspect(value)
vim.notify(msg, vim.log.levels.INFO, {
title = "Debug: " .. opts.loc,
on_open = function(win)
vim.wo[win].conceallevel = 3
vim.wo[win].concealcursor = ""
vim.wo[win].spell = false
local buf = vim.api.nvim_win_get_buf(win)
if not pcall(vim.treesitter.start, buf, "lua") then
vim.bo[buf].filetype = "lua"
end
end,
})
end
function M.dump(...)
local value = { ... }
if vim.tbl_isempty(value) then
value = nil
else
value = vim.tbl_islist(value) and vim.tbl_count(value) <= 1 and value[1] or value
end
M._dump(value)
end
function M.extmark_leaks()
local nsn = vim.api.nvim_get_namespaces()
local counts = {}
for name, ns in pairs(nsn) do
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
local count = #vim.api.nvim_buf_get_extmarks(buf, ns, 0, -1, {})
if count > 0 then
counts[#counts + 1] = {
name = name,
buf = buf,
count = count,
ft = vim.bo[buf].ft,
}
end
end
end
table.sort(counts, function(a, b)
return a.count > b.count
end)
dd(counts)
end
function estimateSize(value, visited)
if value == nil then
return 0
end
local bytes = 0
-- initialize the visited table if not already done
--- @type table<any, true>
visited = visited or {}
-- handle already-visited value to avoid infinite recursion
if visited[value] then
return 0
else
visited[value] = true
end
if type(value) == "boolean" or value == nil then
bytes = 4
elseif type(value) == "number" then
bytes = 8
elseif type(value) == "string" then
bytes = string.len(value) + 24
elseif type(value) == "function" then
bytes = 32 -- base size for a function
-- add size of upvalues
local i = 1
while true do
local name, val = debug.getupvalue(value, i)
if not name then
break
end
bytes = bytes + estimateSize(val, visited)
i = i + 1
end
elseif type(value) == "table" then
bytes = 40 -- base size for a table entry
for k, v in pairs(value) do
bytes = bytes + estimateSize(k, visited) + estimateSize(v, visited)
end
local mt = debug.getmetatable(value)
if mt then
bytes = bytes + estimateSize(mt, visited)
end
end
return bytes
end
function M.module_leaks(filter)
local sizes = {}
for modname, mod in pairs(package.loaded) do
if not filter or modname:match(filter) then
local root = modname:match("^([^%.]+)%..*$") or modname
-- root = modname
sizes[root] = sizes[root] or { mod = root, size = 0 }
sizes[root].size = sizes[root].size + estimateSize(mod) / 1024 / 1024
end
end
sizes = vim.tbl_values(sizes)
table.sort(sizes, function(a, b)
return a.size > b.size
end)
dd(sizes)
end
function M.get_upvalue(func, name)
local i = 1
while true do
local n, v = debug.getupvalue(func, i)
if not n then
break
end
if n == name then
return v
end
i = i + 1
end
end
return M
-9
View File
@@ -1,9 +0,0 @@
!#/bin/bash
cd ~
sudo rm -r neovim
git clone https://github.com/neovim/neovim
cd neovim
sudo make CMAKE_BUILD_TYPE=Release install
cd ~
sudo rm -r neovim
-28
View File
@@ -1,28 +0,0 @@
#!/usr/bin/env bash
# NOTE:
# This doesn't work as is on Windows. You'll need to create an equivalent `.bat` file instead
#
# NOTE:
# If you're not using Linux you'll need to adjust the `-configuration` option
# to point to the `config_mac' or `config_win` folders depending on your system.
JAR="$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/plugins/org.eclipse.equinox.launcher_*.jar"
GRADLE_HOME=$HOME/gradle $HOME/.sdkman/candidates/java/current/bin/java \
-Declipse.application=org.eclipse.jdt.ls.core.id1 \
-Dosgi.bundles.defaultStartLevel=4 \
-Declipse.product=org.eclipse.jdt.ls.core.product \
-Dlog.protocol=true \
-Dlog.level=ALL \
-javaagent:/usr/local/share/lombok/lombok.jar \
-Xms1g \
-Xmx2G \
-jar $(echo "$JAR") \
-configuration "$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/config_linux" \
-data "${1:-$HOME/workspace}" \
--add-modules=ALL-SYSTEM \
--add-opens java.base/java.util=ALL-UNNAMED \
--add-opens java.base/java.lang=ALL-UNNAMED
# for older java versions if you wanna use lombok
# -Xbootclasspath/a:/usr/local/share/lombok/lombok.jar \
-29
View File
@@ -1,29 +0,0 @@
#!/usr/bin/env bash
# NOTE:
# This doesn't work as is on Windows. You'll need to create an equivalent `.bat` file instead
#
# NOTE:
# If you're not using Linux you'll need to adjust the `-configuration` option
# to point to the `config_mac' or `config_win` folders depending on your system.
JAR="$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/plugins/org.eclipse.equinox.launcher_*.jar"
GRADLE_HOME=$HOME/gradle $HOME/.sdkman/candidates/java/current/bin/java \
-Declipse.application=org.eclipse.jdt.ls.core.id1 \
-Dosgi.bundles.defaultStartLevel=4 \
-Declipse.product=org.eclipse.jdt.ls.core.product \
-Dlog.protocol=true \
-Dlog.level=ALL \
-javaagent:/usr/local/share/lombok/lombok.jar \
-Xms1g \
-Xmx2G \
-jar $(echo "$JAR") \
-configuration "$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/config_mac" \
-data "${1:-$HOME/workspace}" \
--add-modules=ALL-SYSTEM \
--add-opens java.base/java.util=ALL-UNNAMED \
--add-opens java.base/java.lang=ALL-UNNAMED
# for older java versions if you wanna use lombok
# -Xbootclasspath/a:/usr/local/share/lombok/lombok.jar \
-2
View File
@@ -1,2 +0,0 @@
#!/bin/bash
nvim -u ~/.config/nvcode/init.lua
-73
View File
@@ -1,73 +0,0 @@
command! LspCodeAction lua require 'lv-utils'.code_action()
command! LspDeclaration lua require 'lv-utils'.declaration()
command! LspDefinition lua require 'lv-utils'.definition()
command! LspDocumentSymbol lua require 'lv-utils'.document_symbol()
command! LspFormatting lua require 'lv-utils'.formatting()
command! LspFormattingSync lua require 'lv-utils'.formatting_sync()
command! LspHover lua require 'lv-utils'.hover()
command! LspImplementation lua require 'lv-utils'.implementation()
command! LspRangeCodeAction lua require 'lv-utils'.range_code_action()
command! LspRangeFormatting lua require 'lv-utils'.range_formatting()
command! LspReferences lua require 'lv-utils'.references()
command! LspRename lua require 'lv-utils'.rename()
command! LspTypeDefinition lua require 'lv-utils'.type_definition()
command! LspWorkspaceSymbol lua require 'lv-utils'.workspace_symbol()
command! LspGotoNext lua require 'lv-utils'.goto_next()
command! LspGotoPrev lua require 'lv-utils'.goto_prev()
command! LspShowLineDiagnostics lua require 'lv-utils'.show_line_diagnostics()
command! NextHunk lua require 'lv-utils'.next_hunk()
command! PrevHunk lua require 'lv-utils'.prev_hunk()
command! StageHunk lua require 'lv-utils'.stage_hunk()
command! UndoStageHunk lua require 'lv-utils'.undo_stage_hunk()
command! ResetHunk lua require 'lv-utils'.reset_hunk()
command! ResetBuffer lua require 'lv-utils'.reset_buffer()
command! PreviewHunk lua require 'lv-utils'.preview_hunk()
command! BlameLine lua require 'lv-utils'.blame_line()
command! W noa w
" Debugging
command! DebugToggleBreakpoint lua require'dap'.toggle_breakpoint()
command! DebugStart lua require'dap'.continue()
command! DebugContinue lua require'dap'.continue()
command! DebugStepOver lua require'dap'.step_over()
command! DebugStepOut lua require'dap'.step_out()
command! DebugStepInto lua require'dap'.step_into()
command! DebugToggleRepl lua require'dap'.repl.toggle()
command! DebugGetSession lua require'dap'.session()
" Available Debug Adapters:
" https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/
"
" Adapter configuration and installation instructions:
" https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation
"
" Debug Adapter protocol:
" https://microsoft.github.io/debug-adapter-protocol/
" TODO Add full support later
" nnoremap <silent> <F5> :lua require'dap'.continue()<CR>
" nnoremap <silent> <F10> :lua require'dap'.step_over()<CR>
" nnoremap <silent> <F11> :lua require'dap'.step_into()<CR>
" nnoremap <silent> <F12> :lua require'dap'.step_out()<CR>
" nnoremap <silent> <leader>b :lua require'dap'.toggle_breakpoint()<CR>
" nnoremap <silent> <leader>B :lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>
" nnoremap <silent> <leader>lp :lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>
" nnoremap <silent> <leader>dr :lua require'dap'.repl.open()<CR>
" nnoremap <silent> <leader>dl :lua require'dap'.run_last()<CR>
autocmd! User GoyoEnter lua require('gitsigns').toggle_signs()
autocmd! User GoyoLeave lua require('gitsigns').toggle_signs()
autocmd User GoyoEnter set laststatus=0
autocmd User GoyoLeave set laststatus=2
" autocmd! User GoyoEnter lua require('galaxyline').disable_galaxyline()
" autocmd! User GoyoLeave lua require('galaxyline').galaxyline_augroup()
function! QuickFixToggle()
if empty(filter(getwininfo(), 'v:val.quickfix'))
copen
else
cclose
endif
endfunction
-84
View File
@@ -1,84 +0,0 @@
" packadd quickscope
execute 'luafile ' . stdpath('config') . '/lua/settings.lua'
function! s:manageEditorSize(...)
let count = a:1
let to = a:2
for i in range(1, count ? count : 1)
call VSCodeNotify(to == 'increase' ? 'workbench.action.increaseViewSize' : 'workbench.action.decreaseViewSize')
endfor
endfunction
function! s:vscodeCommentary(...) abort
if !a:0
let &operatorfunc = matchstr(expand('<sfile>'), '[^. ]*$')
return 'g@'
elseif a:0 > 1
let [line1, line2] = [a:1, a:2]
else
let [line1, line2] = [line("'["), line("']")]
endif
call VSCodeCallRange("editor.action.commentLine", line1, line2, 0)
endfunction
function! s:openVSCodeCommandsInVisualMode()
normal! gv
let visualmode = visualmode()
if visualmode == "V"
let startLine = line("v")
let endLine = line(".")
call VSCodeNotifyRange("workbench.action.showCommands", startLine, endLine, 1)
else
let startPos = getpos("v")
let endPos = getpos(".")
call VSCodeNotifyRangePos("workbench.action.showCommands", startPos[1], endPos[1], startPos[2], endPos[2], 1)
endif
endfunction
function! s:openWhichKeyInVisualMode()
normal! gv
let visualmode = visualmode()
if visualmode == "V"
let startLine = line("v")
let endLine = line(".")
call VSCodeNotifyRange("whichkey.show", startLine, endLine, 1)
else
let startPos = getpos("v")
let endPos = getpos(".")
call VSCodeNotifyRangePos("whichkey.show", startPos[1], endPos[1], startPos[2], endPos[2], 1)
endif
endfunction
" Better Navigation
nnoremap <silent> <C-j> :call VSCodeNotify('workbench.action.navigateDown')<CR>
xnoremap <silent> <C-j> :call VSCodeNotify('workbench.action.navigateDown')<CR>
nnoremap <silent> <C-k> :call VSCodeNotify('workbench.action.navigateUp')<CR>
xnoremap <silent> <C-k> :call VSCodeNotify('workbench.action.navigateUp')<CR>
nnoremap <silent> <C-h> :call VSCodeNotify('workbench.action.navigateLeft')<CR>
xnoremap <silent> <C-h> :call VSCodeNotify('workbench.action.navigateLeft')<CR>
nnoremap <silent> <C-l> :call VSCodeNotify('workbench.action.navigateRight')<CR>
xnoremap <silent> <C-l> :call VSCodeNotify('workbench.action.navigateRight')<CR>
nnoremap gr <Cmd>call VSCodeNotify('editor.action.goToReferences')<CR>
" Bind C-/ to vscode commentary since calling from vscode produces double comments due to multiple cursors
" xnoremap <expr> <C-/> <SID>vscodeCommentary()
" nnoremap <expr> <C-/> <SID>vscodeCommentary() . '_'
nnoremap <silent> <C-w>_ :<C-u>call VSCodeNotify('workbench.action.toggleEditorWidths')<CR>
nnoremap <silent> <Space> :call VSCodeNotify('whichkey.show')<CR>
xnoremap <silent> <Space> :<C-u>call <SID>openWhichKeyInVisualMode()<CR>
xnoremap <silent> <C-P> :<C-u>call <SID>openVSCodeCommandsInVisualMode()<CR>
xmap gc <Plug>VSCodeCommentary
nmap gc <Plug>VSCodeCommentary
omap gc <Plug>VSCodeCommentary
nmap gcc <Plug>VSCodeCommentaryLine
" Simulate same TAB behavior in VSCode
nmap <Tab> :Tabnext<CR>
nmap <S-Tab> :Tabprev<CR>