summaryrefslogtreecommitdiffstats
path: root/.config/nvim/lua
diff options
context:
space:
mode:
authorRomain Gonçalves <me@rgoncalves.se>2021-12-23 18:28:03 +0000
committerRomain Gonçalves <me@rgoncalves.se>2021-12-23 18:28:03 +0000
commit0f08d04698c814955116b6bae50752e64b774d8f (patch)
tree8cf9a33557093eebfd25aab2872e97639c7e2f62 /.config/nvim/lua
downloaddots-0f08d04698c814955116b6bae50752e64b774d8f.tar.gz
Thu Dec 23 06:28:03 PM UTC 2021
Diffstat (limited to '.config/nvim/lua')
-rwxr-xr-x.config/nvim/lua/ftplugin/common-markup.lua3
-rwxr-xr-x.config/nvim/lua/ftplugin/common-space.lua5
-rwxr-xr-x.config/nvim/lua/ftplugin/init.lua2
-rwxr-xr-x.config/nvim/lua/keymaps.lua24
-rwxr-xr-x.config/nvim/lua/lsp.lua17
-rwxr-xr-x.config/nvim/lua/plugins.lua145
-rwxr-xr-x.config/nvim/lua/settings.lua30
-rwxr-xr-x.config/nvim/lua/statusline.lua54
-rwxr-xr-x.config/nvim/lua/utils.lua46
9 files changed, 326 insertions, 0 deletions
diff --git a/.config/nvim/lua/ftplugin/common-markup.lua b/.config/nvim/lua/ftplugin/common-markup.lua
new file mode 100755
index 0000000..956a163
--- /dev/null
+++ b/.config/nvim/lua/ftplugin/common-markup.lua
@@ -0,0 +1,3 @@
+bo.expandtab = true
+bo.shiftwidth = 2
+bo.tabstop = 2
diff --git a/.config/nvim/lua/ftplugin/common-space.lua b/.config/nvim/lua/ftplugin/common-space.lua
new file mode 100755
index 0000000..ccefb94
--- /dev/null
+++ b/.config/nvim/lua/ftplugin/common-space.lua
@@ -0,0 +1,5 @@
+bo.tabstop=4
+bo.shiftwidth=4
+bo.textwidth=0
+bo.wrapmargin=0
+bo.expandtab = true
diff --git a/.config/nvim/lua/ftplugin/init.lua b/.config/nvim/lua/ftplugin/init.lua
new file mode 100755
index 0000000..906b7a1
--- /dev/null
+++ b/.config/nvim/lua/ftplugin/init.lua
@@ -0,0 +1,2 @@
+package.path = package.path .. ';' .. vim.fn.stdpath('config') .. '/ftplugin/?.lua'
+package.path = package.path .. ';' .. vim.fn.stdpath('config') .. '/after/ftplugin/?.lua'
diff --git a/.config/nvim/lua/keymaps.lua b/.config/nvim/lua/keymaps.lua
new file mode 100755
index 0000000..070ddc9
--- /dev/null
+++ b/.config/nvim/lua/keymaps.lua
@@ -0,0 +1,24 @@
+--[[
+-- Keymaps
+--]]
+
+local map = vim.api.nvim_set_keymap
+local cmd = vim.cmd
+
+options = {noremap=true}
+
+map('i', '<C-h>', '<Left>', options)
+map('i', '<C-j>', '<Down>', options)
+map('i', '<C-k>', '<Up>', options)
+map('i', '<C-l>', '<Right>', options)
+map('i', '<C-l>', '<Right>', options)
+
+map('', '<C-n>', ':NvimTreeToggle<CR>', options)
+
+--[[
+map('n', '<silent><expr>', '<C-Space>', 'compe#complete()', options)
+map('n', '<silent><expr>', '<CR>', 'compe#confirm(\'<CR>\'', options)
+map('n', '<silent><expr>', '<C-e>', 'compe#close(\'<C-e>\'', options)
+map('n', '<silent><expr>', '<C-f>', 'compe#scroll({\'delta\': +4}', options)
+map('n', '<silent><expr>', '<C-d>', 'compe#scroll({\'delta\': -4}', options)
+--]]
diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua
new file mode 100755
index 0000000..95d9409
--- /dev/null
+++ b/.config/nvim/lua/lsp.lua
@@ -0,0 +1,17 @@
+--[[
+-- lsp
+--]]
+
+local lsp = vim.lsp
+
+lsp.handlers["textDocument/publishDiagnostics"] = lsp.with(
+ lsp.diagnostic.on_publish_diagnostics,
+ {
+ underline = false,
+ virtual_text = {
+ prefix = "▒ ",
+ spacing = 8,
+ },
+ signs = true,
+ }
+)
diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua
new file mode 100755
index 0000000..24736eb
--- /dev/null
+++ b/.config/nvim/lua/plugins.lua
@@ -0,0 +1,145 @@
+--[[
+-- Plugins
+--]]
+
+-- Bootstrap for Paq
+local install_path = vim.fn.stdpath('data')..'/site/pack/paqs/start/paq-nvim'
+if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
+ vim.fn.system({
+ 'git', 'clone', '--depth=1',
+ 'https://github.com/savq/paq-nvim.git',
+ install_path
+ })
+ vim.cmd 'packadd paq-nvim'
+end
+
+-- Enable Paq
+vim.cmd 'packadd paq-nvim'
+
+-- Plugin list
+require('paq') {
+ {'savq/paq-nvim'};
+
+ -- lsp
+ {
+ 'nvim-treesitter/nvim-treesitter',
+ run=':TSUpdate'
+ };
+ {
+ 'neovim/nvim-lspconfig',
+ run='python3 -m pipx install python-lsp-server[all]'
+ };
+ {
+ 'numirias/semshi',
+ run=':UpdateRemotePlugins'
+ };
+
+ -- utils
+ {'folke/trouble.nvim'};
+ {'hrsh7th/nvim-compe'};
+
+ -- org
+ {'TimUntersberger/neogit'};
+ {'kyazdani42/nvim-tree.lua'};
+
+ -- indent
+ {'lewis6991/gitsigns.nvim'};
+ {'glepnir/indent-guides.nvim'};
+ {'darazaki/indent-o-matic'};
+
+ -- dep
+ {'nvim-lua/plenary.nvim'};
+}
+
+-- Treesitter
+
+local parser_configs = require('nvim-treesitter.parsers').get_parser_configs()
+
+require('nvim-treesitter.configs').setup {
+ ensure_installed = 'maintained',
+ ignore_install = {
+ 'verilog',
+ 'kotlin'
+ },
+ highlight = {
+ enable = true,
+ }
+}
+
+-- completion
+
+require('compe').setup {
+ enabled = true,
+ source = {
+ path = true;
+ buffer = true;
+ calc = true;
+ nvim_lsp = true;
+ nvim_lua = true;
+ vsnip = true;
+ ultisnips = true;
+ luasnip = true;
+ neorg = true;
+ };
+}
+
+-- LSP configuration
+
+local lsputil = require('lspconfig/util')
+local python_venv = require('utils').get_python_venv()
+require('lspconfig').pylsp.setup{
+ cmd = {'pylsp', '-v'},
+ cmd_env = {
+ VIRTUAL_ENV = python_venv,
+ PATH = lsputil.path.join(python_venv, 'bin') .. ':' .. vim.env.PATH
+ },
+}
+
+require('lspconfig').clangd.setup{}
+require('lspconfig').eslint.setup{}
+require('lspconfig').terraformls.setup{}
+
+-- org
+
+require('trouble').setup{}
+require('neogit').setup{}
+
+-- syntactic sugar
+
+require('indent_guides').setup{
+ indent_enable=true;
+ exclude_filetypes={
+ 'help',
+ 'calendar',
+ 'NvimTree'
+ };
+}
+
+require('indent-o-matic').setup {
+ max_lines = 0,
+ standard_widths = { 2, 4, 8 },
+
+ filetype_typescript = {
+ max_lines = 4096,
+ },
+
+ filetype_javascript = {
+ max_lines = 4096,
+ },
+
+ filetype_ = {
+ standard_widths = { 2, 4 },
+ },
+}
+
+vim.g['semshi#update_delay_factor'] = 0.0001
+
+require('gitsigns').setup{
+ signs = {
+ add = {hl = 'GitSignsAdd' , text = '▍', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'},
+ change = {hl = 'GitSignsChange', text = '▍', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
+ delete = {hl = 'GitSignsDelete', text = '▍', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
+ topdelete = {hl = 'GitSignsDelete', text = '▍', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
+ changedelete = {hl = 'GitSignsChange', text = '▍', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
+ }
+}
diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua
new file mode 100755
index 0000000..2741c99
--- /dev/null
+++ b/.config/nvim/lua/settings.lua
@@ -0,0 +1,30 @@
+bo.expandtab = false
+bo.shiftwidth = 8
+bo.softtabstop = 8
+
+o.completeopt = 'longest,menuone'
+o.shell = '/bin/sh'
+o.encoding = 'utf-8'
+o.scrolloff = 3
+o.lazyredraw = true
+o.autochdir = true
+o.smarttab = true
+o.number = true
+o.list = true
+
+o.swapfile = false
+
+-- o.foldmethod = 'expr'
+-- o.foldexpr = 'nvim_treesitter#foldexpr()'
+
+cmd 'syntax enable'
+cmd 'filetype on'
+cmd 'filetype plugin on'
+cmd 'filetype indent on'
+cmd 'colorscheme colorscheme'
+
+vim.cmd([[
+au BufNewFile,BufRead *.Dockerfile,Dockerfile.* setlocal filetype=dockerfile
+au BufNewFile,BufRead *.j2*,*.jinja* setlocal filetype=django
+au BufNewFile,BufRead *.env* setlocal filetype=sh
+]])
diff --git a/.config/nvim/lua/statusline.lua b/.config/nvim/lua/statusline.lua
new file mode 100755
index 0000000..099d930
--- /dev/null
+++ b/.config/nvim/lua/statusline.lua
@@ -0,0 +1,54 @@
+--[[
+-- Statusline
+--]]
+
+local api = vim.api
+local cmd = vim.cmd
+local utils = require('utils')
+
+function _(str)
+ return '[' .. str .. ']'
+end
+
+function set_split()
+ return '%m%='
+end
+
+function get_separator()
+ return ' '
+end
+
+function get_file()
+ return '%f'
+end
+
+function get_fileformat()
+ return '%{&fileformat}'
+end
+
+function get_fileencoding()
+ return '%{&fileencoding?&fileencoding:&encoding}'
+end
+
+function get_scrollposition()
+ return '%p%%'
+end
+
+function get_cursorposition()
+ return '%l:%c'
+end
+
+function get_statusline()
+ return table.concat({
+ get_file(),
+ set_split(),
+ _(get_fileencoding()),
+ _(get_fileformat()),
+ _(get_scrollposition()),
+ _(get_cursorposition()),
+ })
+end
+
+-- Enable statusline
+utils.opt('o', 'laststatus', 2)
+utils.opt('o', 'statusline', get_statusline())
diff --git a/.config/nvim/lua/utils.lua b/.config/nvim/lua/utils.lua
new file mode 100755
index 0000000..ae164e8
--- /dev/null
+++ b/.config/nvim/lua/utils.lua
@@ -0,0 +1,46 @@
+local utils = {}
+
+local scopes = {o = vim.o, b = vim.bo, w = vim.wo}
+
+--- Apply a setting with a specified scope
+function utils.opt(scope, key, value)
+ scopes[scope][key] = value
+ if scope ~= 'o' then scopes['o'][key] = value end
+end
+
+--- Apply an array of settings
+function utils.opts(params)
+ for i, item in ipairs(params) do
+ utils.opt(item[1], item[2], item[3])
+ end
+end
+
+--- Key mapping
+function utils.map(mode, lhs, rhs, opts)
+ local options = {noremap = true}
+ if opts then options = vim.tbl_extend('force', options, opts) end
+ vim.api.nvim_set_keymap(mode, lhs, rhs, options)
+end
+
+function utils.get_python_venv()
+ local lsputil = require('lspconfig/util')
+ local match
+
+ if vim.env.VIRTUAL_ENV then
+ return vim.env.VIRTUAL_ENV
+ end
+
+ match = vim.fn.glob(lsputil.path.join(vim.fn.getcwd(), 'Pipfile'))
+ if match ~= '' then
+ return vim.fn.trim(vim.fn.system('PIPENV_PIPFILE=' .. match .. ' pipenv --venv'))
+ end
+
+ match = vim.fn.system('test -f poetry.lock && poetry env info -p')
+ if vim.v.shell_error then
+ return vim.fn.trim(match)
+ end
+
+ return ''
+end
+
+return utils
remember that computers suck.