Add nvim writing init
This commit is contained in:
338
nvim/writing-init.lua
Normal file
338
nvim/writing-init.lua
Normal file
@ -0,0 +1,338 @@
|
|||||||
|
-------------------------
|
||||||
|
-------- OPTIONS --------
|
||||||
|
-------------------------
|
||||||
|
vim.opt.mouse = 'a'
|
||||||
|
vim.opt.history = 1000
|
||||||
|
-- vim.opt.ruler = true
|
||||||
|
-- vim.opt.ruler = true
|
||||||
|
-- vim.opt.number = true
|
||||||
|
vim.opt.showcmd = true
|
||||||
|
vim.opt.ttimeoutlen = 100
|
||||||
|
vim.opt.backspace = 'indent,eol,start'
|
||||||
|
vim.opt.tabstop = 2
|
||||||
|
vim.opt.expandtab = true
|
||||||
|
vim.opt.shiftwidth = 2
|
||||||
|
vim.opt.softtabstop = 2
|
||||||
|
vim.opt.autoindent = true
|
||||||
|
vim.opt.showmatch = true
|
||||||
|
vim.opt.incsearch = true
|
||||||
|
vim.opt.hlsearch = true
|
||||||
|
vim.opt.wrapscan = true
|
||||||
|
vim.opt.ignorecase = true
|
||||||
|
vim.opt.smartcase = true
|
||||||
|
vim.opt.hidden = true
|
||||||
|
vim.opt.splitright = true
|
||||||
|
vim.opt.splitbelow = true
|
||||||
|
vim.opt.swapfile = false
|
||||||
|
vim.opt.wildmode = 'longest,list'
|
||||||
|
vim.opt.wildignore = vim.opt.wildignore + 'main,*.o,*.d,*.aux,*.bbl,*.lof,*.loa,*.blg,*.fdb_latexmk,*.fls,*.tdo,*.pdf,*.pyc'
|
||||||
|
vim.opt.spell = false
|
||||||
|
vim.opt.foldmethod = 'syntax'
|
||||||
|
vim.opt.foldopen = vim.opt.foldopen - 'block'
|
||||||
|
vim.opt.foldlevel = 99
|
||||||
|
vim.opt.lazyredraw = true
|
||||||
|
vim.opt.listchars = 'eol:¬,tab:▸ ,trail:·'
|
||||||
|
vim.opt.fillchars = 'vert:|,fold: '
|
||||||
|
vim.opt.list = true
|
||||||
|
vim.opt.laststatus = 2
|
||||||
|
vim.opt.scrolloff = 8
|
||||||
|
vim.opt.background = 'light'
|
||||||
|
vim.opt.wrap = true
|
||||||
|
vim.opt.showbreak = '..'
|
||||||
|
vim.opt.errorbells = false
|
||||||
|
vim.opt.visualbell = false
|
||||||
|
vim.opt.title = true
|
||||||
|
vim.opt.autoread = true
|
||||||
|
vim.opt.syntax = 'on'
|
||||||
|
vim.opt.encoding = 'utf-8'
|
||||||
|
vim.opt.completeopt = 'menu,menuone,noselect'
|
||||||
|
|
||||||
|
|
||||||
|
----------------------------
|
||||||
|
-------- CLIPBOARD ---------
|
||||||
|
----------------------------
|
||||||
|
-- if vim.fn.has("wsl") == 1 then
|
||||||
|
vim.opt.clipboard:append('unnamedplus')
|
||||||
|
-- end
|
||||||
|
|
||||||
|
|
||||||
|
----------------------------
|
||||||
|
-------- COMMANDS ----------
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
vim.cmd('filetype plugin indent on')
|
||||||
|
|
||||||
|
-- vim.cmd('colorscheme lucius')
|
||||||
|
-- vim.cmd('LuciusWhite')
|
||||||
|
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
---------- AUTOGROUPS --------
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
vim.api.nvim_create_augroup('VimIntern', { clear = true })
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({'FocusGained', 'BufEnter', 'CursorMoved', 'CursorMovedI', 'CursorHold', 'CursorHoldI'}, {
|
||||||
|
group = 'VimIntern',
|
||||||
|
pattern = '*',
|
||||||
|
command = 'silent! checktime'
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd('BufEnter', {
|
||||||
|
group = 'VimIntern',
|
||||||
|
pattern = '*',
|
||||||
|
command = 'silent! lcd %:p:h'
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------
|
||||||
|
---------- FUNCTIONS --------
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command('TrimWhiteSpace', function()
|
||||||
|
vim.cmd('%s/\\s\\+$//e')
|
||||||
|
end, {})
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
|
||||||
|
-- Navigation
|
||||||
|
vim.keymap.set('n', 'j', 'gj', {})
|
||||||
|
vim.keymap.set('n', 'k', 'gk', {})
|
||||||
|
vim.keymap.set('v', 'j', 'gj', {})
|
||||||
|
vim.keymap.set('v', 'k', 'gk', {})
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<C-h>', '<C-w>h', {})
|
||||||
|
vim.keymap.set('n', '<C-j>', '<C-w>j', {})
|
||||||
|
vim.keymap.set('n', '<C-k>', '<C-w>k', {})
|
||||||
|
vim.keymap.set('n', '<C-l>', '<C-w>l', {})
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<leader>s', ':call WindowSwap#EasyWindowSwap()<CR>', {})
|
||||||
|
|
||||||
|
-- Convenience
|
||||||
|
vim.keymap.set('n', '<leader>w', ':w<CR>', { silent = true })
|
||||||
|
vim.keymap.set('n', '<leader>F', ':e.<CR>', {})
|
||||||
|
vim.keymap.set('n', 'Y', 'y$', {})
|
||||||
|
|
||||||
|
-- Telescope
|
||||||
|
local telebuiltin = require('telescope.builtin')
|
||||||
|
vim.keymap.set('n', '<leader>ff', telebuiltin.find_files, { silent = true })
|
||||||
|
vim.keymap.set('n', '<leader>fg', telebuiltin.live_grep, { silent = true })
|
||||||
|
vim.keymap.set('n', '<leader>fs', telebuiltin.grep_string, { silent = true })
|
||||||
|
vim.keymap.set('n', '<leader>o', telebuiltin.buffers, { silent = true })
|
||||||
|
vim.keymap.set('n', '<leader>fh', telebuiltin.help_tags, { silent = true })
|
||||||
|
|
||||||
|
---- Yanky
|
||||||
|
--vim.keymap.set({"n","x"}, "p", "<Plug>(YankyPutAfter)")
|
||||||
|
--vim.keymap.set({"n","x"}, "P", "<Plug>(YankyPutBefore)")
|
||||||
|
--vim.keymap.set({"n","x"}, "gp", "<Plug>(YankyGPutAfter)")
|
||||||
|
--vim.keymap.set({"n","x"}, "gP", "<Plug>(YankyGPutBefore)")
|
||||||
|
--vim.keymap.set("n", "<c-n>", "<Plug>(YankyCycleForward)")
|
||||||
|
--vim.keymap.set("n", "<c-p>", "<Plug>(YankyCycleBackward)")
|
||||||
|
--vim.keymap.set({"n","x"}, "y", "<Plug>(YankyYank)")
|
||||||
|
|
||||||
|
-- Undotree
|
||||||
|
vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle)
|
||||||
|
|
||||||
|
---- nnoremap <silent> <leader>t :CtrlPBufTagAll<CR>
|
||||||
|
---- nnoremap <silent> <leader>T :TagbarToggle<CR>
|
||||||
|
vim.g.delimitMate_expand_space=1
|
||||||
|
vim.g.delimitMate_expand_cr = 1
|
||||||
|
|
||||||
|
vim.g.tagbar_left=1
|
||||||
|
vim.g.tagbar_autoclose=1
|
||||||
|
vim.g.tagbar_autofocus=1
|
||||||
|
|
||||||
|
--vim.g.windowswap_map_keys=0
|
||||||
|
|
||||||
|
local cmp = require('cmp')
|
||||||
|
local lspkind = require('lspkind')
|
||||||
|
|
||||||
|
--cmp.setup({
|
||||||
|
-- snippet = {
|
||||||
|
-- expand = function(args)
|
||||||
|
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||||
|
-- end,
|
||||||
|
-- },
|
||||||
|
|
||||||
|
-- window = {
|
||||||
|
-- completion = cmp.config.window.bordered(),
|
||||||
|
-- documentation = cmp.config.window.bordered(),
|
||||||
|
-- },
|
||||||
|
|
||||||
|
-- mapping = cmp.mapping.preset.insert({
|
||||||
|
-- ['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
-- ['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
-- ['<C-Space>'] = cmp.mapping.complete(),
|
||||||
|
-- ['<C-e>'] = cmp.mapping.abort(),
|
||||||
|
-- ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||||
|
-- }),
|
||||||
|
|
||||||
|
-- sources = cmp.config.sources({
|
||||||
|
-- { name = 'nvim_lsp' },
|
||||||
|
-- { name = 'vsnip' },
|
||||||
|
-- { name = 'path' },
|
||||||
|
-- { name = 'cmp_yanky' },
|
||||||
|
-- { name = 'git' },
|
||||||
|
-- { name = 'copilot' },
|
||||||
|
-- -- }, {
|
||||||
|
-- { name = 'buffer', keyword_length = 2 },
|
||||||
|
-- }),
|
||||||
|
|
||||||
|
-- formatting = {
|
||||||
|
-- format = lspkind.cmp_format({
|
||||||
|
-- -- mode = "symbol_text",
|
||||||
|
-- mode = "symbol",
|
||||||
|
-- menu = ({
|
||||||
|
-- buffer = "[buf]",
|
||||||
|
-- nvim_lsp = "[lsp]",
|
||||||
|
-- vsnip = "[snip]",
|
||||||
|
-- nvim_lua = "[lua]",
|
||||||
|
-- latex_symbols = "[tex]",
|
||||||
|
-- path = "[path]",
|
||||||
|
-- cmp_yanky = "[yank]",
|
||||||
|
-- copilot = "[copilot]",
|
||||||
|
-- }),
|
||||||
|
-- symbol_map = { Copilot = "" }
|
||||||
|
-- }),
|
||||||
|
-- },
|
||||||
|
--})
|
||||||
|
|
||||||
|
---- -- Set configuration for specific filetype.
|
||||||
|
---- cmp.setup.filetype('gitcommit', {
|
||||||
|
---- sources = cmp.config.sources({
|
||||||
|
---- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
||||||
|
---- }, {
|
||||||
|
---- { name = 'buffer' },
|
||||||
|
---- })
|
||||||
|
---- })
|
||||||
|
|
||||||
|
--cmp.setup.cmdline({ '/', '?' }, {
|
||||||
|
-- mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
-- sources = {
|
||||||
|
-- { name = 'buffer' }
|
||||||
|
-- }
|
||||||
|
--})
|
||||||
|
|
||||||
|
--cmp.setup.cmdline(':', {
|
||||||
|
-- mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
-- sources = cmp.config.sources({
|
||||||
|
-- { name = 'path' }
|
||||||
|
-- }, {
|
||||||
|
-- { name = 'cmdline' }
|
||||||
|
-- }),
|
||||||
|
-- matching = { disallow_symbol_nonprefix_matching = false }
|
||||||
|
--})
|
||||||
|
|
||||||
|
--local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
|
local lspconfig = require("lspconfig")
|
||||||
|
--lspconfig.gopls.setup({ capabilities = capabilities })
|
||||||
|
--lspconfig.svelte.setup({ capabilities = capabilities })
|
||||||
|
--lspconfig.pyright.setup({ capabilities = capabilities })
|
||||||
|
--lspconfig.omnisharp.setup({ capabilities = capabilities })
|
||||||
|
--lspconfig.clangd.setup({ capabilities = capabilities })
|
||||||
|
--lspconfig.dockerls.setup({ capabilities = capabilities })
|
||||||
|
--lspconfig.docker_compose_language_service.setup({ capabilities = capabilities })
|
||||||
|
--lspconfig.flow.setup({ capabilities = capabilities })
|
||||||
|
lspconfig.marksman.setup({ capabilities = capabilities })
|
||||||
|
--lspconfig.als.setup({ capabilities = capabilities })
|
||||||
|
--lspconfig.sqls.setup({ capabilities = capabilities })
|
||||||
|
--lspconfig.yamlls.setup({ capabilities = capabilities })
|
||||||
|
--lspconfig.nil_ls.setup({ capabilities = capabilities })
|
||||||
|
|
||||||
|
require("yanky").setup({
|
||||||
|
ring = {
|
||||||
|
history_length = 100,
|
||||||
|
storage = "shada",
|
||||||
|
sync_with_numbered_registers = true,
|
||||||
|
cancel_event = "update",
|
||||||
|
},
|
||||||
|
system_clipboard = {
|
||||||
|
sync_with_ring = true,
|
||||||
|
},
|
||||||
|
preserve_cursor_position = {
|
||||||
|
enabled = true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
require("telescope").load_extension("yank_history")
|
||||||
|
|
||||||
|
require'nvim-treesitter.configs'.setup {
|
||||||
|
-- ensure_installed = { "lua", "vim", "help" },
|
||||||
|
ensure_installed = {},
|
||||||
|
sync_install = false,
|
||||||
|
auto_install = false,
|
||||||
|
|
||||||
|
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
|
||||||
|
disable = function(lang, buf)
|
||||||
|
local max_filesize = 100 * 1024 -- 100 KB
|
||||||
|
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||||
|
if ok and stats and stats.size > max_filesize then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
additional_vim_regex_highlighting = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
require('lualine').setup({
|
||||||
|
options = {
|
||||||
|
icons_enabled = true,
|
||||||
|
theme = 'Tomorrow',
|
||||||
|
component_separators = { left = '', right = ''},
|
||||||
|
section_separators = { left = '', right = ''},
|
||||||
|
disabled_filetypes = {
|
||||||
|
statusline = {},
|
||||||
|
winbar = {},
|
||||||
|
},
|
||||||
|
ignore_focus = {},
|
||||||
|
always_divide_middle = true,
|
||||||
|
globalstatus = false,
|
||||||
|
refresh = {
|
||||||
|
statusline = 1000,
|
||||||
|
tabline = 1000,
|
||||||
|
winbar = 1000,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sections = {
|
||||||
|
lualine_a = {'mode'},
|
||||||
|
lualine_b = {'branch', 'diff', 'diagnostics'},
|
||||||
|
lualine_c = {'filename'},
|
||||||
|
lualine_x = {'encoding', 'fileformat', 'filetype'},
|
||||||
|
lualine_y = {'progress'},
|
||||||
|
lualine_z = {'location'}
|
||||||
|
},
|
||||||
|
inactive_sections = {
|
||||||
|
lualine_a = {},
|
||||||
|
lualine_b = {},
|
||||||
|
lualine_c = {'filename'},
|
||||||
|
lualine_x = {'location'},
|
||||||
|
lualine_y = {},
|
||||||
|
lualine_z = {}
|
||||||
|
},
|
||||||
|
tabline = {},
|
||||||
|
winbar = {},
|
||||||
|
inactive_winbar = {},
|
||||||
|
extensions = {}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
--require("copilot").setup({
|
||||||
|
-- suggestion = { enabled = false },
|
||||||
|
-- panel = { enabled = false },
|
||||||
|
--})
|
||||||
|
--require("copilot_cmp").setup()
|
||||||
|
|
||||||
|
require("aerial").setup({
|
||||||
|
-- optionally use on_attach to set keymaps when aerial has attached to a buffer
|
||||||
|
on_attach = function(bufnr)
|
||||||
|
-- Jump forwards/backwards with '{' and '}'
|
||||||
|
vim.keymap.set("n", "{", "<cmd>AerialPrev<CR>", { buffer = bufnr })
|
||||||
|
vim.keymap.set("n", "}", "<cmd>AerialNext<CR>", { buffer = bufnr })
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
-- You probably also want to set a keymap to toggle aerial
|
||||||
|
vim.keymap.set("n", "<leader>a", "<cmd>AerialToggle!<CR>")
|
||||||
|
|
||||||
Reference in New Issue
Block a user