nvim: added markdown preview, restructured plugins for easier cleanup

master
tiyn 1 year ago
parent a065c3d401
commit 1ea26420bf

@ -5,6 +5,9 @@ vim.o.showmode = false
vim.o.mouse = 'a'
vim.o.clipboard = 'unnamedplus'
-- basic color settings
vim.o.background = 'dark'
-- setting Tab-length
vim.o.expandtab = true
vim.o.softtabstop = 4
@ -40,10 +43,13 @@ vim.o.lazyredraw = true
-- textEdit might fail without hidden
vim.o.hidden = true
-- disable Backupfiles for Lsp
-- disable backupfiles
vim.o.nobackup = true
vim.o.nowritebackup = true
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'
-- always show the signcolumn
vim.o.signcolumn = "yes"
@ -63,6 +69,3 @@ require('loadplugins')
-- load general mapped keys
require('keymap')
-- load general colorscheme
require('colorscheme')

@ -3,12 +3,6 @@
-- set mapleader for hotkeys
vim.g.mapleader = ","
-- shortcut for split navigation
vim.api.nvim_set_keymap('n', '<C-h>', '<C-w>h', { noremap = true })
vim.api.nvim_set_keymap('n', '<C-j>', '<C-w>j', { noremap = true })
vim.api.nvim_set_keymap('n', '<C-k>', '<C-w>k', { noremap = true })
vim.api.nvim_set_keymap('n', '<C-l>', '<C-w>l', { noremap = true })
-- unmap unwanted commands
vim.api.nvim_set_keymap('n', '<F1>', '<NOP>', { noremap = true })
vim.api.nvim_set_keymap('n', '<F4>', '<NOP>', { noremap = true })
@ -28,6 +22,12 @@ vim.api.nvim_set_keymap('i', '<F10>', '<NOP>', { noremap = true })
vim.api.nvim_set_keymap('i', '<F11>', '<NOP>', { noremap = true })
vim.api.nvim_set_keymap('i', '<F12>', '<NOP>', { noremap = true })
-- shortcut for split navigation
vim.api.nvim_set_keymap('n', '<C-h>', '<C-w>h', { noremap = true })
vim.api.nvim_set_keymap('n', '<C-j>', '<C-w>j', { noremap = true })
vim.api.nvim_set_keymap('n', '<C-k>', '<C-w>k', { noremap = true })
vim.api.nvim_set_keymap('n', '<C-l>', '<C-w>l', { noremap = true })
-- mapping Dictionaries
vim.api.nvim_set_keymap('n', '<F6>', ':setlocal spell! spelllang=de_de<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<F7>', ':setlocal spell! spelllang=en_us<CR>', { noremap = true })
@ -35,24 +35,31 @@ vim.api.nvim_set_keymap('n', '<F7>', ':setlocal spell! spelllang=en_us<CR>', { n
-- compiler for languages
vim.api.nvim_set_keymap('n', '<leader>c', ':w! | !compiler <c-r>%<CR>', { noremap = true })
-- open corresponding file (pdf/html/...)
vim.api.nvim_set_keymap('n', '<leader>p', ':!opout <c-r>%<CR><CR>', { noremap = true })
-- save file as sudo on files that require root permission
vim.api.nvim_set_keymap('c', 'w!!', '"silent! write !sudo tee % >/dev/null" <bar> edit!', { noremap = true })
-- alias for replacing
vim.api.nvim_set_keymap('n', '<leader>ss', ':%s//gI<Left><Left><Left>', { noremap = true })
-- irc compatibility for interactivity
vim.api.nvim_set_keymap('n', '<leader>is', ':.w >> in<cr>dd', { noremap = true })
-- majutsushi/tagbar
-- open corresponding file (pdf/html/...,md)
vim.api.nvim_set_keymap('n', '<leader>p', ':!opout <c-r>%<CR><CR>', { noremap = true })
-- iamcco/markdown-preview.nvim
vim.api.nvim_create_autocmd('FileType', {
pattern = 'markdown',
callback = function()
vim.api.nvim_set_keymap('n', '<leader>p', ':MarkdownPreviewToggle<CR>', { noremap = true })
end,
})
-- SmiteshP/nvim-navbuddy
vim.api.nvim_set_keymap('n', '<F3>', ':Navbuddy<CR>', {})
-- scrooloose/nerdtree
-- nvim-neo-tree/neo-tree.nvim
vim.api.nvim_set_keymap('n', '<F2>', ':Neotree toggle<CR>', {})
-- tpope/vim-fugitive

@ -30,6 +30,11 @@ return require("packer").startup(function(use)
-- show signature while typing
use { 'ray-x/lsp_signature.nvim' }
-- preview for markdown filetypes
use { "iamcco/markdown-preview.nvim",
ft = { 'md' },
run = "cd app && npm install" }
-- latex asynchronous pdf rendering
use { 'donRaphaco/neotex',
ft = { 'tex' } }

@ -1,6 +1,4 @@
-- colorscheme
-- basic color settings
vim.o.background = 'dark'
-- tiyn/vim-tccs
vim.cmd('colorscheme tccs')
vim.api.nvim_set_hl(0, 'colorcolumn', { bg = '#772222' })

@ -1,48 +1,8 @@
-- hrsh7th/nvim-cmp
-- jose-elias-alvarez/null-ls.nvim
local null_ls = require("null-ls")
null_ls.setup({
sources = {
require("null-ls-embedded").nls_source,
null_ls.builtins.formatting.black,
null_ls.builtins.formatting.mdformat,
},
})
require("null-ls").setup({
sources = {
require("null-ls-embedded").nls_source.with({
-- default filetypes:
filetypes = { "markdown" },
}),
},
})
-- mason package manager
require("mason").setup()
require("mason-lspconfig").setup({
-- automatically install language servers setup below for lspconfig
automatic_setup = true,
})
require("mason-null-ls").setup({
automatic_installation = true,
ensure_installed = {}
})
-- Add additional capabilities supported by nvim-cmp
capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'
-- nvim-cmp setup
local cmp = require("cmp")
local luasnip = require("luasnip")
local lspkind = require("lspkind")
require("luasnip.loaders.from_snipmate").lazy_load()
cmp.setup {
sorting = {
comparators = {
@ -93,7 +53,7 @@ cmp.setup {
{ name = 'luasnip' },
},
formatting = {
format = lspkind.cmp_format({
format = require("lspkind").cmp_format({
mode = "symbol_text",
preset = "codicons",
maxwidth = 50,
@ -133,11 +93,35 @@ cmp.setup {
}),
},
}
require("luasnip.loaders.from_snipmate").lazy_load()
-- neovim/nvim-lspconfig
local nvim_lsp = require('lspconfig')
-- jose-elias-alvarez/null-ls.nvim
local null_ls = require("null-ls")
null_ls.setup({
sources = {
require("null-ls-embedded").nls_source.with({
filetypes = { "markdown" },
}),
null_ls.builtins.formatting.black,
null_ls.builtins.formatting.mdformat,
},
})
-- williamboman/mason.nvim
require("mason").setup()
-- williamboman/mason-lspconfig.nvim
require("mason-lspconfig").setup({
automatic_setup = true,
})
-- jay-babu/mason-null-ls.nvim
require("mason-null-ls").setup({
automatic_installation = true,
ensure_installed = {}
})
-- ray-x/lsp_signature.nvim
require "lsp_signature".setup({
bind = true,
handler_opts = {
@ -145,26 +129,31 @@ require "lsp_signature".setup({
}
})
-- smiteshp/nvim-navbuddy
local navbuddy = require("nvim-navbuddy")
-- hrsh7th/cmp-nvim-lsp
local cmp_nvim_lsp = require("cmp_nvim_lsp")
-- neovim/nvim-lspconfig
local nvim_lsp = require('lspconfig')
local servers = { "pyright", "bashls", "texlab", "ccls", "nimls", "marksman" }
local attach_func = function(client, bufnr)
navbuddy.attach(client, bufnr)
end
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { "pyright", "bashls", "texlab", "ccls", "nimls", "marksman" }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = attach_func,
capabilities = capabilities,
capabilities = cmp_nvim_lsp.default_capabilities(),
flags = {
debounce_text_changes = 150
}
}
end
require 'lspconfig'.jdtls.setup {
on_attach = attach_func,
flags = {

Loading…
Cancel
Save