Add neovim configuration files
This commit is contained in:
parent
6cd67e88ad
commit
74a974be5e
25 changed files with 8576 additions and 15 deletions
7
templates/nvim/ftplugin/bash.lua.j2
Normal file
7
templates/nvim/ftplugin/bash.lua.j2
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
vim.b.tabstop = 4
|
||||
vim.b.softtabstop = 4
|
||||
vim.b.shiftwidth = 4
|
||||
vim.b.expandtab = true
|
||||
vim.b.autoindent = true
|
||||
7
templates/nvim/ftplugin/css.lua.j2
Normal file
7
templates/nvim/ftplugin/css.lua.j2
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
vim.b.tabstop = 2
|
||||
vim.b.softtabstop = 2
|
||||
vim.b.shiftwidth = 2
|
||||
vim.b.expandtab = true
|
||||
vim.b.autoindent = true
|
||||
7
templates/nvim/ftplugin/html.lua.j2
Normal file
7
templates/nvim/ftplugin/html.lua.j2
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
vim.b.tabstop = 2
|
||||
vim.b.softtabstop = 2
|
||||
vim.b.shiftwidth = 2
|
||||
vim.b.expandtab = true
|
||||
vim.b.autoindent = true
|
||||
7
templates/nvim/ftplugin/htmldjango.lua.j2
Normal file
7
templates/nvim/ftplugin/htmldjango.lua.j2
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
vim.b.tabstop = 2
|
||||
vim.b.softtabstop = 2
|
||||
vim.b.shiftwidth = 2
|
||||
vim.b.expandtab = true
|
||||
vim.b.autoindent = true
|
||||
7
templates/nvim/ftplugin/javascript.lua.j2
Normal file
7
templates/nvim/ftplugin/javascript.lua.j2
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
vim.b.tabstop = 2
|
||||
vim.b.softtabstop = 2
|
||||
vim.b.shiftwidth = 2
|
||||
vim.b.expandtab = true
|
||||
vim.b.autoindent = true
|
||||
7
templates/nvim/ftplugin/json.lua.j2
Normal file
7
templates/nvim/ftplugin/json.lua.j2
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
vim.b.tabstop = 4
|
||||
vim.b.softtabstop = 4
|
||||
vim.b.shiftwidth = 4
|
||||
vim.b.expandtab = true
|
||||
vim.b.autoindent = true
|
||||
7
templates/nvim/ftplugin/lua.lua.j2
Normal file
7
templates/nvim/ftplugin/lua.lua.j2
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
vim.b.tabstop = 2
|
||||
vim.b.softtabstop = 2
|
||||
vim.b.shiftwidth = 2
|
||||
vim.b.expandtab = true
|
||||
vim.b.autoindent = true
|
||||
7
templates/nvim/ftplugin/python.lua.j2
Normal file
7
templates/nvim/ftplugin/python.lua.j2
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
vim.b.tabstop = 4
|
||||
vim.b.softtabstop = 4
|
||||
vim.b.shiftwidth = 4
|
||||
vim.b.expandtab = true
|
||||
vim.b.autoindent = true
|
||||
7
templates/nvim/ftplugin/scss.lua.j2
Normal file
7
templates/nvim/ftplugin/scss.lua.j2
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
vim.b.tabstop = 2
|
||||
vim.b.softtabstop = 2
|
||||
vim.b.shiftwidth = 2
|
||||
vim.b.expandtab = true
|
||||
vim.b.autoindent = true
|
||||
7
templates/nvim/ftplugin/sh.lua.j2
Normal file
7
templates/nvim/ftplugin/sh.lua.j2
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
vim.b.tabstop = 4
|
||||
vim.b.softtabstop = 4
|
||||
vim.b.shiftwidth = 4
|
||||
vim.b.expandtab = true
|
||||
vim.b.autoindent = true
|
||||
7
templates/nvim/ftplugin/yaml.lua.j2
Normal file
7
templates/nvim/ftplugin/yaml.lua.j2
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
vim.b.tabstop = 2
|
||||
vim.b.softtabstop = 2
|
||||
vim.b.shiftwidth = 2
|
||||
vim.b.expandtab = true
|
||||
vim.b.autoindent = true
|
||||
9
templates/nvim/init.lua.j2
Normal file
9
templates/nvim/init.lua.j2
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
--vim:set ts=2 sw=2 et:
|
||||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
require('options')
|
||||
require('lsp')
|
||||
require('nvim-cmp')
|
||||
require('keybindings')
|
||||
require('auto-commands')
|
||||
require('tree-sitter')
|
||||
41
templates/nvim/lua/auto-commands.lua.j2
Normal file
41
templates/nvim/lua/auto-commands.lua.j2
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
--colorscheme
|
||||
vim.cmd('colorscheme space_vim_theme')
|
||||
|
||||
--enable this option here as the events are used in this buffer
|
||||
vim.cmd('syntax on')
|
||||
|
||||
vim.api.nvim_create_autocmd('Syntax', {
|
||||
command = [[:normal zR]],
|
||||
desc = 'Open folds by default',
|
||||
})
|
||||
|
||||
--color trailing spaces with red color
|
||||
vim.cmd('highlight ExtraWhitespace ctermbg=green guibg=green')
|
||||
vim.cmd('match ExtraWhitespace /s+$/')
|
||||
|
||||
vim.api.nvim_create_autocmd('BufWinEnter', {
|
||||
pattern = "*",
|
||||
command = [[:match ExtraWhitespace /s+$/]],
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('InsertEnter', {
|
||||
pattern = "*",
|
||||
command = [[:match ExtraWhitespace /s+%#@<!$/]],
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('InsertLeave', {
|
||||
pattern = "*",
|
||||
command = [[:match ExtraWhitespace /s+$/]],
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('BufWinLeave', {
|
||||
pattern = "*",
|
||||
command = [[:call clearmatches()]],
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('Filetype', {
|
||||
pattern = 'TelescopeResults',
|
||||
command = [[:setlocal nofoldenable]],
|
||||
})
|
||||
9
templates/nvim/lua/keybindings.lua.j2
Normal file
9
templates/nvim/lua/keybindings.lua.j2
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
local opts = {noremap=true, silent=true}
|
||||
|
||||
vim.api.nvim_set_keymap('n', '<C-E>', '<cmd>:NERDTreeToggle<CR>', opts)
|
||||
vim.api.nvim_set_keymap('n', 'ff', '<cmd>lua require("telescope.builtin").find_files()<CR>', opts)
|
||||
vim.api.nvim_set_keymap('n', 'fg', '<cmd>lua require("telescope.builtin").live_grep()<CR>', opts)
|
||||
vim.api.nvim_set_keymap('n', 'fb', '<cmd>lua require("telescope.builtin").buffers()<CR>', opts)
|
||||
vim.api.nvim_set_keymap('n', 'fh', '<cmd>lua require("telescope.builtin").help_tags()<CR>', opts)
|
||||
55
templates/nvim/lua/lsp.lua.j2
Normal file
55
templates/nvim/lua/lsp.lua.j2
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
--add additional capabilities supported by nvim-cmp
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||
|
||||
--use an on_attach function to only map the following keys
|
||||
--after the language server attaches to the current buffer
|
||||
local on_attach = function(client, bufnr)
|
||||
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
|
||||
-- enable completion triggered by <c-x><c-o>
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- mappings
|
||||
local opts = { noremap=true, silent=true }
|
||||
|
||||
--see `:help vim.lsp.*` for documentation on any of the below functions
|
||||
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
end
|
||||
|
||||
local nvim_lsp = require('lspconfig')
|
||||
|
||||
--enable some language servers with the additional completion capabilities
|
||||
--offered by nvim-cmp
|
||||
local servers = { 'ansiblels', 'yamlls', 'cssls', 'jsonls', }
|
||||
|
||||
local util = require("lspconfig/util")
|
||||
|
||||
nvim_lsp.pyright.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern(".git", "setup.cfg", "requirements")(fname) or
|
||||
util.path.dirname(fname)
|
||||
end
|
||||
})
|
||||
|
||||
nvim_lsp.html.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
filetypes = { 'html', 'htmldjango' },
|
||||
})
|
||||
|
||||
for _, lsp in ipairs(servers) do
|
||||
nvim_lsp[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
end
|
||||
35
templates/nvim/lua/nvim-cmp.lua.j2
Normal file
35
templates/nvim/lua/nvim-cmp.lua.j2
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
local cmp = require('cmp')
|
||||
|
||||
cmp.setup {
|
||||
mapping = {
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.close(),
|
||||
['<CR>'] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
},
|
||||
['<Tab>'] = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
['<S-Tab>'] = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
},
|
||||
}
|
||||
57
templates/nvim/lua/options.lua.j2
Normal file
57
templates/nvim/lua/options.lua.j2
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
--fix different locale settings when ssh'ing
|
||||
vim.o.encoding = 'utf-8'
|
||||
|
||||
vim.o.syntax = 'on'
|
||||
|
||||
--display all matching files when we tab complete
|
||||
vim.o.wildmenu = true
|
||||
|
||||
--replace vertical split pipe character with space
|
||||
vim.o.fillchars = 'vert:|,fold: '
|
||||
|
||||
--Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
|
||||
--delays and poor user experience.
|
||||
vim.o.updatetime = 300
|
||||
|
||||
vim.o.splitright = true
|
||||
vim.o.splitbelow = true
|
||||
|
||||
--switch buffers without writing to file
|
||||
vim.o.hidden = true
|
||||
|
||||
--fold indents
|
||||
vim.o.foldmethod = 'indent'
|
||||
|
||||
--don't open folds when jumping over one with (, {, [[ or [{
|
||||
vim.opt.foldopen = vim.opt.foldopen - { 'block' }
|
||||
|
||||
--search down into subfolders
|
||||
--provides tab-completion for all file-related tasks
|
||||
vim.opt.path = vim.opt.path + { '**' }
|
||||
|
||||
--line numbers
|
||||
vim.o.number = true
|
||||
|
||||
--higlhight search
|
||||
vim.o.hls = true
|
||||
|
||||
--search as characters are entered
|
||||
vim.o.incsearch = true
|
||||
|
||||
--line for linewrapping
|
||||
vim.o.colorcolumn = '80'
|
||||
|
||||
--wrap text instead of being on one line
|
||||
vim.o.lbr = true
|
||||
|
||||
--default Colors for CursorLine
|
||||
vim.o.cursorline = true
|
||||
|
||||
vim.o.termguicolors = true
|
||||
vim.o.background = 'light'
|
||||
|
||||
--enable statusbar
|
||||
vim.o.laststatus = 2
|
||||
vim.o.statusline = ' %F %m%r%w %= %{hostname()} %{strlen(&ft)?&ft:"none"} %{(&bomb?",BOM":"")} %{&ff} %l/%L %c %P'
|
||||
11
templates/nvim/lua/tree-sitter.lua.j2
Normal file
11
templates/nvim/lua/tree-sitter.lua.j2
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
-- {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||
|
||||
local tree_sitter_config = require('nvim-treesitter.configs')
|
||||
|
||||
tree_sitter_config.setup {
|
||||
ensure_installed = {
|
||||
'lua', 'yaml', 'bash', 'python', 'javascript', 'css', 'scss', 'html',
|
||||
'json', 'dockerfile', 'markdown',
|
||||
},
|
||||
auto_install = true,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue