From 6ad42d72ea21036cb066f2185b777f9b2ea1c49e Mon Sep 17 00:00:00 2001 From: Maximilian Friedersdorff Date: Tue, 2 Jan 2024 10:54:53 +0000 Subject: [PATCH] INSTALL NEOVIM --- states/nvim/arch.sls | 12 +++ states/nvim/files/flake8 | 4 + states/nvim/files/ginit.vim | 29 ++++++ states/nvim/files/init.lua | 203 ++++++++++++++++++++++++++++++++++++ states/nvim/init.sls | 44 ++++++++ states/vim/files/vimrc | 7 +- 6 files changed, 298 insertions(+), 1 deletion(-) create mode 100644 states/nvim/arch.sls create mode 100644 states/nvim/files/flake8 create mode 100644 states/nvim/files/ginit.vim create mode 100644 states/nvim/files/init.lua create mode 100644 states/nvim/init.sls diff --git a/states/nvim/arch.sls b/states/nvim/arch.sls new file mode 100644 index 0000000..ec07eaa --- /dev/null +++ b/states/nvim/arch.sls @@ -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 index 0000000..c2d982f --- /dev/null +++ b/states/nvim/files/flake8 @@ -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 index 0000000..8b29e59 --- /dev/null +++ b/states/nvim/files/ginit.vim @@ -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 :call GuiShowContextMenu() +inoremap :call GuiShowContextMenu() +xnoremap :call GuiShowContextMenu()gv +snoremap :call GuiShowContextMenu()gv diff --git a/states/nvim/files/init.lua b/states/nvim/files/init.lua new file mode 100644 index 0000000..f36b233 --- /dev/null +++ b/states/nvim/files/init.lua @@ -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', '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', '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 + 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', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'k', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) + vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', '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', '', ':Vista!!') + + +-- 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', '', ':NERDTreeToggle') +vim.keymap.set('n', '', ':NERDTreeFind') + + +-- 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', 'ff', tele_builtin.find_files, {}) +vim.keymap.set('n', 'fg', tele_builtin.live_grep, {}) +vim.keymap.set('n', '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', '', ':noh') + + +-- Indentline +require("ibl").setup() diff --git a/states/nvim/init.sls b/states/nvim/init.sls new file mode 100644 index 0000000..a3ae5ad --- /dev/null +++ b/states/nvim/init.sls @@ -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 diff --git a/states/vim/files/vimrc b/states/vim/files/vimrc index 899f85f..b1090de 100644 --- a/states/vim/files/vimrc +++ b/states/vim/files/vimrc @@ -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 -- 2.46.2