summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian T. <julian@jtle.dk>2023-11-01 15:46:43 +0100
committerJulian T <julian@jtle.dk>2023-11-19 13:20:34 +0100
commit11ed03d80c55e2c213118adf97fc18c55d2249a3 (patch)
tree557ec6fa7862e234c4ad2245f72263d9f7881420
parent517fec1d313ca9a9cc1c7e70484a730d84cfe070 (diff)
Rework nvim setup
-rw-r--r--vim-core/.config/nvim/init.vim15
-rw-r--r--vim-extra/.config/nvim/extra.vim124
2 files changed, 126 insertions, 13 deletions
diff --git a/vim-core/.config/nvim/init.vim b/vim-core/.config/nvim/init.vim
index fc5f2e5..9e52109 100644
--- a/vim-core/.config/nvim/init.vim
+++ b/vim-core/.config/nvim/init.vim
@@ -1,9 +1,8 @@
set nocompatible
-filetype plugin on
+filetype plugin indent on
set shellslash
-let mapleader=","
-
+let mapleader=" "
runtime extra.vim
filetype plugin indent on " required
@@ -30,7 +29,6 @@ filetype plugin indent on " required
set softtabstop=2
set autoindent
- set smartindent
" Show 5 lines above and below cursor
set scrolloff=3
@@ -60,6 +58,8 @@ filetype plugin indent on " required
set autoread
+ set cino=J1,j1,L0,:0,=0,l1,h0
+
" Exit insert mode on inactivity
" au CursorHoldI * stopinsert}}}
@@ -87,6 +87,7 @@ filetype plugin indent on " required
" Fuzzy like menu
set path+=**
set wildmenu
+ set wildignore+=**/node_modules/**
let g:netrw_liststyle=2"}}}
@@ -99,14 +100,16 @@ filetype plugin indent on " required
nnoremap <expr> j (v:count > 1 ? "m'" . v:count : '' ) . 'j'
nnoremap <expr> k (v:count > 1 ? "m'" . v:count : '' ) . 'k'
- nnoremap <leader>p :echo "Leader virker"<CR>
+ " Leader stuff
+ nnoremap <leader>t <cmd>echo "Yeah det virker"<cr>
" Enforcing filetypes{{{
autocmd BufRead,BufNewFile *.ino set filetype=c
autocmd BufRead,BufNewFile *.asc set filetype=asciidoc
autocmd BufRead,BufNewFile *.nix set filetype=nix
- autocmd BufRead,BufNewFile *.tsx set filetype=typescript"}}}
+ autocmd BufRead,BufNewFile *.tsx set filetype=typescriptreact
+ "}}}
" Highlightning And colors{{{
set termguicolors
diff --git a/vim-extra/.config/nvim/extra.vim b/vim-extra/.config/nvim/extra.vim
index 440d86b..d2fc7cf 100644
--- a/vim-extra/.config/nvim/extra.vim
+++ b/vim-extra/.config/nvim/extra.vim
@@ -1,21 +1,34 @@
" Plugins{{{
call plug#begin()
+ Plug 'williamboman/mason.nvim'
+ Plug 'williamboman/mason-lspconfig.nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
+ Plug 'tpope/vim-unimpaired'
+ Plug 'tpope/vim-fugitive'
+ Plug 'tpope/vim-commentary'
- Plug 'NLKNguyen/papercolor-theme'
- Plug 'lervag/vimtex'
+ Plug 'hrsh7th/cmp-nvim-lsp'
+ Plug 'hrsh7th/cmp-buffer'
+ Plug 'hrsh7th/nvim-cmp'
Plug 'nvim-treesitter/nvim-treesitter'
+ Plug 'nvim-lua/plenary.nvim'
+ Plug 'nvim-telescope/telescope.nvim', { 'branch': '0.1.x' }
+
+ Plug 'NLKNguyen/papercolor-theme'
+ Plug 'lervag/vimtex'
call plug#end()
" }}}
+colorscheme PaperColor
+
" Treesitter {{{
-lua << EOF
+lua <<EOF
require'nvim-treesitter.configs'.setup {
ensure_installed = { "lua", "typescript", "java", "tsx" },
auto_install = false,
@@ -24,20 +37,29 @@ lua << EOF
},
indent = {
enable = true,
- }
+ },
+ incremental_selection = {
+ enable = true,
+ },
}
EOF
" }}}
+" Telescope {{{
+lua <<EOF
+ local builtin = require('telescope.builtin')
+ vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
+ vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
+EOF
+" }}}
+
" Completion{{{
set completeopt+=menuone
set completeopt+=noselect
- "
+
" Close completion window
autocmd CompleteDone * pclose
- colorscheme PaperColor
-
"}}}
" Latex {{{
@@ -45,3 +67,91 @@ EOF
let g:vimtex_quickfix_open_on_warning = 0
"}}}
+
+" LSP {{{
+
+lua <<EOF
+ require("mason").setup()
+ require("mason-lspconfig").setup()
+
+ local lspconfig = require("lspconfig")
+
+ local typescript_formatter = {
+ formatCommand = "prettier --stdin --stdin-filepath '${INPUT}' ${--range-start:charStart} ${--range-end:charEnd} ${--tab-width:tabSize} ${--use-tabs:!insertSpaces}",
+ formatCanRange = true,
+ formatStdin = true,
+ rootMarkers = {
+ '.prettierrc',
+ '.prettierrc.json',
+ '.prettierrc.js',
+ '.prettierrc.yml',
+ '.prettierrc.yaml',
+ '.prettierrc.json5',
+ '.prettierrc.mjs',
+ '.prettierrc.cjs',
+ '.prettierrc.toml',
+ },
+ }
+
+ lspconfig.omnisharp.setup {}
+ lspconfig.tsserver.setup {}
+ lspconfig.jdtls.setup {}
+ lspconfig.pyright.setup {}
+ lspconfig.eslint.setup {}
+ lspconfig.sourcekit.setup {}
+ lspconfig.efm.setup {
+ settings = {
+ rootMarkers = {".git/"},
+ languages = {
+ typescript = typescript_formatter,
+ typescriptreact = typescript_formatter,
+ },
+ },
+ init_options = {documentFormatting = true},
+ filetypes = { "typescript","typescriptreact" },
+ }
+
+ local cmp = require'cmp'
+
+ cmp.setup({
+ mapping = cmp.mapping.preset.insert({
+ ['<C-Space>'] = cmp.mapping.complete(),
+ ['<C-e>'] = cmp.mapping.abort()
+ }),
+ sources = cmp.config.sources({
+ { name = 'nvim_lsp' },
+ }, {
+ {
+ name = 'buffer',
+ option = {
+ get_bufnrs = function()
+ local bufs = {}
+ for _, win in ipairs(vim.api.nvim_list_wins()) do
+ bufs[vim.api.nvim_win_get_buf(win)] = true
+ end
+ return vim.tbl_keys(bufs)
+ end
+ },
+ },
+ })
+ })
+
+ vim.api.nvim_create_autocmd('LspAttach', {
+ group = vim.api.nvim_create_augroup('UserLspConfig', {}),
+ callback = function(ev)
+ local opts = { buffer = ev.buf }
+ vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
+ vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
+ vim.keymap.set('n', '<leader>a', vim.lsp.buf.code_action, opts)
+ vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, opts)
+ vim.keymap.set('n', '<leader>d', vim.diagnostic.disable, opts)
+ vim.keymap.set('n', '<leader>he', vim.diagnostic.open_float, opts)
+ vim.keymap.set('n', '<leader>hh', vim.lsp.buf.hover, opts)
+ vim.keymap.set('n', '<leader>q', vim.diagnostic.setqflist, opts)
+
+ vim.api.nvim_set_hl(0, '@lsp.type.function', {})
+ end,
+ })
+
+EOF
+" }}}