]> git.friedersdorff.com Git - max/saltfiles.git/commitdiff
INSTALL NEOVIM
authorMaximilian Friedersdorff <maximilian.friedersdorff@envsys.co.uk>
Tue, 2 Jan 2024 10:54:53 +0000 (10:54 +0000)
committerMaximilian Friedersdorff <maximilian.friedersdorff@envsys.co.uk>
Tue, 2 Jan 2024 10:54:53 +0000 (10:54 +0000)
states/nvim/arch.sls [new file with mode: 0644]
states/nvim/files/flake8 [new file with mode: 0644]
states/nvim/files/ginit.vim [new file with mode: 0644]
states/nvim/files/init.lua [new file with mode: 0644]
states/nvim/init.sls [new file with mode: 0644]
states/vim/files/vimrc

diff --git a/states/nvim/arch.sls b/states/nvim/arch.sls
new file mode 100644 (file)
index 0000000..ec07eaa
--- /dev/null
@@ -0,0 +1,12 @@
+install vim:
+  pkg.installed:
+    - pkgs:
+      - neovim
+      - neovim-qt
+      - ctags
+      - python-pylint
+      - flake8
+      - python-pip
+      - the_silver_searcher
+      - eslint
+      - python-black
diff --git a/states/nvim/files/flake8 b/states/nvim/files/flake8
new file mode 100644 (file)
index 0000000..c2d982f
--- /dev/null
@@ -0,0 +1,4 @@
+[flake8]
+max-line-length = 120
+max-doc-length = 99
+ignore = BLK100
diff --git a/states/nvim/files/ginit.vim b/states/nvim/files/ginit.vim
new file mode 100644 (file)
index 0000000..8b29e59
--- /dev/null
@@ -0,0 +1,29 @@
+" Enable Mouse
+set mouse=a
+
+" Set Editor Font
+if exists(':GuiFont')
+    " Use GuiFont! to ignore font errors
+    GuiFont Monaco Nerd Font Mono:h10
+endif
+
+" Disable GUI Tabline
+if exists(':GuiTabline')
+    GuiTabline 0
+endif
+
+" Disable GUI Popupmenu
+if exists(':GuiPopupmenu')
+    GuiPopupmenu 0
+endif
+
+" Enable GUI ScrollBar
+if exists(':GuiScrollBar')
+    GuiScrollBar 1
+endif
+
+" Right Click Context Menu (Copy-Cut-Paste)
+nnoremap <silent><RightMouse> :call GuiShowContextMenu()<CR>
+inoremap <silent><RightMouse> <Esc>:call GuiShowContextMenu()<CR>
+xnoremap <silent><RightMouse> :call GuiShowContextMenu()<CR>gv
+snoremap <silent><RightMouse> <C-G>:call GuiShowContextMenu()<CR>gv
diff --git a/states/nvim/files/init.lua b/states/nvim/files/init.lua
new file mode 100644 (file)
index 0000000..f36b233
--- /dev/null
@@ -0,0 +1,203 @@
+vim.g.mapleader = ','
+vim.g.maplocalleader = '\\'
+
+local Plug = vim.fn['plug#']
+vim.call('plug#begin')
+
+Plug 'junegunn/vim-plug'
+
+-- Language Server protocol config
+Plug 'neovim/nvim-lspconfig'
+
+-- Colorschemes
+Plug 'shaunsingh/solarized.nvim'
+
+-- Syntax Highlighting and folding
+Plug('nvim-treesitter/nvim-treesitter', {['do'] = ':TSUpdate'})
+
+Plug 'nvim-lualine/lualine.nvim'
+
+-- Tags
+Plug 'liuchengxu/vista.vim'
+
+-- Navigation
+Plug 'preservim/nerdtree'
+
+-- Telescope finding shit
+Plug 'nvim-lua/plenary.nvim'
+Plug('nvim-telescope/telescope.nvim', {['branch'] = '0.1.x'})
+Plug('nvim-telescope/telescope-fzf-native.nvim', {['do'] = 'make' })
+Plug 'doctorfree/cheatsheet.nvim'
+
+-- Omnisharp
+Plug 'Hoffs/omnisharp-extended-lsp.nvim'
+
+-- Git
+Plug 'tpope/vim-fugitive'
+Plug 'tommcdo/vim-fubitive'
+
+-- Misc
+Plug 'lukas-reineke/indent-blankline.nvim'
+
+vim.call('plug#end')
+
+require'lspconfig'.pylsp.setup{
+       settings = { pylsp = {
+               plugins = {
+                       flake8 = {
+                               enabled = true,
+                               maxLineLength = 100,
+                       },
+                       pycodestyle = { enabled = false, },
+                       pyflakes = { enabled = false, },
+                       rope_autoimport = { enabled = true, },
+               },
+               configurationSources = 'flake8'
+       }}
+}
+require'lspconfig'.omnisharp.setup{
+       cmd = { "dotnet", "/usr/lib/omnisharp-roslyn/OmniSharp.dll" },
+       enable_roslyn_analyzers = false,
+       handlers = {
+               ["textDocument/definition"] = require('omnisharp_extended').handler,
+       },
+}
+
+vim.diagnostic.config{
+       float = {
+               source = 'always',
+       }
+}
+
+-- Global mappings.
+-- See `:help vim.diagnostic.*` for documentation on any of the below functions
+vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
+vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
+vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
+vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
+
+-- Use LspAttach autocommand to only map the following keys
+-- after the language server attaches to the current buffer
+vim.api.nvim_create_autocmd('LspAttach', {
+       group = vim.api.nvim_create_augroup('UserLspConfig', {}),
+       callback = function(ev)
+               -- Enable completion triggered by <c-x><c-o>
+               vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
+
+               -- Buffer local mappings.
+               -- See `:help vim.lsp.*` for documentation on any of the below functions
+               local opts = { buffer = ev.buf }
+               vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
+               vim.keymap.set('n', '<leader>K', vim.lsp.buf.hover, opts)
+               vim.keymap.set('n', '<leader>k', vim.lsp.buf.signature_help, opts)
+               vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts)
+               vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
+               vim.keymap.set({ 'n', 'v' }, '<leader>ca', vim.lsp.buf.code_action, opts)
+               vim.keymap.set('n', '<space>f', function()
+                       vim.lsp.buf.format { async = true }
+               end, opts)
+       end,
+})
+
+
+-- Tressiter for syntax highlighting and folding
+require'nvim-treesitter.configs'.setup {
+       ensure_installed = { "c", "lua", "vim", "vimdoc", "python", "html" },
+       auto_install = true,
+
+       highlight = { enable = true, },
+       indent = { enable = true, },
+}
+
+vim.opt.foldmethod = "expr"
+vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
+
+
+-- Tag bar
+vim.g.vista_default_executive = 'nvim_lsp'
+vim.keymap.set('n', '<F8>', ':Vista!!<CR>')
+
+
+-- Colourscheme
+vim.opt.background = 'light'
+
+vim.g.solarized_borders = true
+
+
+-- This setting needs to be set before solarized is loaded
+-- so it can't go into ginit.vim, since that is loaded after
+-- this file
+if vim.fn.has('gui_running') == 0 then
+       vim.g.solarized_disable_background = true
+else
+       vim.g.solarized_disable_background = false
+end
+require('solarized').set()
+
+
+-- Lualine (powerline like thing) setup
+require('lualine').setup {
+       options = {
+               theme = 'solarized'
+       }
+}
+
+
+-- Nerdree mappings
+vim.keymap.set('n', '<C-n>', ':NERDTreeToggle<CR>')
+vim.keymap.set('n', '<C-f>', ':NERDTreeFind<CR>')
+
+
+-- Telescope
+require('telescope').setup{
+       extensions = {
+               fzf = {
+                       fuzzy = true,                    -- false will only do exact matching
+                       override_generic_sorter = true,  -- override the generic sorter
+                       override_file_sorter = true,     -- override the file sorter
+                       case_mode = "smart_case",
+               }
+       },
+       pickers = {
+               find_files = {
+                       theme = "dropdown",
+               },
+               live_grep = {
+                       theme = "dropdown",
+               },
+               lsp_references = {
+                       theme = "dropdown",
+               },
+       }
+}
+local tele_builtin = require('telescope.builtin')
+vim.keymap.set('n', '<leader>ff', tele_builtin.find_files, {})
+vim.keymap.set('n', '<leader>fg', tele_builtin.live_grep, {})
+vim.keymap.set('n', '<leader>gr', tele_builtin.lsp_references, {})
+require('telescope').load_extension('fzf')
+
+
+-- General Setup
+-- Relative line numbering
+vim.opt.relativenumber = true
+vim.opt.number = true
+-- Ruler at 80 and 100 cols
+vim.o.colorcolumn = "80,100"
+
+-- Show Spaces, newlines tabs etc
+vim.opt.listchars = {
+       trail = '•',
+       extends = '>',
+       precedes = '<',
+       nbsp = '␣',
+       eol = '↲',
+       tab = '→,',
+}
+vim.opt.list = true
+
+-- Clear highlights from search with Ctrl-l
+vim.keymap.set('n', '<C-l>', ':noh<CR>')
+
+
+-- Indentline
+require("ibl").setup()
diff --git a/states/nvim/init.sls b/states/nvim/init.sls
new file mode 100644 (file)
index 0000000..a3ae5ad
--- /dev/null
@@ -0,0 +1,44 @@
+include:
+  - nvim.{{ grains['os'] | lower }}
+
+rc:
+  file.managed:
+    - name: {{ grains['homedir'] }}/.config/nvim/init.lua
+    - source: salt:///nvim/files/init.lua
+    - user: {{ grains['user'] }}
+    - group: {{ grains['user'] }}
+    - mode: 640
+
+grc:
+  file.managed:
+    - name: {{ grains['homedir'] }}/.config/nvim/ginit.vim
+    - source: salt:///nvim/files/ginit.vim
+    - user: {{ grains['user'] }}
+    - group: {{ grains['user'] }}
+    - mode: 640
+
+flake8:
+  file.managed:
+    - name: {{ grains['homedir'] }}/.config/flake8
+    - source : salt:///nvim/files/flake8
+    - user: {{ grains['user'] }}
+    - group: {{ grains['user'] }}
+    - mode: 640
+
+plugins install:
+  cmd.wait:
+    - name: nvim +PlugInstall +qall
+    - onchanges:
+      - file: rc
+
+plugins update:
+  cmd.run:
+    - name: nvim +PlugUpdate +qall
+    - onchanges:
+      - file: rc
+
+plugins remove:
+  cmd.run:
+    - name: vim +PlugClean +qall
+    - onchanges:
+      - file: rc
index 899f85f16ca3b6c6dd09b4ac717eb9ed6dbb5c38..b1090de1dc8bf584df64b377efcdf692e0e7e1b4 100644 (file)
@@ -35,6 +35,7 @@ Plugin 'pangloss/vim-javascript'
 Plugin 'itspriddle/vim-shellcheck'
 Plugin 'vimwiki/vimwiki'
 Plugin 'dense-analysis/ale'
+Plugin 'Shougo/deoplete.nvim'
 
 " All of your Plugins must be added before the following line
 call vundle#end()            " required
@@ -56,7 +57,11 @@ set tabstop=4
 set relativenumber
 set number
 
-let g:ale_linters = {'python': ['flake8']}
+call deoplete#custom#option('sources', {'_': ['ale',],})
+let g:ale_completion_enabled = 1
+set omnifunc=ale#completion#OmniFunc
+let g:ale_linters = {'python': ['flake8', 'jedils']}
+let g:ale_python_flake8_options = '--max-line-length=88'
 
 let g:html_indent_inctags = "html,body,head,tbody"
 let g:indentLine_color_term = 5