config overhaul

This commit is contained in:
christianchiarulli 2021-06-28 00:36:29 -04:00
parent e563306c63
commit ccf7e85df9
12 changed files with 218 additions and 270 deletions

View file

@ -1,5 +1,5 @@
require('lv-globals')
vim.cmd('luafile ' .. CONFIG_PATH .. '/lv-settings.lua')
require('default-config')
vim.cmd('luafile ' .. CONFIG_PATH .. '/lv-config.lua')
require('settings')
require('plugins')
require('lv-utils')
@ -13,24 +13,8 @@ require('lv-autopairs')
require('lv-which-key')
-- extras
if O.extras then
require('lv-rnvimr')
require('lv-gitblame')
require('lv-matchup')
require('lv-numb')
require('lv-dial')
require('lv-hop')
require('lv-colorizer')
require('lv-spectre')
require('lv-symbols-outline')
require('lv-vimtex')
require('lv-zen')
require('lv-dashboard')
require('lv-lsp-rooter')
end
-- TODO is there a way to do this without vimscript
-- TODO gotta get rid of this for speed
vim.cmd('source ' .. CONFIG_PATH .. '/vimscript/functions.vim')
-- LSP

134
lua/default-config.lua Normal file
View file

@ -0,0 +1,134 @@
CONFIG_PATH = vim.fn.stdpath('config')
DATA_PATH = vim.fn.stdpath('data')
CACHE_PATH = vim.fn.stdpath('cache')
O = {
auto_close_tree = 0,
auto_complete = true,
colorscheme = 'lunar',
hidden_files = true,
wrap_lines = false,
number = true,
relative_number = true,
cursorline = true,
shell = 'bash',
timeoutlen = 100,
nvim_tree_disable_netrw = 0,
extras = false,
-- @usage pass a table with your desired languages
treesitter = {
ensure_installed = "all",
ignore_install = {"haskell"},
highlight = {enabled = true},
playground = {enabled = true},
rainbow = {enabled = false}
},
database = {save_location = '~/.config/nvcode_db', auto_execute = 1},
lang = {
python = {
linter = '',
-- @usage can be 'yapf', 'black'
formatter = '',
autoformat = false,
isort = false,
diagnostics = {
virtual_text = {spacing = 0, prefix = ""},
signs = true,
underline = true
},
analysis = {
type_checking = "basic",
auto_search_paths = true,
use_library_code_types = true
}
},
dart = {
sdk_path = '/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot'
},
lua = {
-- @usage can be 'lua-format'
formatter = '',
autoformat = false,
diagnostics = {
virtual_text = {spacing = 0, prefix = ""},
signs = true,
underline = true
}
},
sh = {
-- @usage can be 'shellcheck'
linter = '',
-- @usage can be 'shfmt'
formatter = '',
autoformat = false,
diagnostics = {
virtual_text = {spacing = 0, prefix = ""},
signs = true,
underline = true
}
},
tsserver = {
-- @usage can be 'eslint'
linter = '',
-- @usage can be 'prettier'
formatter = '',
autoformat = false,
diagnostics = {
virtual_text = {spacing = 0, prefix = ""},
signs = true,
underline = true
}
},
json = {
-- @usage can be 'prettier'
formatter = '',
autoformat = false,
diagnostics = {
virtual_text = {spacing = 0, prefix = ""},
signs = true,
underline = true
}
},
tailwindls = {
filetypes = {
'html', 'css', 'scss', 'javascript', 'javascriptreact',
'typescript', 'typescriptreact'
}
},
clang = {
diagnostics = {
virtual_text = {spacing = 0, prefix = ""},
signs = true,
underline = true
}
},
ruby = {
diagnostics = {
virtualtext = {spacing = 0, prefix = ""},
signs = true,
underline = true
},
filetypes = {'rb', 'erb', 'rakefile'}
},
go = {}
-- css = {formatter = '', autoformat = false, virtual_text = true},
-- json = {formatter = '', autoformat = false, virtual_text = true}
},
dashboard = {
custom_header = {
' _..._ ',
' .\' (_`. _ __ ___ ',
' : . : | | _ _ _ __ __ _ _ _\\ \\ / (_)_ __ ___ ',
' :) () : | | | | | | \'_ \\ / _` | \'__\\ \\ / /| | \'_ ` _ \\ ',
' `. . .\' | |__| |_| | | | | (_| | | \\ V / | | | | | | |',
' `-...-\' |_____\\__,_|_| |_|\\__,_|_| \\_/ |_|_| |_| |_|'
},
footer = {'chrisatmachine.com'}
}
}

