summary refs log tree commit diff
path: root/.vim/lua
diff options
context:
space:
mode:
Diffstat (limited to '.vim/lua')
-rw-r--r--.vim/lua/conf/colors.lua9
-rw-r--r--.vim/lua/conf/diagnostic.lua17
-rw-r--r--.vim/lua/conf/lsp.lua51
-rw-r--r--.vim/lua/conf/telescope.lua75
-rw-r--r--.vim/lua/conf/treesitter.lua21
-rw-r--r--.vim/lua/init.lua4
-rw-r--r--.vim/lua/line.lua146
-rw-r--r--.vim/lua/misc.lua18
-rw-r--r--.vim/lua/plugins.lua142
9 files changed, 483 insertions, 0 deletions
diff --git a/.vim/lua/conf/colors.lua b/.vim/lua/conf/colors.lua
new file mode 100644
index 0000000..65d1fb1
--- /dev/null
+++ b/.vim/lua/conf/colors.lua
@@ -0,0 +1,9 @@
+
+local lush = require('lush')
+local hsl = lush.hsl
+
+return lush(function()
+	return {
+		Normal { bg = hsl}
+	}
+end)
diff --git a/.vim/lua/conf/diagnostic.lua b/.vim/lua/conf/diagnostic.lua
new file mode 100644
index 0000000..4fd5047
--- /dev/null
+++ b/.vim/lua/conf/diagnostic.lua
@@ -0,0 +1,17 @@
+
+vim.g.diagnostic_enable_virtual_text = 1
+vim.g.diagnostic_trimmed_virtual_text = '40'
+vim.g.diagnostic_insert_delay = 1
+vim.api.nvim_command('nnoremap <silent> c[ <cmd>PrevDiagnosticCycle<cr>')
+vim.api.nvim_command('nnoremap <silent> c] <cmd>NextDiagnosticCycle<cr>')
+
+
+vim.fn.sign_define("LspDiagnosticsErrorSign", {text="✘", texthl="LspDiagnosticsError"})
+vim.fn.sign_define("LspDiagnosticsWarningSign", {text="‼", texthl="LspDiagnosticsWarning"})
+vim.fn.sign_define("LspDiagnosticsInformationSign", {text="i", texthl="LspDiagnosticsInformation"})
+vim.fn.sign_define("LspDiagnosticsHintSign", {text="☛",texthl="LspDiagnosticsHint"})
+
+vim.api.nvim_command('highlight link LspDiagnosticsError Error')
+vim.api.nvim_command('highlight link LspDiagnosticsWarning WarningMsg')
+vim.api.nvim_command('highlight link LspDiagnosticsInformation Todo')
+vim.api.nvim_command('highlight link LspDiagnosticsHint Question')
diff --git a/.vim/lua/conf/lsp.lua b/.vim/lua/conf/lsp.lua
new file mode 100644
index 0000000..4249de5
--- /dev/null
+++ b/.vim/lua/conf/lsp.lua
@@ -0,0 +1,51 @@
+-- lsp config
+
+local lsp     = require 'lspconfig'
+local util    = require 'lspconfig.util'
+
+local function my_attach(client)
+	-- attach completion
+	require 'completion'.on_attach(client)
+
+	-- do lsp mappings
+	vim.fn.nvim_buf_set_keymap(0, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>',
+		{noremap=true, silent=true})
+	vim.fn.nvim_buf_set_keymap(0, 'n', '<c-]>', '<cmd>lua vim.lsp.buf.definition()<cr>',
+		{noremap=true, silent=true})
+	vim.fn.nvim_buf_set_keymap(0, 'n', 'grr', '<cmd>lua vim.lsp.buf.rename()<cr>',
+		{noremap=true, silent=true})
+	vim.fn.nvim_buf_set_keymap(0, 'i', '<c-h>', '<cmd>lua vim.lsp.buf.signature_help()<cr>',
+		{noremap=true, silent=true})
+
+	-- nnoremap <silent> gD <cmd> lua vim.lsp.buf.declaration()<CR>
+	-- nnoremap <silent> gd <cmd> lua vim.lsp.buf.definition()<CR>
+	-- nnoremap <silent> gT <cmd> lua vim.lsp.buf.type_definition()<CR>
+	-- nnoremap <silent> gI <cmd> lua vim.lsp.buf.implementation()<CR>
+	-- nnoremap <silent> gr <cmd> lua vim.lsp.buf.references()<CR>
+	-- nnoremap <silent> g0 <cmd> lua vim.lsp.buf.document_symbol()<CR>
+	-- nnoremap <silent> gW <cmd> lua vim.lsp.buf.workspace_symbol()<CR>
+	-- nnoremap <silent> ;h <cmd> lua vim.lsp.buf.hover()<CR>
+	-- nnoremap <silent> ;s <cmd> lua vim.lsp.buf.signature_help()<CR>
+end
+
+-- lsp.ccls.setup{
+-- 	on_attach = my_attach,
+-- }
+
+lsp.gopls.setup{
+	on_attach = my_attach,
+	root_dir = util.root_pattern('go.mod', '.git'),
+	-- NOTE: this is done to avoid the gopls warning about being outside gopath
+	-- message_level = vim.lsp.protocol.MessageType.Error,
+}
+
+lsp.sumneko_lua.setup{
+	cmd = { 'lua-language-server' };
+	on_attach = my_attach;
+}
+
+lsp.rust_analyzer.setup{
+	cmd = { 'env', 'CARGO_TARGET_DIR=/tmp', 'rust-analyzer' },
+	on_attach = my_attach,
+
+}
diff --git a/.vim/lua/conf/telescope.lua b/.vim/lua/conf/telescope.lua
new file mode 100644
index 0000000..e1145c2
--- /dev/null
+++ b/.vim/lua/conf/telescope.lua
@@ -0,0 +1,75 @@
+-- config for telescope.nvim
+local telescope  = require('telescope')
+local finders    = require('telescope.finders')
+local pickers    = require('telescope.pickers')
+local previewers = require('telescope.previewers')
+local make_entry = require('telescope.make_entry')
+local sorters    = require('telescope.sorters')
+
+telescope.setup{
+	defaults = {
+		borderchars = {'─', '│', '─', '│', '┌', '┐', '┘', '└'},
+		winblend = 3,
+		layout_strategy = 'flex',
+	}
+}
+
+vim.api.nvim_set_keymap('n', ';f', "<cmd>lua require'telescope.builtin'.find_files{}<cr>",
+	{noremap=true, silent=true})
+vim.api.nvim_set_keymap('n', ';g', "<cmd>lua require'telescope.builtin'.live_grep{}<cr>",
+	{noremap=true, silent=true})
+vim.api.nvim_set_keymap('n', ';r', "<cmd>lua require'telescope.builtin'.lsp_references{}<cr>",
+	{noremap=true, silent=true})
+vim.api.nvim_set_keymap('n', ';q', "<cmd>lua require'telescope.builtin'.quickfix{}<cr>",
+	{noremap=true, silent=true})
+vim.api.nvim_set_keymap('n', ';l', "<cmd>lua require'telescope.builtin'.loclist{}<cr>",
+	{noremap=true, silent=true})
+vim.api.nvim_set_keymap('n', ';b', "<cmd>lua require'telescope.builtin'.buffers{}<cr>",
+	{noremap=true, silent=true})
+-- vim.api.nvim_set_keymap('n', ';h', "<cmd>lua require'conf.telescope'.home{}<cr>",
+-- 	{noremap=true, silent=true})
+vim.api.nvim_set_keymap('n', ';w', "<cmd>lua require'conf.telescope'.wiki{}<cr>",
+	{noremap=true, silent=true})
+
+local M = {}
+M.fzf = function(opts)
+	opts = opts or {}
+	if opts.cwd then
+		opts.cwd = vim.fn.expand(opts.cwd)
+	end
+	local cmd = {'fd', '--type', 'f', '--no-ignore', '--absolute-path'}
+	if opts.extensions then
+		for _, ext in ipairs(opts.extensions) do
+			table.insert(cmd, '--extension')
+			table.insert(cmd, ext)
+		end
+	end
+	if opts.exclude then
+		for _, excl in ipairs(opts.exclude) do
+			table.insert(cmd, '--exclude')
+			table.insert(cmd, excl)
+		end
+	end
+	pickers.new(opts, {
+		prompt = opts.prompt or "FZF",
+		finder = finders.new_oneshot_job(cmd, opts),
+		previewer = previewers.cat.new(opts),
+		sorter = sorters.get_fuzzy_file(),
+	}):find()
+end
+
+M.wiki = function()
+	return M.fzf {
+		prompt = 'WIKI',
+		cwd = '~/wiki',
+		extensions = {'md'},
+		exclude = {'_templates/*'}
+	}
+end
+-- M.home = function()
+-- 	return M.fzf {
+-- 		prompt = 'HOME',
+-- 		cwd = '~',
+-- 	}
+-- end
+return M
diff --git a/.vim/lua/conf/treesitter.lua b/.vim/lua/conf/treesitter.lua
new file mode 100644
index 0000000..79763b8
--- /dev/null
+++ b/.vim/lua/conf/treesitter.lua
@@ -0,0 +1,21 @@
+
+require 'nvim-treesitter.configs'.setup {
+	ensure_installed = { "c", "c_sharp", "lua", "bash" },
+	highlight = {
+		enable = false,
+	},
+	refactor = {
+		navigation = {
+			enable = true,
+			keymaps = {
+				goto_definition = "<c-]>",
+			},
+		},
+		smart_rename = {
+			enable = true,
+			keymaps = {
+				smart_rename = "grr",
+			},
+		},
+	},
+}
diff --git a/.vim/lua/init.lua b/.vim/lua/init.lua
new file mode 100644
index 0000000..0397b28
--- /dev/null
+++ b/.vim/lua/init.lua
@@ -0,0 +1,4 @@
+-- init lua
+
+require 'plugins'
+require 'conf.diagnostic'
diff --git a/.vim/lua/line.lua b/.vim/lua/line.lua
new file mode 100644
index 0000000..278782f
--- /dev/null
+++ b/.vim/lua/line.lua
@@ -0,0 +1,146 @@
+-- statusline
+
+local gl  = require('galaxyline')
+local gls = gl.section
+local gcolors = require('galaxyline.colors')
+
+local colors = {
+  blue = '#5fafd7',
+  orange = '#d7875f',
+  purple = '#af87d7',
+  yellow = '#d7af5f',
+
+  black = '#1c1c1c',
+  grey_dim = '#3a3a3a',
+  grey_dimmer = '#262626',
+  white = '#d0d0d0',
+  white_dim = '#bdc0ba',
+}
+
+local style = {
+  left = {
+    sep = ' ',
+    sep_hl = {colors.white, colors.black},
+  },
+  right = {
+    hl = {colors.white,colors.grey_dimmer},
+    sep = ' ',
+    sep_hl = {colors.grey_dim, colors.grey_dimmer},
+  }
+}
+
+local empty_buffer = function()
+  if vim.fn.empty(vim.fn.expand('%:t')) ~= 1 then
+    return true
+  end
+    return false
+end
+
+local space = function() return ' ' end
+
+gls.left[1] = {
+  ViMode = {
+    provider = function()
+      local m = vim.fn.mode()
+      if m == 'n' then
+        gcolors.set_highlight('GalaxyViMode', {colors.white, colors.grey_dim, 'bold'})
+      elseif m == 'i' then
+        gcolors.set_highlight('GalaxyViMode', {colors.black, colors.blue, 'bold'})
+      elseif m == 'v' or m == 'V' or m == 'CTRL-V' then
+        gcolors.set_highlight('GalaxyViMode', {colors.black, colors.purple, 'bold'})
+      elseif m == 's' or m == 'S' or m == 'CTRL-S' then
+        gcolors.set_highlight('GalaxyViMode', {colors.black, '#ff0000', 'bold'})
+      elseif m == 'R' or m == 'Rc' or m == 'Rv' or m == 'Rx' then
+        gcolors.set_highlight('GalaxyViMode', {colors.black, colors.orange, 'bold'})
+      elseif m == 'c' then
+        gcolors.set_highlight('GalaxyViMode', {colors.yellow, colors.grey_dim, 'bold,italic'})
+      end
+      return '  ' .. m:gsub("^%l*$", string.upper) .. ' '
+    end,
+    separator = style.left.sep,
+    separator_highlight = style.left.sep_hl,
+  },
+}
+
+gls.left[2] = {
+  FileName = {
+    provider = function()
+      local file = vim.fn.expand('%:t')
+      if vim.fn.empty(file) == 1 then return '' end
+      if vim.bo.readonly then
+        return file .. ' '
+      end
+      if vim.o.modifiable then
+        if vim.bo.modified then
+          return file .. ' +'
+        end
+      end
+      return file .. ' '
+    end,
+    condition = empty_buffer,
+    highlight = {colors.white,colors.grey_dimmer},
+    separator = style.left.sep,
+    separator_highlight = style.left.sep_hl,
+  }
+}
+
+-- ########################################################## --
+
+gls.right[1] = {
+  Indent = {
+    provider = function()
+      local res = vim.o.expandtab and '→' or '␣'
+      return res
+        .. ' '
+        .. 'ts=' .. vim.o.tabstop
+        .. ' '
+        .. 'sw=' .. vim.o.shiftwidth
+    end,
+    highlight = style.right.hl,
+  },
+}
+
+gls.right[2] = {
+  BufNum = {
+    icon = '% ',
+    provider = function()
+      local nbufs = #vim.fn.getbufinfo({buflisted = 1})
+      local res = vim.fn.bufnr('%') .. '(' .. nbufs .. ')'
+      if vim.fn.tabpagenr() > 1 then
+        res = res .. ':' .. vim.fn.tabpagenr()
+      end
+      return res
+    end,
+    highlight = style.right.hl,
+    separator = style.right.sep,
+    separator_highlight = style.right.sep_hl,
+  },
+}
+
+gls.right[3] = {
+  LineColumn = {
+    icon = ' ',
+    provider = 'LineColumn',
+    highlight = style.right.hl,
+    separator = style.right.sep,
+    separator_highlight = style.right.sep_hl,
+  },
+}
+
+gls.right[4] = {
+  LinePercent = {
+    provider = 'LinePercent',
+    highlight = style.right.hl,
+    separator = style.right.sep,
+    separator_highlight = style.right.sep_hl,
+  }
+}
+
+gls.right[5] = {
+  BufferType = {
+    provider = function() return '  ' .. vim.bo.filetype .. ' ' end,
+    highlight = {colors.white,colors.grey_dim,'bold'},
+    -- separator = style.right.sep,
+    -- separator_highlight = style.right.sep_hl,
+  }
+}
diff --git a/.vim/lua/misc.lua b/.vim/lua/misc.lua
new file mode 100644
index 0000000..8b26ed1
--- /dev/null
+++ b/.vim/lua/misc.lua
@@ -0,0 +1,18 @@
+-- misc stuff implemented in lua
+
+local M = {}
+
+function M.open_under_cursor(cmd)
+  local txt = vim.fn.expand('<cfile>')
+  local txt = vim.fn.expand(txt)
+  if not cmd then
+    vim.fn.inputsave()
+    cmd = vim.fn.input('open with: ')
+    vim.fn.inputrestore()
+  end
+  if cmd then
+    c = vim.loop.spawn(cmd, { args = {txt} }, function() c:close() end)
+  end
+end
+
+return M
diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua
new file mode 100644
index 0000000..1a66299
--- /dev/null
+++ b/.vim/lua/plugins.lua
@@ -0,0 +1,142 @@
+-- load by calling `lua require('plugins')` from your init.vim
+
+function disable_distribution_plugins()
+  vim.g.loaded_gzip              = 1
+  vim.g.loaded_tar               = 1
+  vim.g.loaded_tarPlugin         = 1
+  vim.g.loaded_zip               = 1
+  vim.g.loaded_zipPlugin         = 1
+  vim.g.loaded_getscript         = 1
+  vim.g.loaded_getscriptPlugin   = 1
+  vim.g.loaded_vimball           = 1
+  vim.g.loaded_vimballPlugin     = 1
+  vim.g.loaded_matchit           = 1
+  vim.g.loaded_matchparen        = 1
+  vim.g.loaded_2html_plugin      = 1
+  vim.g.loaded_logiPat           = 1
+  vim.g.loaded_rrhelper          = 1
+  vim.g.loaded_netrw             = 1
+  vim.g.loaded_netrwPlugin       = 1
+  vim.g.loaded_netrwSettings     = 1
+  vim.g.loaded_netrwFileHandlers = 1
+end
+
+-- enable to bootstrap packer from ~/.local/share/nvim/site/pack/packer/opt/packer.nvim
+-- vim.cmd [[packadd packer.nvim]]
+
+return require'packer'.startup(function()
+	-- disable built-in plugins
+	disable_distribution_plugins()
+
+	-- manage packer itself
+	use {'wbthomason/packer.nvim'}
+
+	use {'mhinz/vim-signify'}      -- git status in the sign column
+	use {'tpope/vim-commentary'}   -- auto-comment using `gcc`
+	use {'cohama/lexima.vim'}      -- auto-close parens, brackets, etc.
+	use {'tpope/vim-surround'}     -- edit surroundings in pairs
+	-- use {'itchyny/lightline.vim'}  -- lightweight status bar
+	use {'glepnir/galaxyline.nvim',
+		branch = 'main',
+		config=function() require 'line' end}
+	use {'neomake/neomake'}        -- async job runner
+	use {'sbdchd/neoformat'}       -- async code formatter
+	use {'justinmk/vim-dirvish'}   -- folder browser
+	use {'justinmk/vim-sneak'}     -- powerful missing vim motions
+
+	use { 'neovim/nvim-lspconfig',
+		requires = {'nvim-lua/completion-nvim'}, -- , 'nvim-lua/diagnostic-nvim'},
+		config=function() require'conf.lsp' end}
+
+	use { 'steelsojka/completion-buffers' }
+		-- config = function()
+		-- 	vim.api.nvim_command("autocmd BufEnter * require'completion'.on_attach()")
+		-- end}
+
+	use { 'nvim-treesitter/nvim-treesitter',
+		requires = {
+			'nvim-lua/completion-nvim',
+			'nvim-treesitter/completion-treesitter',
+			'nvim-treesitter/nvim-treesitter-refactor',
+		},
+		config=function() require'conf.treesitter' end}
+	
+	use { 'nvim-lua/telescope.nvim',
+		requires = {'nvim-lua/popup.nvim', 'nvim-lua/plenary.nvim'},
+		config=function() require'conf.telescope' end}
+
+	-- snippets
+	use {'SirVer/ultisnips',
+		requires = {'honza/vim-snippets'}}
+
+	-- interactive finder / dispatcher
+	-- use {'liuchengxu/vim-clap',
+	-- 	run = ':Clap install-binary!'}
+
+	use {'junegunn/vim-easy-align',
+		cmd = {'EasyAlign'}}
+
+	-- use {'tpope/vim-sleuth'}                -- detect indentation
+	use {'nathanaelkane/vim-indent-guides'} -- show indentation levels
+	use {'tpope/vim-repeat'}                -- extend '.' to plugins
+	use {'liuchengxu/vista.vim'}            -- sidebar populated by lsp, ctags, etc.
+	use {'sgur/vim-editorconfig'}           -- implements editorconfig in vimscript
+	-- use 'rhysd/conflict-marker.vim'
+	use {'michaeljsmith/vim-indent-object'} -- adds indentation text-objects
+	use {'kshenoy/vim-signature'}           -- toggle, display and navigate marks
+	-- highlight color codes
+	use {'norcalli/nvim-colorizer.lua',
+		config=function()
+			require'colorizer'.setup(nil, {
+					name = true;
+					RRGGBB = true;
+					RRGGBBAA = false;
+					rgb_fn = true;
+					hsl_fn = true;
+					mode = 'background';
+				})
+		end}
+	use {'rhysd/git-messenger.vim'}         -- git-blame in a popup
+	use {'kassio/neoterm'}
+
+	-- languages
+	-- NOTE: these should only be loaded when they are required...
+	-- use {'rhysd/vim-grammarous',       ft = {'markdown', 'latex', 'tex'}}
+	use {'lervag/vimtex',                 ft = {'latex', 'tex'}}
+	use {'plasticboy/vim-markdown',       ft = {'markdown'}}
+	use {'masukomi/vim-markdown-folding', ft = {'markdown'}}
+	-- easy html editing
+	use {'mattn/emmet-vim',               ft = {'html'}}
+	-- use {'valloric/matchtagalways',    ft = {'html', 'vue', 'xml'}} -- visually match HTML tags enclosing cursor location
+	-- use {'ledger/vim-ledger',             ft = {'ledger'},
+	-- 	requires = {
+	-- 		'tpope/vim-speeddating',   -- easy time/date incrementing
+	-- 		'vim-scripts/utl.vim'}}    -- follow links/urls
+	
+	use {'gentoo/gentoo-syntax'}
+	use {'jjo/vim-cue'}
+
+	-- multi-language support with lazy loading
+	-- NOTE: put language specific plugs before this to avoid conflicsts
+	use {'sheerun/vim-polyglot'}
+		
+	-- minimal ux
+	use {'junegunn/goyo.vim',         cmd = 'Goyo'}      -- hide ui clutter
+	use {'junegunn/limelight.vim',    cmd = 'Limelight'} -- dims colors
+	-- use 'equalsraf/neovim-gui-shim'
+
+	-- colorschemes
+	use {'NLKNguyen/papercolor-theme'}
+	-- use {'cideM/yui'}
+	use {'ayu-theme/ayu-vim'}
+	-- use {'rktjmp/lush.nvim',
+	-- 	config=function() require'conf.colors' end}
+
+	use {'dstein64/vim-startuptime'}
+
+	-- local
+	-- use {'~/devel/projects/nihon-theme/vim'}
+	-- use {'~/devel/projects/vim-orgdown'}
+	use {'~/.vim/devel/obsidian.nvim'}
+	use {'~/.vim/devel/vim-github-link'}
+end)