mirror of
https://github.com/ViViDboarder/vim-settings.git
synced 2024-12-22 23:37:33 +00:00
Neovim lua: Refactor more plugin loading and add better language support
This commit is contained in:
parent
1ac22e81b2
commit
b194e639fd
8
neovim/ftplugin/fish.vim
Normal file
8
neovim/ftplugin/fish.vim
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
" Set up :make to use fish for syntax checking.
|
||||||
|
compiler fish
|
||||||
|
|
||||||
|
" Set this to have long lines wrap inside comments.
|
||||||
|
setlocal textwidth=79
|
||||||
|
|
||||||
|
" Enable folding of block structures in fish.
|
||||||
|
setlocal foldmethod=expr
|
9
neovim/ftplugin/go.vim
Normal file
9
neovim/ftplugin/go.vim
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
let g:argwrap_tail_comma = 1
|
||||||
|
let g:ale_fix_on_save = 1
|
||||||
|
" Disable some vim-go settings when Ale is installed
|
||||||
|
if exists('g:ale_fixers')
|
||||||
|
let g:go_def_mapping_enabled = 0
|
||||||
|
let g:go_version_warning = 0
|
||||||
|
let g:go_fmt_autosave = 0
|
||||||
|
let g:go_imports_autosave = 0
|
||||||
|
end
|
5
neovim/ftplugin/markdown.vim
Normal file
5
neovim/ftplugin/markdown.vim
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
" Set Markdown indent to 2 so single indented text doesn't become 'code'
|
||||||
|
set shiftwidth=2
|
||||||
|
|
||||||
|
" From plasticboy/vim-markdown via sheerun/vim-polyglot
|
||||||
|
let g:vim_markdown_new_list_item_indent = 0
|
1
neovim/ftplugin/python.vim
Normal file
1
neovim/ftplugin/python.vim
Normal file
@ -0,0 +1 @@
|
|||||||
|
let g:argwrap_tail_comma = 1
|
2
neovim/ftplugin/yaml.vim
Normal file
2
neovim/ftplugin/yaml.vim
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
" Set YAML indent to 2 because list objects are weird otherwise
|
||||||
|
set shiftwidth=2
|
@ -2,8 +2,6 @@
|
|||||||
if has('nvim-0.5')
|
if has('nvim-0.5')
|
||||||
lua require('init')
|
lua require('init')
|
||||||
else
|
else
|
||||||
" set runtimepath-='~/.local/share/nvim/site/pack/packer/**'
|
set runtimepath+='~/.vim'
|
||||||
" set runtimepath='~/.vim'
|
|
||||||
set runtimepath+='~/.vim"
|
|
||||||
source ~/.vim/init.vim
|
source ~/.vim/init.vim
|
||||||
end
|
end
|
||||||
|
56
neovim/lua/_colors.lua
Normal file
56
neovim/lua/_colors.lua
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
utils = require("utils")
|
||||||
|
|
||||||
|
-- TODO: Determine if I want to keep this or remove it in favor of dark-notify
|
||||||
|
_G.update_colors = function()
|
||||||
|
local function maybe_set(scope, name, val)
|
||||||
|
if vim[scope][name] ~= val then
|
||||||
|
vim[scope][name] = val
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set colorscheme based on env
|
||||||
|
local default_color = "solarized"
|
||||||
|
local env_color = utils.env_default("VIM_COLOR", default_color)
|
||||||
|
env_color = utils.env_default("NVIM_COLOR", env_color)
|
||||||
|
|
||||||
|
-- Read dark mode
|
||||||
|
local mode = vim.env.IS_DARKMODE
|
||||||
|
if vim.g.is_mac == 1 then
|
||||||
|
local cmd = "defaults read -g AppleInterfaceStyle 2>/dev/null || echo Light"
|
||||||
|
mode = vim.fn.system(cmd):gsub("\n", ""):lower()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Update background and theme
|
||||||
|
local change = false
|
||||||
|
if mode == "dark" then
|
||||||
|
env_color = utils.env_default("VIM_COLOR_DARK", env_color)
|
||||||
|
env_color = utils.env_default("NVIM_COLOR_DARK", env_color)
|
||||||
|
change = maybe_set("o", "background", "dark")
|
||||||
|
change = maybe_set("g", "colors_name", env_color) or change
|
||||||
|
elseif mode == "light" then
|
||||||
|
env_color = utils.env_default("VIM_COLOR_LIGHT", env_color)
|
||||||
|
env_color = utils.env_default("NVIM_COLOR_LIGHT", env_color)
|
||||||
|
change = maybe_set("o", "background", "light")
|
||||||
|
change = maybe_set("g", "colors_name", env_color) or change
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Update status line theme
|
||||||
|
if change and vim.fn.exists(":AirlineRefresh") == 1 then
|
||||||
|
vim.cmd(":AirlineRefresh")
|
||||||
|
elseif change and _G["packer_plugins"] ~= nil and packer_plugins["lualine"] and packer_plugins["lualine"].loaded then
|
||||||
|
local lualine_theme = vim.g.colors_name
|
||||||
|
if lualine_theme == "solarized" then
|
||||||
|
lualine_theme = lualine_theme .. "_" .. mode
|
||||||
|
end
|
||||||
|
require("plugins.lualine").config_lualine(lualine_theme)
|
||||||
|
end
|
||||||
|
|
||||||
|
return changed and "Changed color to " .. env_color .. " with mode " .. mode or "No change"
|
||||||
|
end
|
||||||
|
-- utils.autocmd("auto_colors", "FocusGained * call v:lua.update_colors()")
|
||||||
|
|
||||||
|
-- Initial set of colors
|
||||||
|
-- TODO: if update_colors() is removed, use the env color fetching and set the colorscheme here
|
||||||
|
update_colors()
|
@ -1,77 +1,23 @@
|
|||||||
local o, wo, bo = vim.o, vim.wo, vim.bo
|
local o, wo, bo = vim.o, vim.wo, vim.bo
|
||||||
|
|
||||||
-- Helpers
|
-- Helpers
|
||||||
|
|
||||||
require "_settings"
|
require "_settings"
|
||||||
require "_bindings"
|
require "_bindings"
|
||||||
utils = require("utils")
|
require "_colors"
|
||||||
|
|
||||||
-- Modify visual presentation
|
|
||||||
|
|
||||||
-- Create commands
|
-- Create commands
|
||||||
vim.cmd "command! TagsUpdate !ctags -R ."
|
vim.cmd "command! TagsUpdate !ctags -R ."
|
||||||
vim.cmd "command! Todo grep TODO"
|
vim.cmd "command! Todo grep TODO"
|
||||||
|
|
||||||
-- Use better grep programs
|
-- Use better grep programs
|
||||||
if vim.fn.executable('rg') == 1 then
|
if vim.fn.executable("rg") == 1 then
|
||||||
vim.o.grepprg = "rg --vimgrep --no-heading --color=never"
|
o.grepprg = "rg --vimgrep --no-heading --color=never"
|
||||||
vim.o.grepformat = "%f:%l:%c:%m,%f:%l:%m"
|
o.grepformat = "%f:%l:%c:%m,%f:%l:%m"
|
||||||
elseif vim.fn.executable('ag') == 1 then
|
elseif vim.fn.executable("ag") == 1 then
|
||||||
vim.o.grepprg = "ag --vimgrep --nogroup --nocolor"
|
o.grepprg = "ag --vimgrep --nogroup --nocolor"
|
||||||
elseif vim.fn.executable('ack') == 1 then
|
elseif vim.fn.executable("ack") == 1 then
|
||||||
vim.o.grepprg = "ack"
|
o.grepprg = "ack"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: Determine if I want to keep this or remove it in favor of dark-notify
|
-- Plugins
|
||||||
_G.update_colors = function()
|
|
||||||
local function maybe_set(scope, name, val)
|
|
||||||
if vim[scope][name] ~= val then
|
|
||||||
vim[scope][name] = val
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Set colorscheme based on env
|
|
||||||
local default_color = "solarized"
|
|
||||||
local env_color = utils.env_default("VIM_COLOR", default_color)
|
|
||||||
|
|
||||||
-- Read dark mode
|
|
||||||
local mode = vim.env.IS_DARKMODE
|
|
||||||
if vim.g.is_mac == 1 then
|
|
||||||
cmd = "defaults read -g AppleInterfaceStyle 2>/dev/null || echo Light"
|
|
||||||
mode = vim.fn.system(cmd):gsub("\n", ""):lower()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Update background and theme
|
|
||||||
local change = false
|
|
||||||
if mode == "dark" then
|
|
||||||
env_color = utils.env_default("VIM_COLOR_DARK", env_color)
|
|
||||||
change = maybe_set("o", "background", "dark")
|
|
||||||
change = maybe_set("g", "colors_name", env_color) or change
|
|
||||||
elseif mode == "light" then
|
|
||||||
env_color = utils.env_default("VIM_COLOR_LIGHT", env_color)
|
|
||||||
change = maybe_set("o", "background", "light")
|
|
||||||
change = maybe_set("g", "colors_name", env_color) or change
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Update status line theme
|
|
||||||
if change and vim.fn.exists(":AirlineRefresh") == 1 then
|
|
||||||
vim.cmd(":AirlineRefresh")
|
|
||||||
elseif change and _G["packer_plugins"] ~= nil and packer_plugins["lualine"] and packer_plugins["lualine"].loaded then
|
|
||||||
local lualine_theme = vim.g.colors_name
|
|
||||||
if lualine_theme == "solarized" then
|
|
||||||
lualine_theme = lualine_theme .. "_" .. mode
|
|
||||||
end
|
|
||||||
require("plugins.lualine").config_lualine(lualine_theme)
|
|
||||||
end
|
|
||||||
|
|
||||||
return changed and "Changed color to " .. env_color .. " with mode " .. mode or "No change"
|
|
||||||
end
|
|
||||||
-- utils.autocmd("auto_colors", "FocusGained * call v:lua.update_colors()")
|
|
||||||
|
|
||||||
-- Initial set of colors
|
|
||||||
-- TODO: if update_colors() is removed, use the env color fetching and set the colorscheme here
|
|
||||||
update_colors()
|
|
||||||
|
|
||||||
require("plugins")
|
require("plugins")
|
||||||
|
@ -10,44 +10,6 @@ end
|
|||||||
|
|
||||||
-- Requires :PackerCompile for "config" to be loaded
|
-- Requires :PackerCompile for "config" to be loaded
|
||||||
|
|
||||||
-- TODO: Get rid of if airline goes
|
|
||||||
local function config_airline()
|
|
||||||
-- Use short-form mode text
|
|
||||||
vim.g.airline_mode_map = {
|
|
||||||
['__'] = '-',
|
|
||||||
['n'] = 'N',
|
|
||||||
['i'] = 'I',
|
|
||||||
['R'] = 'R',
|
|
||||||
['c'] = 'C',
|
|
||||||
['v'] = 'V',
|
|
||||||
['V'] = 'V',
|
|
||||||
[''] = 'V',
|
|
||||||
['s'] = 'S',
|
|
||||||
['S'] = 'S',
|
|
||||||
[''] = 'S',
|
|
||||||
['t'] = 'T',
|
|
||||||
}
|
|
||||||
|
|
||||||
-- abbreviate trailing whitespace and mixed indent
|
|
||||||
vim.g["airline#extensions#whitespace#trailing_format"] = "tw[%s]"
|
|
||||||
vim.g["airline#extensions#whitespace#mixed_indent_format"] = "i[%s]"
|
|
||||||
-- Vertical separators for all
|
|
||||||
vim.g.airline_left_sep=''
|
|
||||||
vim.g.airline_left_alt_sep=''
|
|
||||||
vim.g.airline_right_sep=''
|
|
||||||
vim.g.airline_right_alt_sep=''
|
|
||||||
vim.g["airline#extensions#tabline#enabled"] = 1
|
|
||||||
vim.g["airline#extensions#tabline#left_sep"] = " "
|
|
||||||
vim.g["airline#extensions#tabline#left_alt_sep"] = "|"
|
|
||||||
-- Slimmer section z
|
|
||||||
vim.g.airline_section_z = "%2l/%L:%2v"
|
|
||||||
-- Skip most common encoding
|
|
||||||
vim.g["airline#parts#ffenc#skip_expected_string"] = "utf-8[unix]"
|
|
||||||
-- If UTF-8 symbols don't work, use ASCII
|
|
||||||
-- vim.g.airline_symbols_ascii = 1
|
|
||||||
vim.g["airline#extensions#nvimlsp#enabled"] = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Configures dark-notify to use colors from my environment
|
-- Configures dark-notify to use colors from my environment
|
||||||
local function config_dark_notify()
|
local function config_dark_notify()
|
||||||
local default_color = "solarized"
|
local default_color = "solarized"
|
||||||
@ -95,7 +57,7 @@ return require('packer').startup(function()
|
|||||||
}
|
}
|
||||||
use {
|
use {
|
||||||
"tpope/vim-fugitive",
|
"tpope/vim-fugitive",
|
||||||
cmd = { "Git", "Gstatus", "Gblame", "Gpush", "Gpull" },
|
-- cmd = { "Git", "Gstatus", "Gblame", "Gpush", "Gpull" },
|
||||||
}
|
}
|
||||||
use {
|
use {
|
||||||
"milkypostman/vim-togglelist",
|
"milkypostman/vim-togglelist",
|
||||||
@ -106,8 +68,17 @@ return require('packer').startup(function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- UI
|
-- UI
|
||||||
|
use "~/workspace/ez-colors.nvim/wombat"
|
||||||
|
use {
|
||||||
|
"~/workspace/wombuddy",
|
||||||
|
requires = "tjdevries/colorbuddy.vim",
|
||||||
|
}
|
||||||
use "vim-scripts/wombat256.vim"
|
use "vim-scripts/wombat256.vim"
|
||||||
use "ishan9299/nvim-solarized-lua"
|
use "ishan9299/nvim-solarized-lua"
|
||||||
|
use {
|
||||||
|
"norcalli/nvim-colorizer.lua",
|
||||||
|
config = function() require("colorizer").setup() end,
|
||||||
|
}
|
||||||
--[[
|
--[[
|
||||||
use {
|
use {
|
||||||
"shaunsingh/solarized.nvim",
|
"shaunsingh/solarized.nvim",
|
||||||
@ -125,7 +96,7 @@ return require('packer').startup(function()
|
|||||||
--[[
|
--[[
|
||||||
use {
|
use {
|
||||||
"vim-airline/vim-airline",
|
"vim-airline/vim-airline",
|
||||||
config = config_airline,
|
config = function() require("plugins.airline") end,
|
||||||
requires = { "vim-airline/vim-airline-themes", opt = true },
|
requires = { "vim-airline/vim-airline-themes", opt = true },
|
||||||
}
|
}
|
||||||
--]]
|
--]]
|
||||||
@ -155,6 +126,15 @@ return require('packer').startup(function()
|
|||||||
"glepnir/lspsaga.nvim",
|
"glepnir/lspsaga.nvim",
|
||||||
requires = { "neovim/nvim-lspconfig" },
|
requires = { "neovim/nvim-lspconfig" },
|
||||||
}
|
}
|
||||||
|
--[[
|
||||||
|
use {
|
||||||
|
"SmiteshP/nvim-gps",
|
||||||
|
requires = "nvim-treesitter/nvim-treesitter"
|
||||||
|
}
|
||||||
|
--]]
|
||||||
|
|
||||||
|
-- Writing
|
||||||
|
-- abolish/pencil
|
||||||
|
|
||||||
-- Treesitter
|
-- Treesitter
|
||||||
use {
|
use {
|
||||||
@ -254,6 +234,11 @@ return require('packer').startup(function()
|
|||||||
}
|
}
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
|
use {
|
||||||
|
"dense-analysis/ale",
|
||||||
|
config = function() require("utils").require_with_local("plugins.ale") end,
|
||||||
|
}
|
||||||
|
|
||||||
-- Debuging nvim config
|
-- Debuging nvim config
|
||||||
use {
|
use {
|
||||||
"tweekmonster/startuptime.vim",
|
"tweekmonster/startuptime.vim",
|
||||||
|
38
neovim/lua/plugins/airline.lua
Normal file
38
neovim/lua/plugins/airline.lua
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
local function config_airline()
|
||||||
|
-- Use short-form mode text
|
||||||
|
vim.g.airline_mode_map = {
|
||||||
|
['__'] = '-',
|
||||||
|
['n'] = 'N',
|
||||||
|
['i'] = 'I',
|
||||||
|
['R'] = 'R',
|
||||||
|
['c'] = 'C',
|
||||||
|
['v'] = 'V',
|
||||||
|
['V'] = 'V',
|
||||||
|
[''] = 'V',
|
||||||
|
['s'] = 'S',
|
||||||
|
['S'] = 'S',
|
||||||
|
[''] = 'S',
|
||||||
|
['t'] = 'T',
|
||||||
|
}
|
||||||
|
|
||||||
|
-- abbreviate trailing whitespace and mixed indent
|
||||||
|
vim.g["airline#extensions#whitespace#trailing_format"] = "tw[%s]"
|
||||||
|
vim.g["airline#extensions#whitespace#mixed_indent_format"] = "i[%s]"
|
||||||
|
-- Vertical separators for all
|
||||||
|
vim.g.airline_left_sep=''
|
||||||
|
vim.g.airline_left_alt_sep=''
|
||||||
|
vim.g.airline_right_sep=''
|
||||||
|
vim.g.airline_right_alt_sep=''
|
||||||
|
vim.g["airline#extensions#tabline#enabled"] = 1
|
||||||
|
vim.g["airline#extensions#tabline#left_sep"] = " "
|
||||||
|
vim.g["airline#extensions#tabline#left_alt_sep"] = "|"
|
||||||
|
-- Slimmer section z
|
||||||
|
vim.g.airline_section_z = "%2l/%L:%2v"
|
||||||
|
-- Skip most common encoding
|
||||||
|
vim.g["airline#parts#ffenc#skip_expected_string"] = "utf-8[unix]"
|
||||||
|
-- If UTF-8 symbols don't work, use ASCII
|
||||||
|
-- vim.g.airline_symbols_ascii = 1
|
||||||
|
vim.g["airline#extensions#nvimlsp#enabled"] = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
config_airline()
|
38
neovim/lua/plugins/ale.lua
Normal file
38
neovim/lua/plugins/ale.lua
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
vim.g["airline#extensions#ale#enabled"] = 1
|
||||||
|
vim.g.ale_lint_on_enter = 0
|
||||||
|
vim.g.ale_linters = {
|
||||||
|
-- go = { 'gopls', 'golint', 'golangci-lint' },
|
||||||
|
go = { "golangci-lint" },
|
||||||
|
-- rust = { 'rls', 'cargo' },
|
||||||
|
rust = { "cargo" },
|
||||||
|
-- sh = { 'language_server', 'shell', 'shellcheck' },
|
||||||
|
sh = { "shell", "shellcheck" },
|
||||||
|
text = { "proselint", "alex" },
|
||||||
|
}
|
||||||
|
vim.g.ale_linter_aliases = {
|
||||||
|
markdown = { "text" },
|
||||||
|
}
|
||||||
|
local pretty_trim_fixer = {
|
||||||
|
"prettier",
|
||||||
|
"trim_whitespace",
|
||||||
|
"remove_trailing_lines"
|
||||||
|
}
|
||||||
|
vim.g.ale_fixers = {
|
||||||
|
["*"] = { "trim_whitespace", "remove_trailing_lines" },
|
||||||
|
-- go = { "gofmt", "goimports" },
|
||||||
|
json = pretty_trim_fixer,
|
||||||
|
-- rust = { "rustfmt" },
|
||||||
|
--[[
|
||||||
|
python = {
|
||||||
|
"black",
|
||||||
|
"autopep8",
|
||||||
|
"reorder-python-imports",
|
||||||
|
"remove_trailing_lines",
|
||||||
|
"trim_whitespace",
|
||||||
|
},
|
||||||
|
--]]
|
||||||
|
markdown = pretty_trim_fixer,
|
||||||
|
yaml = { "prettier", "remove_trailing_lines" },
|
||||||
|
css = pretty_trim_fixer,
|
||||||
|
javascript = pretty_trim_fixer,
|
||||||
|
}
|
@ -46,9 +46,9 @@ function M.mixed_indent()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.trailing_whitespace()
|
function M.trailing_whitespace()
|
||||||
local count = vim.fn.search([[\s\+$]], 'nw')
|
local line = vim.fn.search([[\s\+$]], 'nw')
|
||||||
if count ~= 0 then
|
if line ~= 0 then
|
||||||
return "tw:" .. count
|
return "tw:" .. line
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -56,29 +56,32 @@ end
|
|||||||
|
|
||||||
-- Configure lualine witha provided theme
|
-- Configure lualine witha provided theme
|
||||||
function M.config_lualine(theme_name)
|
function M.config_lualine(theme_name)
|
||||||
|
-- Theme name transformations
|
||||||
if theme_name == nil then
|
if theme_name == nil then
|
||||||
theme_name = "auto"
|
theme_name = "auto"
|
||||||
elseif theme_name == "wombat256mod" then
|
elseif theme_name == "wombat256mod" then
|
||||||
theme_name = "wombat"
|
theme_name = "wombat"
|
||||||
|
elseif theme_name == "wombuddy" then
|
||||||
|
theme_name = "wombat"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
require("lualine").setup {
|
require("lualine").setup {
|
||||||
options = {
|
options = {
|
||||||
theme = theme_name,
|
theme = theme_name,
|
||||||
icons_enabled = false,
|
icons_enabled = false,
|
||||||
component_separators = {"|", "|"},
|
component_separators = {"|", "|"},
|
||||||
section_separators = {" ", " "},
|
section_separators = {"", ""},
|
||||||
},
|
},
|
||||||
sections = {
|
sections = {
|
||||||
lualine_a = { M.single_letter_mode },
|
lualine_a = { M.single_letter_mode },
|
||||||
lualine_b = { "branch", "diff" },
|
lualine_b = { "FugitiveHead", "diff" },
|
||||||
lualine_c = { "filename" },
|
lualine_c = { "filename" },
|
||||||
lualine_x = { M.custom_ffenc, "filetype" },
|
lualine_x = { M.custom_ffenc, "filetype" },
|
||||||
lualine_y = { "progress", "location" },
|
lualine_y = { "progress", "location" },
|
||||||
lualine_z = {
|
lualine_z = {
|
||||||
{ "diagnostics", sources = { "nvim_lsp" } },
|
{ "diagnostics", sources = { "nvim_lsp" } },
|
||||||
M.mixed_indent, M.trailing_whitespace,
|
{ M.mixed_indent, color = { bg = "#de4f1f" } },
|
||||||
|
{ M.trailing_whitespace, color = { bg = "#de4f1f" } },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user