View file

@ -3,9 +3,9 @@ require'lspconfig'.clangd.setup {
on_attach = require'lsp'.common_on_attach,
handlers = {
["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = O.clang.diagnostics.virtual_text,
signs = O.clang.diagnostics.signs,
underline = O.clang.diagnostics.underline,
virtual_text = O.lang.clang.diagnostics.virtual_text,
signs = O.lang.clang.diagnostics.signs,
underline = O.lang.clang.diagnostics.underline,
update_in_insert = true
})

View file

@ -1,5 +1,5 @@
require'lspconfig'.dartls.setup{
cmd = { "dart", O.dart.sdk_path, "--lsp" },
cmd = { "dart", O.lang.dart.sdk_path, "--lsp" },
on_attach = require'lsp'.common_on_attach,
init_options = {
closingLabels = false,

View file

@ -15,13 +15,13 @@ local isort = {formatCommand = "isort --quiet -", formatStdin = true}
local yapf = {formatCommand = "yapf --quiet", formatStdin = true}
local black = {formatCommand = "black --quiet -", formatStdin = true}
if O.python.linter == 'flake8' then table.insert(python_arguments, flake8) end
if O.lang.python.linter == 'flake8' then table.insert(python_arguments, flake8) end
if O.python.isort then table.insert(python_arguments, isort) end
if O.lang.python.isort then table.insert(python_arguments, isort) end
if O.python.formatter == 'yapf' then
if O.lang.python.formatter == 'yapf' then
table.insert(python_arguments, yapf)
elseif O.python.formatter == 'black' then
elseif O.lang.python.formatter == 'black' then
table.insert(python_arguments, black)
end
@ -38,9 +38,9 @@ local lua_fmt = {
formatStdin = true
}
if O.lua.formatter == 'lua-format' then
if O.lang.lua.formatter == 'lua-format' then
table.insert(lua_arguments, luaFormat)
elseif O.lua.formatter == 'lua-fmt' then
elseif O.lang.lua.formatter == 'lua-fmt' then
table.insert(lua_arguments, lua_fmt)
end
@ -54,9 +54,9 @@ local shellcheck = {
lintFormats = {'%f:%l:%c: %trror: %m', '%f:%l:%c: %tarning: %m', '%f:%l:%c: %tote: %m'}
}
if O.sh.formatter == 'shfmt' then table.insert(sh_arguments, shfmt) end
if O.lang.sh.formatter == 'shfmt' then table.insert(sh_arguments, shfmt) end
if O.sh.linter == 'shellcheck' then table.insert(sh_arguments, shellcheck) end
if O.lang.sh.linter == 'shellcheck' then table.insert(sh_arguments, shellcheck) end
-- tsserver/web javascript react, vue, json, html, css, yaml
local prettier = {formatCommand = "prettier --stdin-filepath ${INPUT}", formatStdin = true}
@ -74,9 +74,9 @@ local eslint = {
local tsserver_args = {}
if O.tsserver.formatter == 'prettier' then table.insert(tsserver_args, prettier) end
if O.lang.tsserver.formatter == 'prettier' then table.insert(tsserver_args, prettier) end
if O.tsserver.linter == 'eslint' then table.insert(tsserver_args, eslint) end
if O.lang.tsserver.linter == 'eslint' then table.insert(tsserver_args, eslint) end
-- local markdownlint = {
-- -- TODO default to global lintrc

View file

@ -18,9 +18,9 @@ require'lspconfig'.tsserver.setup {
settings = {documentFormatting = false},
handlers = {
["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = O.tsserver.diagnostics.virtual_text,
signs = O.tsserver.diagnostics.signs,
underline = O.tsserver.diagnostics.underline,
virtual_text = O.lang.tsserver.diagnostics.virtual_text,
signs = O.lang.tsserver.diagnostics.signs,
underline = O.lang.tsserver.diagnostics.underline,
update_in_insert = true
})

View file

@ -4,18 +4,18 @@ require'lspconfig'.pyright.setup {
on_attach = require'lsp'.common_on_attach,
handlers = {
["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = O.python.diagnostics.virtual_text,
signs = O.python.diagnostics.signs,
underline = O.python.diagnostics.underline,
virtual_text = O.lang.python.diagnostics.virtual_text,
signs = O.lang.python.diagnostics.signs,
underline = O.lang.python.diagnostics.underline,
update_in_insert = true
})
},
settings = {
python = {
analysis = {
typeCheckingMode = O.python.analysis.type_checking,
autoSearchPaths = O.python.analysis.auto_search_paths,
useLibraryCodeForTypes = O.python.analysis.use_library_code_types
typeCheckingMode = O.lang.python.analysis.type_checking,
autoSearchPaths = O.lang.python.analysis.auto_search_paths,
useLibraryCodeForTypes = O.lang.python.analysis.use_library_code_types
}
}
}

View file

@ -4,12 +4,12 @@ require'lspconfig'.solargraph.setup {
on_attach = require'lsp'.common_on_attach,
handlers = {
["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = O.ruby.diagnostics.virtual_text,
signs = O.ruby.diagnostics.signs,
underline = O.ruby.diagnostics.underline,
virtual_text = O.lang.ruby.diagnostics.virtual_text,
signs = O.lang.ruby.diagnostics.signs,
underline = O.lang.ruby.diagnostics.underline,
update_in_insert = true
})
},
filetypes = O.ruby.filetypes,
filetypes = O.lang.ruby.filetypes,
}

View file

@ -3,13 +3,13 @@ local utils = require('lv-utils')
local auto_formatters = { }
local python_autoformat = {'BufWritePre', '*.py', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
if O.python.autoformat then table.insert(auto_formatters, python_autoformat) end
if O.lang.python.autoformat then table.insert(auto_formatters, python_autoformat) end
local javascript_autoformat = {'BufWritePre', '*.js', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
local javascriptreact_autoformat = {'BufWritePre', '*.jsx', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
local typescript_autoformat = {'BufWritePre', '*.ts', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
local typescriptreact_autoformat = {'BufWritePre', '*.tsx', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
if O.tsserver.autoformat then
if O.lang.tsserver.autoformat then
table.insert(auto_formatters, javascript_autoformat)
table.insert(auto_formatters, javascriptreact_autoformat)
table.insert(auto_formatters, typescript_autoformat)
@ -17,16 +17,16 @@ if O.tsserver.autoformat then
end
local lua_format = {'BufWritePre', '*.lua', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
if O.lua.autoformat then table.insert(auto_formatters, lua_format) end
if O.lang.lua.autoformat then table.insert(auto_formatters, lua_format) end
local json_format = {'BufWritePre', '*.json', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
if O.json.autoformat then table.insert(auto_formatters, json_format) end
if O.lang.json.autoformat then table.insert(auto_formatters, json_format) end
local ruby_format = {'BufWritePre', '*.rb', 'lua vim.lsp.buf.formatting_sync(nil,1000)'}
if O.ruby.autoformat then table.insert(auto_formatters, ruby_format) end
if O.lang.ruby.autoformat then table.insert(auto_formatters, ruby_format) end
local go_format = {'BufWritePre', '*.go', 'lua vim.lsp.buf.formatting_sync(nil,1000)'}
if O.go.autoformat then table.insert(auto_formatters, go_format) end
if O.lang.go.autoformat then table.insert(auto_formatters, go_format) end
utils.define_augroups({
_general_settings = {

View file

@ -1,89 +0,0 @@
CONFIG_PATH = vim.fn.stdpath('config')
DATA_PATH = vim.fn.stdpath('data')
CACHE_PATH = vim.fn.stdpath('cache')
O = {
auto_close_tree = 0,
auto_complete = true,
colorscheme = 'lunar',
hidden_files = true,
wrap_lines = false,
number = true,
relative_number = true,
cursorline = true,
shell = 'bash',
timeoutlen = 100,
nvim_tree_disable_netrw = 0,
extras = false,
-- @usage pass a table with your desired languages
treesitter = {
ensure_installed = "all",
ignore_install = {"haskell"},
highlight = {enabled = true},
playground = {enabled = true},
rainbow = {enabled = false}
},
database = {save_location = '~/.config/nvcode_db', auto_execute = 1},
python = {
linter = '',
-- @usage can be 'yapf', 'black'
formatter = '',
autoformat = false,
isort = false,
diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true},
analysis = {type_checking = "basic", auto_search_paths = true, use_library_code_types = true}
},
dart = {sdk_path = '/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot'},
lua = {
-- @usage can be 'lua-format'
formatter = '',
autoformat = false,
diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}
},
sh = {
-- @usage can be 'shellcheck'
linter = '',
-- @usage can be 'shfmt'
formatter = '',
autoformat = false,
diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}
},
tsserver = {
-- @usage can be 'eslint'
linter = '',
-- @usage can be 'prettier'
formatter = '',
autoformat = false,
diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}
},
json = {
-- @usage can be 'prettier'
formatter = '',
autoformat = false,
diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}
},
tailwindls = {filetypes = {'html', 'css', 'scss', 'javascript', 'javascriptreact', 'typescript', 'typescriptreact'}},
clang = {diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}},
ruby = {
diagnostics = {virtualtext = {spacing = 0, prefix = ""}, signs = true, underline = true},
filetypes = {'rb', 'erb', 'rakefile'}
},
go = {},
-- css = {formatter = '', autoformat = false, virtual_text = true},
-- json = {formatter = '', autoformat = false, virtual_text = true}
dashboard = {
custom_header = {
' _..._ ',
' .\' (_`. _ __ ___ ',
' : . : | | _ _ _ __ __ _ _ _\\ \\ / (_)_ __ ___ ',
' :) () : | | | | | | \'_ \\ / _` | \'__\\ \\ / /| | \'_ ` _ \\ ',
' `. . .\' | |__| |_| | | | | (_| | | \\ V / | | | | | | |',
' `-...-\' |_____\\__,_|_| |_|\\__,_|_| \\_/ |_|_| |_| |_|',
},
footer= {'chrisatmachine.com'}
}
}

View file

@ -34,48 +34,13 @@ return require("packer").startup(function(use)
use "wbthomason/packer.nvim"
-- TODO refactor all of this (for now it works, but yes I know it could be wrapped in a simpler function)
use {
"neovim/nvim-lspconfig"
-- event = "BufRead",
-- config = function()
-- require("lsp").config()
-- end
}
use {
"glepnir/lspsaga.nvim"
-- event = "BufRead",
-- opt = true
}
use {
"kabouzeid/nvim-lspinstall"
-- event = "BufRead",
-- opt = true
}
use {"neovim/nvim-lspconfig"}
use {"glepnir/lspsaga.nvim"}
use {"kabouzeid/nvim-lspinstall"}
-- Telescope
use {
"nvim-lua/popup.nvim"
-- opt = true
}
use {
"nvim-lua/plenary.nvim"
-- opt = true
}
use {
"nvim-telescope/telescope.nvim"
-- cmd = "Telescope",
-- opt = true
}
use {"nvim-lua/popup.nvim"}
use {"nvim-lua/plenary.nvim"}
use {"nvim-telescope/telescope.nvim"}
-- Autocomplete
use {
@ -87,29 +52,15 @@ return require("packer").startup(function(use)
}
-- Treesitter
use {
"nvim-treesitter/nvim-treesitter",
-- event = "BufRead",
-- config = function()
-- require('lv-treesitter').config()
-- end,
run = ":TSUpdate"
}
-- Explorer
-- use {"kyazdani42/nvim-tree.lua", opt = true}
use {"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"}
use {
"kyazdani42/nvim-tree.lua",
cmd = "NvimTreeToggle",
config = function()
-- require_plugin("lv-nvimtree")
require("lv-nvimtree").config()
end
-- opt = true
}
-- use {'lukas-reineke/indent-blankline.nvim', opt=true, branch = 'lua'}
@ -117,28 +68,13 @@ return require("packer").startup(function(use)
"lewis6991/gitsigns.nvim",
config = function()
-- require_plugin("nvim-compe")
require("lv-gitsigns").config()
end,
event = "BufRead"
-- opt = true
}
use {
"folke/which-key.nvim"
-- opt = true
}
use {
"windwp/nvim-autopairs"
-- event = "InsertEnter",
-- opt = true
}
use {"folke/which-key.nvim"}
use {"windwp/nvim-autopairs"}
-- Comments
use {
@ -147,31 +83,21 @@ return require("packer").startup(function(use)
config = function()
require('nvim_comment').setup()
end
-- opt = true
}
-- Color
use {"christianchiarulli/nvcode-color-schemes.vim", opt = true}
-- Icons
use {
"kyazdani42/nvim-web-devicons"
-- opt = true
}
use {"kyazdani42/nvim-web-devicons"}
-- Status Line and Bufferline
use {
"glepnir/galaxyline.nvim"
-- opt = true
}
use {"glepnir/galaxyline.nvim"}
use {
"romgrk/barbar.nvim",
config = function()
-- require_plugin("barbar.nvim")
vim.api.nvim_set_keymap('n', '<TAB>', ':BufferNext<CR>',
{noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<S-TAB>', ':BufferPrevious<CR>',
@ -180,32 +106,25 @@ return require("packer").startup(function(use)
{noremap = true, silent = true})
end
-- opt = true
}
use {
"hrsh7th/vim-vsnip"
use {"hrsh7th/vim-vsnip"}
-- opt = true
}
-- require_plugin("nvim-lspconfig")
-- require_plugin("lspsaga.nvim")
-- require_plugin("nvim-lspinstall")
-- require_plugin("popup.nvim")
-- require_plugin("plenary.nvim")
-- require_plugin("telescope.nvim")
-- require_plugin("nvim-treesitter")
-- require_plugin("nvim-comment")
-- require_plugin("nvim-tree.lua")
-- require_plugin("gitsigns.nvim")
-- require_plugin("which-key.nvim")
-- require_plugin("nvim-autopairs")
-- require_plugin("nvim-web-devicons")
-- require_plugin("galaxyline.nvim")
-- require_plugin("vim-vsnip")
-- extras
-- if O.matchup then require('lv-matchup') end
-- require('lv-rnvimr')
-- require('lv-gitblame')
-- require('lv-numb')
-- require('lv-dial')
-- require('lv-hop')
-- require('lv-colorizer')
-- require('lv-spectre')
-- require('lv-symbols-outline')
-- require('lv-vimtex')
-- require('lv-zen')
-- require('lv-dashboard')
-- require('lv-lsp-rooter')
-- end
-- Extras
if O.extras then

View file

@ -27,44 +27,44 @@ O.treesitter.ignore_install = {"haskell"}
O.treesitter.highlight.enabled = true
O.clang.diagnostics.virtual_text = false
O.clang.diagnostics.signs = false
O.clang.diagnostics.underline = false
O.lang.clang.diagnostics.virtual_text = false
O.lang.clang.diagnostics.signs = false
O.lang.clang.diagnostics.underline = false
-- python
-- add things like O.python.formatter.yapf.exec_path
-- add things like O.python.linter.flake8.exec_path
-- add things like O.python.formatter.isort.exec_path
O.python.formatter = 'yapf'
O.lang.python.formatter = 'yapf'
-- O.python.linter = 'flake8'
O.python.isort = true
O.python.autoformat = true
O.python.diagnostics.virtual_text = true
O.python.diagnostics.signs = true
O.python.diagnostics.underline = true
O.python.analysis.type_checking = "off"
O.python.analysis.auto_search_paths = true
O.python.analysis.use_library_code_types = true
O.lang.python.isort = true
O.lang.python.autoformat = true
O.lang.python.diagnostics.virtual_text = true
O.lang.python.diagnostics.signs = true
O.lang.python.diagnostics.underline = true
O.lang.python.analysis.type_checking = "off"
O.lang.python.analysis.auto_search_paths = true
O.lang.python.analysis.use_library_code_types = true
-- lua
-- TODO look into stylua
O.lua.formatter = 'lua-format'
O.lang.lua.formatter = 'lua-format'
-- O.lua.formatter = 'lua-format'
O.lua.autoformat = false
O.lang.lua.autoformat = false
-- javascript
O.tsserver.formatter = 'prettier'
O.tsserver.linter = nil
O.tsserver.autoformat = true
O.lang.tsserver.formatter = 'prettier'
O.lang.tsserver.linter = nil
O.lang.tsserver.autoformat = true
-- json
O.json.autoformat = true
O.lang.json.autoformat = true
-- ruby
O.ruby.autoformat = true
O.lang.ruby.autoformat = true
-- go
O.go.autoformat = true
O.lang.go.autoformat = true
-- create custom autocommand field (This would be easy with lua)
-- Turn off relative_numbers