Compare commits

...

3 Commits

Author SHA1 Message Date
Marcin Woźniak
98ed56e5da Added installing the terraform and terraform-ls
Signed-off-by: Marcin Woźniak <marcin.wozniak@wundermanthompson.com>
2023-01-03 08:44:12 +01:00
Marcin Woźniak
9442d529ef Changes in the neovim
Signed-off-by: Marcin Woźniak <marcin.wozniak@wundermanthompson.com>
2023-01-03 08:38:20 +01:00
Marcin Woźniak
cdc503467b Added terraform into neovim
Signed-off-by: Marcin Woźniak <marcin.wozniak@wundermanthompson.com>
2023-01-03 08:38:00 +01:00
2 changed files with 39 additions and 6 deletions

View File

@ -111,6 +111,9 @@ call plug#begin('~/.config/nvim/plugged')
Plug 'pearofducks/ansible-vim', { 'do': './UltiSnips/generate.sh' } Plug 'pearofducks/ansible-vim', { 'do': './UltiSnips/generate.sh' }
Plug 'Yggdroot/indentLine' Plug 'Yggdroot/indentLine'
" Terraform
Plug 'hashivim/vim-terraform'
" Multiple cursors " Multiple cursors
Plug 'terryma/vim-multiple-cursors' Plug 'terryma/vim-multiple-cursors'
@ -124,7 +127,7 @@ call plug#begin('~/.config/nvim/plugged')
Plug 'tpope/vim-fugitive' Plug 'tpope/vim-fugitive'
" Prettier " Prettier
Plug 'prettier/vim-prettier' Plug 'prettier/vim-prettier', { 'do': 'yarn install --frozen-lockfile --production' }
" Debug " Debug
Plug 'puremourning/vimspector' Plug 'puremourning/vimspector'
@ -153,8 +156,15 @@ call plug#begin('~/.config/nvim/plugged')
Plug 'nvim-tree/nvim-web-devicons' Plug 'nvim-tree/nvim-web-devicons'
Plug 'nvim-tree/nvim-tree.lua' Plug 'nvim-tree/nvim-tree.lua'
" SHFMT
Plug 'z0mbix/vim-shfmt', { 'for': 'sh' } Plug 'z0mbix/vim-shfmt', { 'for': 'sh' }
" Mikrotik
Plug 'zainin/vim-mikrotik' Plug 'zainin/vim-mikrotik'
Plug 'nvim-treesitter/nvim-treesitter'
Plug 'nvim-treesitter/nvim-treesitter-context'
call plug#end() call plug#end()
" LUA " LUA
@ -190,7 +200,7 @@ local handlers = {
-- Use a loop to conveniently call 'setup' on multiple servers and -- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches -- map buffer local keybindings when the language server attaches
local servers = { 'pyright', 'bashls', 'yamlls', 'ansiblels', 'gopls', 'solargraph', 'terraformls'} local servers = { 'pyright', 'bashls', 'yamlls', 'ansiblels', 'gopls', 'solargraph', 'terraformls', 'tflint' }
for _, lsp in pairs(servers) do for _, lsp in pairs(servers) do
require('lspconfig')[lsp].setup { require('lspconfig')[lsp].setup {
on_attach = on_attach, on_attach = on_attach,
@ -317,6 +327,8 @@ cmp.setup.cmdline('/', {
require("nvim-tree").setup({ require("nvim-tree").setup({
}) })
require'treesitter-context'.setup{}
EOF EOF
" Added popout window to see diagnostic " Added popout window to see diagnostic
@ -327,7 +339,7 @@ autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=fals
let g:neoformat_try_formatprg = 1 let g:neoformat_try_formatprg = 1
let g:neoformat_basic_format_trim = 1 let g:neoformat_basic_format_trim = 1
let g:neoformat_only_msg_on_error = 1 let g:neoformat_only_msg_on_error = 1
autocmd BufWritePre * silent! undojoin | Neoformat prettier autocmd BufWritePre * silent! undojoin | Neoformat
let g:neoformat_python_black = { let g:neoformat_python_black = {
\ 'exe': 'black', \ 'exe': 'black',
\ 'stdin': 1, \ 'stdin': 1,
@ -335,6 +347,9 @@ let g:neoformat_python_black = {
\ } \ }
let g:neoformat_enabled_python = ['black'] let g:neoformat_enabled_python = ['black']
" Terraform
let g:terraform_fmt_on_save=1
let g:terraform_align=1
function! s:check_back_space() abort function! s:check_back_space() abort
let col = col('.') - 1 let col = col('.') - 1
@ -561,7 +576,6 @@ EOF
" Files " Files
"""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""
" Bash " Bash
if executable('shfmt') if executable('shfmt')
let &l:formatprg='shfmt -i ' . &l:shiftwidth . ' -ln posix -sr -ci -s' let &l:formatprg='shfmt -i ' . &l:shiftwidth . ' -ln posix -sr -ci -s'
@ -608,6 +622,10 @@ au BufNewFile,BufRead *.mikrotik setfiletype routeros
" Ebuild " Ebuild
au BufNewFile,BufRead,BufWritePre *.ebuild let g:shfmt_extra_args = '-ci -sr -s' au BufNewFile,BufRead,BufWritePre *.ebuild let g:shfmt_extra_args = '-ci -sr -s'
" Terrafrom
autocmd BufWritePre *.tf lua vim.lsp.buf.formatting_sync()
autocmd BufWritePre *.tfvars lua vim.lsp.buf.formatting_sync()
" Automatically deletes all trailing whitespace and newlines at end of file on save. " Automatically deletes all trailing whitespace and newlines at end of file on save.
autocmd BufWritePre * %s/\s\+$//e autocmd BufWritePre * %s/\s\+$//e
autocmd BufWritepre * %s/\n\+\%$//e autocmd BufWritepre * %s/\n\+\%$//e

View File

@ -44,10 +44,24 @@ function install_shfmt() {
GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@latest GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@latest
} }
function install_terraform() {
# Install terraform and terraform-ls
GO111MODULE=on go install github.com/hashicorp/terraform@latest
GO111MODULE=on go install github.com/hashicorp/terraform-ls@latest
if [[ "$(uname)" == "Darwin" ]]; then
brew install tflint
else
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
fi
}
function install_shellcheck() { function install_shellcheck() {
# Install shellcheck # Install shellcheck
[[ "$(uname)" == "Darwin" ]] && brew install shellcheck if [[ "$(uname)" == "Darwin" ]]; then
sudo emerge shellcheck-bin brew install shellcheck
else
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
fi
} }
function install_gopls() { function install_gopls() {
@ -84,6 +98,7 @@ function main() {
command_start install_shfmt command_start install_shfmt
command_start install_shellcheck command_start install_shellcheck
command_start install_gopls command_start install_gopls
command_start install_terraform
command_start install_black command_start install_black
command_start install_ansible command_start install_ansible
command_start install_meraki_ansible command_start install_meraki_ansible