From 16026289eca4f64a39f35bc9b93663d7b8c379e7 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Mon, 11 Oct 2021 01:27:00 +0300 Subject: neovim: big lua push --- .config/nvim/lua/autocmds.lua | 2 +- .config/nvim/lua/functions.lua | 24 +++++++ .config/nvim/lua/mappings.lua | 15 ++-- .config/nvim/lua/plugin_settings.lua | 135 +++++++++++++++++++++++++++++++---- .config/nvim/lua/plugins.lua | 40 ++++++++--- .config/nvim/lua/settings.lua | 1 + 6 files changed, 184 insertions(+), 33 deletions(-) create mode 100644 .config/nvim/lua/functions.lua (limited to '.config/nvim') diff --git a/.config/nvim/lua/autocmds.lua b/.config/nvim/lua/autocmds.lua index 6b3279e..90915db 100644 --- a/.config/nvim/lua/autocmds.lua +++ b/.config/nvim/lua/autocmds.lua @@ -51,6 +51,7 @@ au.FileType = { end, } +-- gf plugins au.BufEnter = { 'init.lua', function() @@ -64,4 +65,3 @@ au.BufLeave = { vim.opt.path:remove("./lua") end } - diff --git a/.config/nvim/lua/functions.lua b/.config/nvim/lua/functions.lua new file mode 100644 index 0000000..daee597 --- /dev/null +++ b/.config/nvim/lua/functions.lua @@ -0,0 +1,24 @@ +-- ┌──────────────────────────┐ +-- │▗▀▖ ▐ ▗ │ +-- │▐ ▌ ▌▛▀▖▞▀▖▜▀ ▄ ▞▀▖▛▀▖▞▀▘│ +-- │▜▀ ▌ ▌▌ ▌▌ ▖▐ ▖▐ ▌ ▌▌ ▌▝▀▖│ +-- │▐ ▝▀▘▘ ▘▝▀ ▀ ▀▘▝▀ ▘ ▘▀▀ │ +-- └──────────────────────────┘ +-- 2021-10-10 21:50 WIP, I don't know how to integrate these functions to init.lua and honestly, everything is a nvim_command or something anyway + +local random = math.random + +local function random_filename() + uuid = '' + for i=0,6 do + uuid = uuid .. (string.format('%x', random(0, 0xf))) + end + return uuid +end + +function create_note() + nvim_command("e! " .. nvim_call_function('fnameescape', '~/nextcloud/personal_wiki/text/box/' .. random_filename() .. ".wiki")) + local text = "= up =\n\n= down =\n\n= keywords =\n\n" + nvim_command("put! " .. text) + nvim_command("normal gg") +end diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua index 6633134..ffd8610 100644 --- a/.config/nvim/lua/mappings.lua +++ b/.config/nvim/lua/mappings.lua @@ -93,7 +93,7 @@ map('n', 'nr', ':call CreateReference(expand(""))') -- create a new note map('n', 'nn', ':call CreateNote()') --- plug mappings {{{1 -- +-- plug mappings {{{ -- -- mappings should not be noremap -- https://www.reddit.com/r/vim/comments/78izt4/please_help_understand_how_to_use_plug_mapping/ @@ -135,11 +135,6 @@ plugmap('n', 'ss', '(SubversiveSubvertWordRange)') plugmap('n', '', '(YoinkPostPasteSwapBack)') plugmap('n', '', '(YoinkPostPasteSwapForward)') --- insert mode completion -plugmap('i', '', '(fzf-complete-word)') -plugmap('i', '', '(fzf-complete-path)') -plugmap('i', '', '(fzf-complete-line)') - -- checkmarks on vimwiki plugmap('n', 'v', 'VimwikiToggleListItem') -- add/increase header level @@ -152,4 +147,10 @@ map('n', 't', ':TestSuite') map('n', 't', ':TestLast') map('n', 't', ':TestVisit') --- 1}}} -- +-- telescope bindings +map('n', 'ff', "lua require('telescope.builtin').find_files()") +map('n', 'fg', "lua require('telescope.builtin').live_grep()") +map('n', 'fb', "lua require('telescope.builtin').buffers()") +map('n', 'fh', "lua require('telescope.builtin').help_tags()") + +-- }}} plug mappings -- diff --git a/.config/nvim/lua/plugin_settings.lua b/.config/nvim/lua/plugin_settings.lua index 60bbbe1..e9c4cd4 100644 --- a/.config/nvim/lua/plugin_settings.lua +++ b/.config/nvim/lua/plugin_settings.lua @@ -66,7 +66,7 @@ require'lualine'.setup { } -- }}} requi -- --- Cutlass suite {{{1 -- +-- cutlass suite {{{ -- -- cutlass/yoink/subverse suite g.yoinkIncludeDeleteOperations = 1 @@ -85,7 +85,7 @@ g.clipboard = { cache_enabled = 1, } --- 1}}} -- +-- }}} cutlass suite -- -- UltiSnips {{{ -- opt.runtimepath:append('/home/yigit/.vim/my-snippets/') @@ -101,12 +101,6 @@ g.beacon_shrink = 1 cmd('highlight Beacon guibg=red ctermbg=15') -- }}} beacon -- --- vim-slime {{{ -- -g.slime_target = "tmux" -g.slime_paste_file = "/home/yigit/.slime_paste" --- g.slime_default_config = {socket_name = get(split($TMUX, ","), 0), target_pane = "{last}"} --- }}} vim-slime -- - -- vimtex {{{ -- g.vimtex_view_method = 'zathura' g.vimtex_quickfix_mode = 0 @@ -138,15 +132,20 @@ g.ledger_fillstring = ' -' require'nvim-web-devicons'.setup { override = { wiki = { - icon = "", + icon = "", color = "#D7827E", - name = "vimwiki" + name = "vimwiki" }, rem = { - icon = "", + icon = "", color = "#B4637A", - name = "remind" - } + name = "remind" + }, + mail = { + icon = "", + color = "#907AA9", + name = "mail" + }, }; default = true @@ -193,7 +192,115 @@ g.gutentags_ctags_exclude = { } -- }}} gutentags -- --- float preview +-- 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", -- or "ignore_case" or "respect_case" + -- the default case_mode is "smart_case" + } + } +} + +require('telescope').load_extension('fzf') +-- }}} telescope -- + +-- dashboard {{{ -- +g.dashboard_default_executive = 'telescope' +g.dashboard_preview_command = 'cat' +g.dashboard_preview_pipeline = 'lolcat' +g.dashboard_preview_file = '~/.config/nvim/neovim.cat' +g.dashboard_preview_file_height = 14 +g.dashboard_preview_file_width = 90 +-- }}} dashboard -- + +-- treesitter {{{ -- + +require'nvim-treesitter.configs'.setup { + ensure_installed = "maintained", + ignore_install = { "javascript" }, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, +} +-- }}} treesitter -- + +-- nvim-cmp {{{ -- +local cmp = require'cmp' + +cmp.setup({ + snippet = { + expand = function(args) + vim.fn["UltiSnips#Anon"](args.body) + end, + }, + mapping = { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm({ select = true }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'ultisnips' }, + { name = 'buffer' }, + { name = "latex_symbols" }, + } +}) + +-- }}} nvim-cmp -- + +-- nvim-lsp {{{ -- +local nvim_lsp = require('lspconfig') + +local on_attach = function(client, bufnr) + local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end + local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end + + -- Enable completion triggered by + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + local opts = { noremap=true, silent=true } + + -- See `:help vim.lsp.*` for documentation on any of the below functions + buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + buf_set_keymap('n', 'vh', 'lua vim.lsp.buf.hover()', opts) + buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + buf_set_keymap('n', 'vs', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + buf_set_keymap('n', 'wd', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) + buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) + buf_set_keymap('n', 'd', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) + buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) +end + +local servers = { 'rust_analyzer', 'jedi_language_server', 'texlab' } +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { + on_attach = on_attach, + flags = { + debounce_text_changes = 150, + }, + capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) + } +end + +-- }}} nvim-lsp -- + g["float_preview#docked"] = 0 -- highlight on yank diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 8233e44..35750e9 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -8,12 +8,36 @@ return require('packer').startup(function() -- packer can manage itself use 'wbthomason/packer.nvim' - -- latex suite use {'lervag/vimtex', ft = {'tex', 'latex', 'plaintext'}} - -- still here, going away soon say bye bye - use 'dense-analysis/ale' + -- treesitter... + use { + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate' + } + use 'nvim-treesitter/playground' + + -- quickstart lsp config + use 'neovim/nvim-lspconfig' + + -- dashboard + use 'glepnir/dashboard-nvim' + + -- completion suite + use 'hrsh7th/cmp-nvim-lsp' + use 'hrsh7th/cmp-buffer' + use 'hrsh7th/nvim-cmp' + use 'kdheepak/cmp-latex-symbols' + use 'quangnguyen30192/cmp-nvim-ultisnips' + + -- find, filter, preview, pick + use { + 'nvim-telescope/telescope.nvim', + requires = { {'nvim-lua/plenary.nvim'} } + } + use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make' } + -- manages tag files use 'ludovicchabant/vim-gutentags' -- run tests (todo: write tests) @@ -22,7 +46,6 @@ return require('packer').startup(function() use 'jpalardy/vim-slime' -- snippets to expand use {'SirVer/ultisnips', 'honza/vim-snippets'} - -- auto pair plugin, people hate these use 'tmsvg/pear-tree' -- git diff in the sign column @@ -30,6 +53,7 @@ return require('packer').startup(function() -- completion preview of floating window use 'ncm2/float-preview.nvim' + -- language packs use "nathom/filetype.nvim" -- i3 config filetype @@ -39,9 +63,6 @@ return require('packer').startup(function() -- ledger filetype use 'ledger/vim-ledger' - use {'junegunn/fzf', dir = '~/.fzf'} - use 'junegunn/fzf.vim' - -- file explorer use 'lambdalisue/fern.vim' -- bug in neovim, so required for now @@ -59,7 +80,7 @@ return require('packer').startup(function() -- highlight colors use { 'norcalli/nvim-colorizer.lua', - ft = { 'css', 'javascript', 'vim', 'html' }, + ft = {'css', 'javascript', 'vim', 'html'}, config = [[require('colorizer').setup {'css', 'javascript', 'vim', 'html'}]], } @@ -130,7 +151,4 @@ return require('packer').startup(function() use 'tpope/vim-commentary' -- asynchronous build and test dispatcher use {'tpope/vim-dispatch', opt = true, cmd = {'Dispatch', 'Make', 'Focus', 'Start'}} - - -- fancy start screen - use 'mhinz/vim-startify' end) diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua index 5931e5d..7276b0e 100644 --- a/.config/nvim/lua/settings.lua +++ b/.config/nvim/lua/settings.lua @@ -95,3 +95,4 @@ opt.diffopt = { -- menu: use a popup menu to show the possible completions -- preview: show extra information opt.completeopt = {"menu", "preview"} + -- cgit v1.2.3-70-g09d2