This commit is contained in:
abs3nt 2023-07-10 20:43:47 -07:00
parent bc5f8b84fc
commit 1951664755
Signed by: abs3nt
GPG Key ID: FDC6662313FA9386
6 changed files with 729 additions and 743 deletions

View File

@ -1,18 +1,18 @@
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 if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ vim.fn.system({
"git", "git",
"clone", "clone",
"--filter=blob:none", "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git", "https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release "--branch=stable", -- latest stable release
lazypath, lazypath,
}) })
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require('options') require("options")
require('lazy').setup('plugins') require("lazy").setup("plugins")
require('mappings') require("mappings")
require('lsp_settings') require("lsp_settings")
require('autocmds') require("autocmds")

View File

@ -3,143 +3,148 @@ local autocmd = vim.api.nvim_create_autocmd -- Create autocommand
local _group = vim.api.nvim_create_augroup("LineNumber", { clear = true }) local _group = vim.api.nvim_create_augroup("LineNumber", { clear = true })
local function relativeln(target) local function relativeln(target)
if vim.b.lnstatus == nil then if vim.b.lnstatus == nil then
vim.b.lnstatus = "number" vim.b.lnstatus = "number"
end end
if vim.b.lnstatus ~= "nonumber" then if vim.b.lnstatus ~= "nonumber" then
if target == "number" then if target == "number" then
vim.o.number = true vim.o.number = true
vim.o.relativenumber = false vim.o.relativenumber = false
else else
vim.o.number = true vim.o.number = true
vim.o.relativenumber = true vim.o.relativenumber = true
end end
else else
vim.o.number = false vim.o.number = false
end end
end end
autocmd("InsertEnter", { autocmd("InsertEnter", {
pattern = "*", pattern = "*",
callback = function() callback = function()
relativeln("number") relativeln("number")
end, end,
once = false, once = false,
group = _group, group = _group,
}) })
autocmd("InsertLeave", { autocmd("InsertLeave", {
pattern = "*", pattern = "*",
callback = function() callback = function()
relativeln("relativenumber") relativeln("relativenumber")
end, end,
once = false, once = false,
group = _group, group = _group,
}) })
autocmd("FocusLost", { autocmd("FocusLost", {
pattern = "*", pattern = "*",
callback = function() callback = function()
relativeln("number") relativeln("number")
end, end,
once = false, once = false,
group = _group, group = _group,
}) })
autocmd("CursorMoved", { autocmd("CursorMoved", {
pattern = "*", pattern = "*",
callback = function() callback = function()
relativeln("relativenumber") relativeln("relativenumber")
end, end,
once = false, once = false,
group = _group, group = _group,
}) })
local nvim_tree_events = require('nvim-tree.events') vim.cmd([[
local bufferline_api = require('bufferline.api') :augroup fmt
: autocmd!
: autocmd BufWritePre * silent! undojoin | silent! Neoformat
:augroup END
]])
local nvim_tree_events = require("nvim-tree.events")
local bufferline_api = require("bufferline.api")
local function get_tree_size() local function get_tree_size()
return require 'nvim-tree.view'.View.width return require("nvim-tree.view").View.width
end end
nvim_tree_events.subscribe('TreeOpen', function() nvim_tree_events.subscribe("TreeOpen", function()
bufferline_api.set_offset(get_tree_size()) bufferline_api.set_offset(get_tree_size())
end) end)
nvim_tree_events.subscribe('Resize', function() nvim_tree_events.subscribe("Resize", function()
bufferline_api.set_offset(get_tree_size()) bufferline_api.set_offset(get_tree_size())
end) end)
nvim_tree_events.subscribe('TreeClose', function() nvim_tree_events.subscribe("TreeClose", function()
bufferline_api.set_offset(0) bufferline_api.set_offset(0)
end) end)
-- change tmux title -- change tmux title
autocmd("BufReadPost", { autocmd("BufReadPost", {
pattern = "*", pattern = "*",
callback = function() callback = function()
vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]]) vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]])
end, end,
once = false, once = false,
group = _group, group = _group,
}) })
autocmd("FileReadPost", { autocmd("FileReadPost", {
pattern = "*", pattern = "*",
callback = function() callback = function()
vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]]) vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]])
end, end,
once = false, once = false,
group = _group, group = _group,
}) })
autocmd("BufNewFile", { autocmd("BufNewFile", {
pattern = "*", pattern = "*",
callback = function() callback = function()
vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]]) vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]])
end, end,
once = false, once = false,
group = _group, group = _group,
}) })
autocmd("BufEnter", { autocmd("BufEnter", {
pattern = "*", pattern = "*",
callback = function() callback = function()
vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]]) vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]])
end, end,
once = false, once = false,
group = _group, group = _group,
}) })
-- auto close nvimtree -- auto close nvimtree
autocmd('BufEnter', { autocmd("BufEnter", {
command = "if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif", command = "if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif",
nested = true, nested = true,
}) })
-- dont show line numbers for nvimtree buffers -- dont show line numbers for nvimtree buffers
autocmd("BufEnter", autocmd("BufEnter", {
{ pattern = { "NvimTree*" },
pattern = { "NvimTree*" }, callback = function()
callback = function() vim.b.lnstatus = "nonumber"
vim.b.lnstatus = "nonumber" end,
end })
})
-- Disable the statusline, tabline and cmdline while the alpha dashboard is open -- Disable the statusline, tabline and cmdline while the alpha dashboard is open
autocmd('User', { autocmd("User", {
pattern = 'AlphaReady', pattern = "AlphaReady",
desc = 'disable status, tabline and cmdline for alpha', desc = "disable status, tabline and cmdline for alpha",
callback = function() callback = function()
vim.go.laststatus = 1 vim.go.laststatus = 1
vim.opt.showtabline = 1 vim.opt.showtabline = 1
vim.opt.cmdheight = 1 vim.opt.cmdheight = 1
end, end,
}) })
autocmd('BufUnload', { autocmd("BufUnload", {
buffer = 0, buffer = 0,
desc = 'enable status, tabline and cmdline after alpha', desc = "enable status, tabline and cmdline after alpha",
callback = function() callback = function()
vim.go.laststatus = 2 vim.go.laststatus = 2
vim.opt.showtabline = 2 vim.opt.showtabline = 2
vim.opt.cmdheight = 1 vim.opt.cmdheight = 1
end, end,
}) })

