added neovim configs
This commit is contained in:
commit
547f109048
|
@ -0,0 +1 @@
|
|||
lua require('config')
|
|
@ -0,0 +1,14 @@
|
|||
-- launch file browser when opening on a directory
|
||||
vim.api.nvim_command('au VimEnter * lua require("userfuncs").browse_if_dir()')
|
||||
|
||||
-- recognize csx files as csharp
|
||||
vim.api.nvim_command('au BufRead,BufNewFile *.csx set filetype=cs')
|
||||
|
||||
-- enable dadbod completion for sql files
|
||||
vim.api.nvim_command("au FileType sql let b:db = exists('*DotenvGet') ? DotenvGet('DATABASE_URL') : eval('$DATABASE_URL')")
|
||||
vim.api.nvim_command([[au FileType sql lua require'cmp'.setup.buffer {
|
||||
sources = {
|
||||
{ name = 'vim-dadbod-completion' },
|
||||
{ name = 'buffer' },
|
||||
}}
|
||||
]])
|
|
@ -0,0 +1,31 @@
|
|||
vim.o.termguicolors = true
|
||||
vim.cmd('colo wormbait')
|
||||
|
||||
vim.g.mapleader = ','
|
||||
|
||||
vim.opt.guicursor = ''
|
||||
vim.opt.cursorline = true
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.hidden = true
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.list = true
|
||||
vim.opt.listchars = 'eol:¶,tab:→ ,trail:␣,extends:»,precedes:«'
|
||||
vim.opt.mouse = 'a'
|
||||
vim.opt.number = true
|
||||
vim.opt.shiftwidth = 2
|
||||
vim.opt.signcolumn = 'yes'
|
||||
vim.opt.softtabstop = 2
|
||||
vim.opt.tabstop = 2
|
||||
vim.opt.undofile = true
|
||||
vim.opt.undolevels = 9999
|
||||
vim.opt.wrap = true
|
||||
|
||||
vim.g['loaded_netrw'] = 1
|
||||
vim.g['loaded_netrwPlugin'] = 1
|
||||
vim.cmd('filetype plugin on')
|
||||
|
||||
require('userfuncs')
|
||||
require('plugins')
|
||||
require('plugins-conf')
|
||||
require('keybindings')
|
||||
require('autocmd')
|
|
@ -0,0 +1,59 @@
|
|||
local cwdopt = '{cwd = require("userfuncs").find_project_root()}'
|
||||
|
||||
local noremap = {noremap = true}
|
||||
|
||||
-- file navigation
|
||||
vim.api.nvim_set_keymap('n', '-', '<cmd>lua require("telescope").extensions.vinegar.file_browser()<cr>', noremap)
|
||||
vim.api.nvim_set_keymap('n', '<F1>', '<cmd>b#<cr>', noremap)
|
||||
vim.api.nvim_set_keymap('n', '<leader>-', '<cmd>lua require("telescope.builtin").find_files('..cwdopt..')<cr>', noremap)
|
||||
vim.api.nvim_set_keymap('n', '_', '<cmd>lua require("telescope.builtin").buffers('..cwdopt..')<cr>', noremap)
|
||||
vim.api.nvim_set_keymap('n', '<leader>gg', '<cmd>lua require("telescope.builtin").live_grep('..cwdopt..')<cr>', noremap)
|
||||
|
||||
-- lsp stuff
|
||||
vim.api.nvim_set_keymap('n', '<leader>fu', '<cmd>Telescope lsp_references<cr>', noremap)
|
||||
vim.api.nvim_set_keymap('n', '<leader>gd', '<cmd>Telescope lsp_definitions<cr>', noremap)
|
||||
vim.api.nvim_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<cr>', noremap)
|
||||
vim.api.nvim_set_keymap('n', '<leader>dn', '<cmd>lua vim.lsp.diagnostic.goto_next()<cr>', noremap)
|
||||
vim.api.nvim_set_keymap('n', '<leader>dN', '<cmd>lua vim.lsp.diagnostic.goto_prev()<cr>', noremap)
|
||||
vim.api.nvim_set_keymap('n', '<leader>dd', '<cmd>Telescope lsp_document_diagnostics<cr>', noremap)
|
||||
vim.api.nvim_set_keymap('n', '<leader>dD', '<cmd>Telescope lsp_workspace_diagnostics<cr>', noremap)
|
||||
vim.api.nvim_set_keymap('n', '<leader>xx', '<cmd>Telescope lsp_code_actions<cr>', noremap)
|
||||
vim.api.nvim_set_keymap('n', '<leader>xd', '<cmd>%Telescope lsp_range_code_actions<cr>', noremap)
|
||||
|
||||
-- dadbod stuff
|
||||
vim.cmd([[
|
||||
augroup dadbod_keybindings
|
||||
autocmd!
|
||||
autocmd FileType sql nnoremap <buffer> <F5> :'{,'}DB<cr>
|
||||
autocmd FileType sql vnoremap <buffer> <F5> :DB<cr>
|
||||
autocmd FileType sql inoremap <buffer> <F5> <C-o>:'{,'}DB<cr>
|
||||
augroup end
|
||||
]])
|
||||
|
||||
-- misc
|
||||
-- f2 gets highlight details of thing under cursor
|
||||
vim.api.nvim_set_keymap('n', '<F2>', '<cmd>echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . "> trans<" . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<cr>', noremap)
|
||||
-- f3 for synonym list under cursor
|
||||
vim.api.nvim_set_keymap('n', '<F3>', '<cmd>lua require("telescope").extensions.dict.synonyms()<cr>', noremap)
|
||||
-- replace z= with telescope spell_suggest
|
||||
vim.api.nvim_set_keymap('n', 'z=', '<cmd>Telescope spell_suggest<cr>', noremap)
|
||||
|
||||
-- f12 for zen mode
|
||||
vim.api.nvim_set_keymap('n', '<F12>', '<cmd>TZAtaraxis<cr>', noremap)
|
||||
|
||||
vim.api.nvim_set_keymap('', '<S-ScrollWheelUp>', '<ScrollWheelLeft>', noremap)
|
||||
vim.api.nvim_set_keymap('', '<S-ScrollWheelDown>', '<ScrollWheelRight>', noremap)
|
||||
vim.api.nvim_set_keymap('', '<S-2-ScrollWheelUp>', '<2-ScrollWheelLeft>', noremap)
|
||||
vim.api.nvim_set_keymap('', '<S-2-ScrollWheelDown>', '<2-ScrollWheelRight>', noremap)
|
||||
vim.api.nvim_set_keymap('', '<S-3-ScrollWheelUp>', '<3-ScrollWheelLeft>', noremap)
|
||||
vim.api.nvim_set_keymap('', '<S-3-ScrollWheelDown>', '<3-ScrollWheelRight>', noremap)
|
||||
vim.api.nvim_set_keymap('', '<S-4-ScrollWheelUp>', '<4-ScrollWheelLeft>', noremap)
|
||||
vim.api.nvim_set_keymap('', '<S-4-ScrollWheelDown>', '<4-ScrollWheelRight>', noremap)
|
||||
vim.api.nvim_set_keymap('', '<S-PageUp>', '<ScrollWheelLeft>', noremap)
|
||||
vim.api.nvim_set_keymap('', '<S-PageDown>', '<ScrollWheelRight>', noremap)
|
||||
vim.api.nvim_set_keymap('', '<S-2-PageUp>', '<2-ScrollWheelLeft>', noremap)
|
||||
vim.api.nvim_set_keymap('', '<S-2-PageDown>', '<2-ScrollWheelRight>', noremap)
|
||||
vim.api.nvim_set_keymap('', '<S-3-PageUp>', '<3-ScrollWheelLeft>', noremap)
|
||||
vim.api.nvim_set_keymap('', '<S-3-PageDown>', '<3-ScrollWheelRight>', noremap)
|
||||
vim.api.nvim_set_keymap('', '<S-4-PageUp>', '<4-ScrollWheelLeft>', noremap)
|
||||
vim.api.nvim_set_keymap('', '<S-4-PageDown>', '<4-ScrollWheelRight>', noremap)
|
|
@ -0,0 +1,207 @@
|
|||
local util = require('lspconfig').util
|
||||
|
||||
-- autocomplete config
|
||||
local cmp = require 'cmp'
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
['<Tab>'] = cmp.mapping.select_next_item(),
|
||||
['<S-Tab>'] = cmp.mapping.select_prev_item(),
|
||||
['<CR>'] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = false,
|
||||
})
|
||||
},
|
||||
preselect = cmp.PreselectMode.None,
|
||||
confirmation = { get_commit_characters = function(_) return {} end },
|
||||
sources = {
|
||||
{ name = 'nvim_lsp', },
|
||||
{ name = 'buffer' },
|
||||
{ name = 'path' },
|
||||
},
|
||||
}
|
||||
|
||||
-- gitsigns
|
||||
require('gitsigns').setup()
|
||||
|
||||
-- lsp configs
|
||||
require'lspconfig'.openscad_ls.setup {
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
||||
on_attach = function(_, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
end,
|
||||
}
|
||||
require'lspconfig'.omnisharp.setup {
|
||||
root_dir = function(file, _)
|
||||
if file:sub(-#".csx") == ".csx" then
|
||||
return util.path.dirname(file)
|
||||
end
|
||||
return util.root_pattern("*.sln")(file) or util.root_pattern("*.csproj")(file)
|
||||
end,
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
||||
on_attach = function(_, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
end,
|
||||
cmd = { "/home/rudism/.local/share/omnisharp/OmniSharp", "--languageserver" , "--hostPID", tostring(pid) },
|
||||
}
|
||||
require'lspconfig'.tsserver.setup {
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
||||
on_attach = function(_, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
end,
|
||||
cmd = { 'npx', 'typescript-language-server', '--stdio' },
|
||||
}
|
||||
require'lspconfig'.yamlls.setup {
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
||||
on_attach = function(_, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
end,
|
||||
}
|
||||
require'lspconfig'.ccls.setup {
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
||||
on_attach = function(_, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
end,
|
||||
}
|
||||
local runtime_path = vim.split(package.path, ';')
|
||||
table.insert(runtime_path, "lua/?.lua")
|
||||
table.insert(runtime_path, "lua/?/init.lua")
|
||||
require'lspconfig'.sumneko_lua.setup {
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
||||
on_attach = function(_, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
end,
|
||||
cmd = { "lua-language-server", "-E" },
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
version = 'LuaJIT',
|
||||
path = runtime_path,
|
||||
},
|
||||
diagnostics = {
|
||||
globals = {'vim', 'use'},
|
||||
},
|
||||
workspace = {
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
},
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
require'lspconfig'.perlpls.setup {
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
||||
on_attach = function(_, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
end,
|
||||
settings = {
|
||||
perl = {
|
||||
perlcritic = {
|
||||
enabled = false
|
||||
},
|
||||
syntax = {
|
||||
enabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
require'lspconfig'.efm.setup {
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
||||
on_attach = function(_, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
end,
|
||||
filetypes = {"sh", "markdown"},
|
||||
settings = {
|
||||
languages = {
|
||||
sh = {{
|
||||
lintCommand = "shellcheck -f gcc -x",
|
||||
lintSource = "shellcheck",
|
||||
lintFormats = { "%f:%l:%c: %trror: %m", "%f:%l:%c: %tarning: %m", "%f:%l:%c: %tote: %m" },
|
||||
lintIgnoreExitCode = true
|
||||
}},
|
||||
markdown = {{
|
||||
lintCommand = "write-good --parse",
|
||||
lintSource = "write-good",
|
||||
lintFormats = { "%f:%l:%c:%m" },
|
||||
}},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-- status line setup
|
||||
require'lualine'.setup {
|
||||
options = {
|
||||
theme = 'wombat',
|
||||
component_separators = { left = '', right = '' },
|
||||
section_separators = { left = '', right = '' },
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {'mode'},
|
||||
lualine_b = {'branch'},
|
||||
lualine_c = {{
|
||||
'filename',
|
||||
symbols = {
|
||||
modified = '✎ ',
|
||||
readonly = '🔒 ',
|
||||
unnamed = '[No Name]'
|
||||
}
|
||||
}},
|
||||
lualine_x = {{
|
||||
"diagnostics",
|
||||
sources = {"nvim_lsp"},
|
||||
icons_enabled = false
|
||||
}},
|
||||
lualine_y = {'progress'},
|
||||
lualine_z = {'location'},
|
||||
}
|
||||
}
|
||||
|
||||
-- zen mode setup
|
||||
local true_zen = require('true-zen')
|
||||
true_zen.setup {
|
||||
modes = {
|
||||
ataraxis = {
|
||||
custom_bg = { "solid", "#080808" },
|
||||
ideal_writing_area_width = { 90, 150, "max" },
|
||||
affected_higroups = {},
|
||||
},
|
||||
},
|
||||
integrations = {
|
||||
tmux = true,
|
||||
gitsigns = true,
|
||||
lualine = true,
|
||||
},
|
||||
}
|
||||
true_zen.before_mode_ataraxis_on = function ()
|
||||
vim.cmd("set nolist")
|
||||
vim.cmd("set nocursorline")
|
||||
vim.cmd("set spell")
|
||||
vim.cmd("set lbr")
|
||||
vim.cmd("hi Normal guibg=#080808")
|
||||
vim.cmd("hi StatusLine guibg=#080808 guifg=#080808")
|
||||
vim.cmd("hi StatusLineNC guibg=#080808 guifg=#080808")
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.api.nvim_set_keymap("", "k", "gk", opts)
|
||||
vim.api.nvim_set_keymap("", "j", "gj", opts)
|
||||
vim.api.nvim_set_keymap("", "<Up>", "gk", opts)
|
||||
vim.api.nvim_set_keymap("", "<Down>", "gj", opts)
|
||||
end
|
||||
true_zen.after_mode_ataraxis_off = function ()
|
||||
vim.cmd("set list")
|
||||
vim.cmd("set cursorline")
|
||||
vim.cmd("set nospell")
|
||||
vim.cmd("set nolbr")
|
||||
vim.cmd("hi Normal guibg=#242424")
|
||||
vim.cmd("hi StatusLine guifg=NONE guibg=NONE")
|
||||
vim.cmd("hi StatusLineNC guifg=NONE guibg=NONE")
|
||||
vim.api.nvim_del_keymap("", "k")
|
||||
vim.api.nvim_del_keymap("", "j")
|
||||
vim.api.nvim_del_keymap("", "<Up>")
|
||||
vim.api.nvim_del_keymap("", "<Down>")
|
||||
end
|
|
@ -0,0 +1,34 @@
|
|||
return require('packer').startup(function()
|
||||
local pid = vim.fn.getpid()
|
||||
|
||||
use 'wbthomason/packer.nvim' -- plugin manager
|
||||
use 'rktjmp/lush.nvim'
|
||||
use 'https://code.sitosis.com/rudism/wormbait.nvim.git' -- color scheme
|
||||
use 'hoob3rt/lualine.nvim' -- status line
|
||||
use { -- file picker and grepper
|
||||
'nvim-telescope/telescope.nvim',
|
||||
requires = { {'nvim-lua/plenary.nvim'} }
|
||||
}
|
||||
use 'gpanders/editorconfig.nvim'
|
||||
use 'neovim/nvim-lspconfig'
|
||||
use 'hrsh7th/nvim-cmp' -- autocomplete
|
||||
use 'hrsh7th/cmp-vsnip' -- autocomplete
|
||||
use 'hrsh7th/vim-vsnip' -- autocomplete
|
||||
use 'hrsh7th/cmp-nvim-lsp' -- lsp autocomplete
|
||||
use 'hrsh7th/cmp-buffer' -- buffer autocomplete
|
||||
use 'hrsh7th/cmp-path' -- path autocompletes
|
||||
use { -- gitgutter replacement
|
||||
'lewis6991/gitsigns.nvim',
|
||||
requires = {
|
||||
'nvim-lua/plenary.nvim'
|
||||
}
|
||||
}
|
||||
use 'Pocco81/TrueZen.nvim' -- distraction free writing
|
||||
use 'https://code.sitosis.com/rudism/telescope-dict.nvim.git' -- thesaurus and dictionary
|
||||
use 'nvim-telescope/telescope-file-browser.nvim' -- file picker
|
||||
use 'https://code.sitosis.com/rudism/telescope-vinegar.nvim.git' -- thesaurus and dictionary
|
||||
use 'tpope/vim-dadbod' -- database query runner
|
||||
use 'tpope/vim-dotenv' -- .env configuration support
|
||||
use 'kristijanhusak/vim-dadbod-completion' -- sql completion
|
||||
use 'sirtaj/vim-openscad'
|
||||
end)
|
|
@ -0,0 +1,62 @@
|
|||
local M = {}
|
||||
|
||||
local function parent_dir(path)
|
||||
local idx = path:match('.*/()')
|
||||
if idx == nil then
|
||||
return nil
|
||||
end
|
||||
return path:sub(1, idx - 2)
|
||||
end
|
||||
|
||||
local function scan_dir(path)
|
||||
local pfile = io.popen('ls -a "'..path..'"')
|
||||
local files = {}
|
||||
for filename in pfile:lines() do
|
||||
table.insert(files, filename)
|
||||
end
|
||||
return files
|
||||
end
|
||||
|
||||
local rootfiles = {
|
||||
'.git',
|
||||
'package.json',
|
||||
'node_modules',
|
||||
'Makefile',
|
||||
'*.sln'
|
||||
}
|
||||
|
||||
M.browse_if_dir = function()
|
||||
if require('plenary.path'):new(vim.fn.expand('%:p')):is_dir() then
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
vim.api.nvim_buf_set_option(buf, 'buftype', 'nofile')
|
||||
vim.api.nvim_buf_set_option(buf, 'buflisted', false)
|
||||
vim.api.nvim_buf_set_option(buf, 'swapfile', false)
|
||||
vim.api.nvim_buf_set_option(buf, 'bufhidden', 'hide')
|
||||
require('telescope').extensions.vinegar.file_browser()
|
||||
end
|
||||
end
|
||||
|
||||
M.find_project_root = function()
|
||||
local stop_at = parent_dir(os.getenv('HOME'))
|
||||
local cwd = vim.fn.expand('%:p:h')
|
||||
local cur_dir = cwd
|
||||
while cur_dir:find(stop_at) == 1 do
|
||||
for _, filename in pairs(scan_dir(cur_dir)) do
|
||||
for _, rootfile in pairs(rootfiles) do
|
||||
if rootfile:sub(1, 1) == '*' then
|
||||
local idx = filename:find(rootfile:sub(2))
|
||||
if idx == filename:len() - rootfile:len() + 2 then
|
||||
return cur_dir
|
||||
end
|
||||
elseif filename == rootfile then
|
||||
print(cur_dir)
|
||||
return cur_dir
|
||||
end
|
||||
end
|
||||
end
|
||||
cur_dir = parent_dir(cur_dir)
|
||||
end
|
||||
return cwd
|
||||
end
|
||||
|
||||
return M
|
Loading…
Reference in New Issue