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"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require('options')
require('lazy').setup('plugins')
require('mappings')
require('lsp_settings')
require('autocmds')
require("options")
require("lazy").setup("plugins")
require("mappings")
require("lsp_settings")
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 function relativeln(target)
if vim.b.lnstatus == nil then
vim.b.lnstatus = "number"
end
if vim.b.lnstatus == nil then
vim.b.lnstatus = "number"
end
if vim.b.lnstatus ~= "nonumber" then
if target == "number" then
vim.o.number = true
vim.o.relativenumber = false
else
vim.o.number = true
vim.o.relativenumber = true
end
else
vim.o.number = false
end
if vim.b.lnstatus ~= "nonumber" then
if target == "number" then
vim.o.number = true
vim.o.relativenumber = false
else
vim.o.number = true
vim.o.relativenumber = true
end
else
vim.o.number = false
end
end
autocmd("InsertEnter", {
pattern = "*",
callback = function()
relativeln("number")
end,
once = false,
group = _group,
pattern = "*",
callback = function()
relativeln("number")
end,
once = false,
group = _group,
})
autocmd("InsertLeave", {
pattern = "*",
callback = function()
relativeln("relativenumber")
end,
once = false,
group = _group,
pattern = "*",
callback = function()
relativeln("relativenumber")
end,
once = false,
group = _group,
})
autocmd("FocusLost", {
pattern = "*",
callback = function()
relativeln("number")
end,
once = false,
group = _group,
pattern = "*",
callback = function()
relativeln("number")
end,
once = false,
group = _group,
})
autocmd("CursorMoved", {
pattern = "*",
callback = function()
relativeln("relativenumber")
end,
once = false,
group = _group,
pattern = "*",
callback = function()
relativeln("relativenumber")
end,
once = false,
group = _group,
})
local nvim_tree_events = require('nvim-tree.events')
local bufferline_api = require('bufferline.api')
vim.cmd([[
: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()
return require 'nvim-tree.view'.View.width
return require("nvim-tree.view").View.width
end
nvim_tree_events.subscribe('TreeOpen', function()
bufferline_api.set_offset(get_tree_size())
nvim_tree_events.subscribe("TreeOpen", function()
bufferline_api.set_offset(get_tree_size())
end)
nvim_tree_events.subscribe('Resize', function()
bufferline_api.set_offset(get_tree_size())
nvim_tree_events.subscribe("Resize", function()
bufferline_api.set_offset(get_tree_size())
end)
nvim_tree_events.subscribe('TreeClose', function()
bufferline_api.set_offset(0)
nvim_tree_events.subscribe("TreeClose", function()
bufferline_api.set_offset(0)
end)
-- change tmux title
autocmd("BufReadPost", {
pattern = "*",
callback = function()
vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]])
end,
once = false,
group = _group,
pattern = "*",
callback = function()
vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]])
end,
once = false,
group = _group,
})
autocmd("FileReadPost", {
pattern = "*",
callback = function()
vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]])
end,
once = false,
group = _group,
pattern = "*",
callback = function()
vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]])
end,
once = false,
group = _group,
})
autocmd("BufNewFile", {
pattern = "*",
callback = function()
vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]])
end,
once = false,
group = _group,
pattern = "*",
callback = function()
vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]])
end,
once = false,
group = _group,
})
autocmd("BufEnter", {
pattern = "*",
callback = function()
vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]])
end,
once = false,
group = _group,
pattern = "*",
callback = function()
vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]])
end,
once = false,
group = _group,
})
-- auto close nvimtree
autocmd('BufEnter', {
command = "if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif",
nested = true,
autocmd("BufEnter", {
command = "if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif",
nested = true,
})
-- dont show line numbers for nvimtree buffers
autocmd("BufEnter",
{
pattern = { "NvimTree*" },
callback = function()
vim.b.lnstatus = "nonumber"
end
})
autocmd("BufEnter", {
pattern = { "NvimTree*" },
callback = function()
vim.b.lnstatus = "nonumber"
end,
})
-- Disable the statusline, tabline and cmdline while the alpha dashboard is open
autocmd('User', {
pattern = 'AlphaReady',
desc = 'disable status, tabline and cmdline for alpha',
callback = function()
vim.go.laststatus = 1
vim.opt.showtabline = 1
vim.opt.cmdheight = 1
end,
autocmd("User", {
pattern = "AlphaReady",
desc = "disable status, tabline and cmdline for alpha",
callback = function()
vim.go.laststatus = 1
vim.opt.showtabline = 1
vim.opt.cmdheight = 1
end,
})
autocmd('BufUnload', {
buffer = 0,
desc = 'enable status, tabline and cmdline after alpha',
callback = function()
vim.go.laststatus = 2
vim.opt.showtabline = 2
vim.opt.cmdheight = 1
end,
autocmd("BufUnload", {
buffer = 0,
desc = "enable status, tabline and cmdline after alpha",
callback = function()
vim.go.laststatus = 2
vim.opt.showtabline = 2
vim.opt.cmdheight = 1
end,
})

View File

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

View File

@ -1,4 +1,4 @@
local vimp = require('vimp')
local vimp = require("vimp")
-- tabs and stuff
vimp.vnoremap("<C-b>", [[<C-a>]])
@ -13,34 +13,34 @@ vimp.xnoremap("<", [[<gv]])
vimp.xnoremap(">", [[>gv]])
-- Toggle Lines
vimp.nnoremap({ 'silent' }, '<leader>l', function()
if vim.b.lnstatus == nil then
vim.b.lnstatus = "number"
end
if vim.b.lnstatus == "number" then
vim.o.number = false
vim.o.relativenumber = false
vim.b.lnstatus = "nonumber"
else
vim.o.number = true
vim.o.relativenumber = true
vim.b.lnstatus = "number"
end
vimp.nnoremap({ "silent" }, "<leader>l", function()
if vim.b.lnstatus == nil then
vim.b.lnstatus = "number"
end
if vim.b.lnstatus == "number" then
vim.o.number = false
vim.o.relativenumber = false
vim.b.lnstatus = "nonumber"
else
vim.o.number = true
vim.o.relativenumber = true
vim.b.lnstatus = "number"
end
end)
-- plugins
vimp.noremap('<leader>md', [[:MarkdownPreviewToggle<CR>]])
vimp.noremap("<leader>md", [[:MarkdownPreviewToggle<CR>]])
vimp.nnoremap({ 'silent' }, '<A-Right>', [[:BufferNext<CR>]])
vimp.nnoremap({ 'silent' }, '<A-Left>', [[:BufferPrevious<CR>]])
vimp.nnoremap({ "silent" }, "<A-Right>", [[:BufferNext<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>n', [[:NvimTreeToggle<CR>]])
vimp.noremap({ 'silent' }, '<leader>ff', [[:Telescope find_files<CR>]])
vimp.noremap({ 'silent' }, '<leader>fg', [[:Telescope live_grep<CR>]])
vimp.noremap({ 'silent' }, '<leader>fb', [[:Telescope buffers<CR>]])
vimp.noremap({ 'silent' }, '<leader>fp', function() require 'telescope'.extensions.projects.projects {} end)
vimp.noremap({ "silent" }, "<leader>ff", [[:Telescope find_files<CR>]])
vimp.noremap({ "silent" }, "<leader>fg", [[:Telescope live_grep<CR>]])
vimp.noremap({ "silent" }, "<leader>fb", [[:Telescope buffers<CR>]])
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.
vim.o.hidden = true
vim.o.signcolumn = 'yes'
vim.o.encoding = 'utf-8'
vim.o.shortmess = 'c'
vim.o.signcolumn = "yes"
vim.o.encoding = "utf-8"
vim.o.shortmess = "c"
vim.o.autoread = true
vim.o.backspace = 'indent,eol,start'
vim.o.backspace = "indent,eol,start"
vim.o.ruler = true
vim.o.showmode = true
vim.o.history = 1000
@ -35,24 +35,24 @@ vim.o.softtabstop = 2
vim.o.tabstop = 2
vim.o.expandtab = true
vim.o.scrolloff = 5
vim.o.foldmethod = 'indent'
vim.o.foldmethod = "indent"
vim.o.foldlevel = 99
vim.wo.wrap = false
vim.o.showcmd = true
vim.o.number = true
vim.o.relativenumber = true
vim.o.mouse = 'a'
vim.o.mouse = "a"
vim.o.redrawtime = 10000
vim.o.inccommand = 'split'
vim.o.inccommand = "split"
---- Sync " and + registers
vim.o.clipboard = 'unnamedplus'
vim.o.clipboard = "unnamedplus"
-- show completion options on <TAB>
vim.o.wildmenu = true
-- 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.o.directory = os.getenv("XDG_CACHE_HOME") .. '/nvim/swap//'
vim.o.undodir = os.getenv("XDG_CACHE_HOME") .. '/nvim/undo//'
vim.opt.backupdir = os.getenv("XDG_CACHE_HOME") .. "/nvim/backup//"
vim.o.directory = os.getenv("XDG_CACHE_HOME") .. "/nvim/swap//"
vim.o.undodir = os.getenv("XDG_CACHE_HOME") .. "/nvim/undo//"
vim.o.undofile = true

File diff suppressed because it is too large Load Diff