View File

@ -1,116 +1,116 @@
require("mason").setup { require("mason").setup({
automatic_installation = true automatic_installation = true,
} })
-- Setup lspconfig. -- Setup lspconfig.
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
local navic = require("nvim-navic") local navic = require("nvim-navic")
-- LSP hotkey config -- LSP hotkey config
local opts = { noremap = true, silent = true } local opts = { noremap = true, silent = true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts) vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts) vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, opts)
-- Use an on_attach function to only map the following keys -- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer -- after the language server attaches to the current buffer
local on_attach = function(client, bufnr) local on_attach = function(client, bufnr)
if client.server_capabilities.documentSymbolProvider then if client.server_capabilities.documentSymbolProvider then
navic.attach(client, bufnr) navic.attach(client, bufnr)
end end
vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]] -- vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]]
-- Enable completion triggered by <c-x><c-o> -- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
-- Mappings. -- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions -- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap = true, silent = true, buffer = bufnr } local bufopts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts) vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts) vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts) vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function() vim.keymap.set("n", "<space>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts) end, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts) vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts) vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts) vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<space>f', vim.lsp.buf.formatting, bufopts) vim.keymap.set("n", "<space>f", vim.lsp.buf.formatting, bufopts)
end end
local lsp_flags = { local lsp_flags = {
-- This is the default in Nvim 0.7+ -- This is the default in Nvim 0.7+
debounce_text_changes = 150, debounce_text_changes = 150,
} }
--- initialize language servers --- initialize language servers
require('mason-lspconfig').setup() require("mason-lspconfig").setup()
require('mason-lspconfig').setup_handlers { require("mason-lspconfig").setup_handlers({
function(server_name) function(server_name)
require("lspconfig")[server_name].setup { require("lspconfig")[server_name].setup({
on_attach = on_attach, on_attach = on_attach,
flags = lsp_flags, flags = lsp_flags,
capabilities = capabilities, capabilities = capabilities,
settings = { settings = {
Lua = { Lua = {
completion = { completion = {
callSnippet = 'Replace', callSnippet = "Replace",
}, },
diagnostics = { diagnostics = {
globals = { 'vim' } globals = { "vim" },
} },
}, },
} },
} })
require("lspconfig")['tsserver'].setup { require("lspconfig")["tsserver"].setup({
on_attach = on_attach, on_attach = on_attach,
flags = lsp_flags, flags = lsp_flags,
capabilities = capabilities, capabilities = capabilities,
settings = { settings = {
typescript = { typescript = {
format = { format = {
insertSpaceAfterOpeningAndBeforeClosingEmptyBraces = false, insertSpaceAfterOpeningAndBeforeClosingEmptyBraces = false,
insertSpaceAfterFunctionKeywordForAnonymousFunctions = true, insertSpaceAfterFunctionKeywordForAnonymousFunctions = true,
semicolons = 'remove', semicolons = "remove",
}, },
}, },
}, },
} })
require("lspconfig")['pylsp'].setup { require("lspconfig")["pylsp"].setup({
on_attach = on_attach, on_attach = on_attach,
flags = lsp_flags, flags = lsp_flags,
capabilities = capabilities, capabilities = capabilities,
settings = { settings = {
pylsp = { pylsp = {
plugins = { plugins = {
pycodestyle = { pycodestyle = {
maxLineLength = 120 maxLineLength = 120,
} },
} },
} },
} },
} })
require("lspconfig")['gopls'].setup { require("lspconfig")["gopls"].setup({
on_attach = on_attach, on_attach = on_attach,
flags = lsp_flags, flags = lsp_flags,
capabilities = capabilities, capabilities = capabilities,
settings = { settings = {
gopls = { gopls = {
experimentalPostfixCompletions = true, experimentalPostfixCompletions = true,
gofumpt = true, gofumpt = true,
analyses = { analyses = {
nilness = true, nilness = true,
unusedwrite = true, unusedwrite = true,
unusedvariable = true, unusedvariable = true,
}, },
staticcheck = true, staticcheck = true,
} },
}, },
} })
end end,
} })

View File

@ -1,4 +1,4 @@
local vimp = require('vimp') local vimp = require("vimp")
-- tabs and stuff -- tabs and stuff
vimp.vnoremap("<C-b>", [[<C-a>]]) vimp.vnoremap("<C-b>", [[<C-a>]])
@ -13,34 +13,34 @@ vimp.xnoremap("<", [[<gv]])
vimp.xnoremap(">", [[>gv]]) vimp.xnoremap(">", [[>gv]])
-- Toggle Lines -- Toggle Lines
vimp.nnoremap({ 'silent' }, '<leader>l', function() vimp.nnoremap({ "silent" }, "<leader>l", function()
if vim.b.lnstatus == nil then if vim.b.lnstatus == nil then
vim.b.lnstatus = "number" vim.b.lnstatus = "number"
end end
if vim.b.lnstatus == "number" then if vim.b.lnstatus == "number" then
vim.o.number = false vim.o.number = false
vim.o.relativenumber = false vim.o.relativenumber = false
vim.b.lnstatus = "nonumber" vim.b.lnstatus = "nonumber"
else else
vim.o.number = true vim.o.number = true
vim.o.relativenumber = true vim.o.relativenumber = true
vim.b.lnstatus = "number" vim.b.lnstatus = "number"
end end
end) end)
-- plugins -- plugins
vimp.noremap('<leader>md', [[:MarkdownPreviewToggle<CR>]]) vimp.noremap("<leader>md", [[:MarkdownPreviewToggle<CR>]])
vimp.nnoremap({ 'silent' }, '<A-Right>', [[:BufferNext<CR>]]) vimp.nnoremap({ "silent" }, "<A-Right>", [[:BufferNext<CR>]])
vimp.nnoremap({ 'silent' }, '<A-Left>', [[:BufferPrevious<CR>]]) vimp.nnoremap({ "silent" }, "<A-Left>", [[:BufferPrevious<CR>]])
vimp.nnoremap({ "silent" }, "<leader>a", [[:ArgWrap<CR>]])
vimp.nnoremap({ 'silent' }, '<leader>a', [[:ArgWrap<CR>]]) vimp.noremap({ "silent" }, "<leader>n", [[:NvimTreeToggle<CR>]])
vimp.noremap({ "silent" }, "<leader>ff", [[:Telescope find_files<CR>]])
vimp.noremap({ 'silent' }, '<leader>n', [[:NvimTreeToggle<CR>]]) vimp.noremap({ "silent" }, "<leader>fg", [[:Telescope live_grep<CR>]])
vimp.noremap({ "silent" }, "<leader>fb", [[:Telescope buffers<CR>]])
vimp.noremap({ 'silent' }, '<leader>ff', [[:Telescope find_files<CR>]]) vimp.noremap({ "silent" }, "<leader>fp", function()
vimp.noremap({ 'silent' }, '<leader>fg', [[:Telescope live_grep<CR>]]) require("telescope").extensions.projects.projects({})
vimp.noremap({ 'silent' }, '<leader>fb', [[:Telescope buffers<CR>]]) end)
vimp.noremap({ 'silent' }, '<leader>fp', function() require 'telescope'.extensions.projects.projects {} end)

View File

@ -13,11 +13,11 @@ vim.o.mmp = 5000
-- don't give |ins-completion-menu| messages. -- don't give |ins-completion-menu| messages.
vim.o.hidden = true vim.o.hidden = true
vim.o.signcolumn = 'yes' vim.o.signcolumn = "yes"
vim.o.encoding = 'utf-8' vim.o.encoding = "utf-8"
vim.o.shortmess = 'c' vim.o.shortmess = "c"
vim.o.autoread = true vim.o.autoread = true
vim.o.backspace = 'indent,eol,start' vim.o.backspace = "indent,eol,start"
vim.o.ruler = true vim.o.ruler = true
vim.o.showmode = true vim.o.showmode = true
vim.o.history = 1000 vim.o.history = 1000
@ -35,24 +35,24 @@ vim.o.softtabstop = 2
vim.o.tabstop = 2 vim.o.tabstop = 2
vim.o.expandtab = true vim.o.expandtab = true
vim.o.scrolloff = 5 vim.o.scrolloff = 5
vim.o.foldmethod = 'indent' vim.o.foldmethod = "indent"
vim.o.foldlevel = 99 vim.o.foldlevel = 99
vim.wo.wrap = false vim.wo.wrap = false
vim.o.showcmd = true vim.o.showcmd = true
vim.o.number = true vim.o.number = true
vim.o.relativenumber = true vim.o.relativenumber = true
vim.o.mouse = 'a' vim.o.mouse = "a"
vim.o.redrawtime = 10000 vim.o.redrawtime = 10000
vim.o.inccommand = 'split' vim.o.inccommand = "split"
---- Sync " and + registers ---- Sync " and + registers
vim.o.clipboard = 'unnamedplus' vim.o.clipboard = "unnamedplus"
-- show completion options on <TAB> -- show completion options on <TAB>
vim.o.wildmenu = true vim.o.wildmenu = true
-- complete only up to the point of ambiguity -- complete only up to the point of ambiguity
vim.o.wildmode = 'list:longest' vim.o.wildmode = "list:longest"
vim.opt.backupdir = os.getenv("XDG_CACHE_HOME") .. '/nvim/backup//' vim.opt.backupdir = os.getenv("XDG_CACHE_HOME") .. "/nvim/backup//"
vim.o.directory = os.getenv("XDG_CACHE_HOME") .. '/nvim/swap//' vim.o.directory = os.getenv("XDG_CACHE_HOME") .. "/nvim/swap//"
vim.o.undodir = os.getenv("XDG_CACHE_HOME") .. '/nvim/undo//' vim.o.undodir = os.getenv("XDG_CACHE_HOME") .. "/nvim/undo//"
vim.o.undofile = true vim.o.undofile = true

File diff suppressed because it is too large Load Diff