From dbc8f9ae007b4003888ca893330ddbb235b2d3bd Mon Sep 17 00:00:00 2001 From: pegasust Date: Sun, 14 Aug 2022 00:36:50 -0700 Subject: [PATCH 01/32] Init --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..96bf7ed --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# dotfiles From bdda612d66966270e5c5af93e3560d9253b13817 Mon Sep 17 00:00:00 2001 From: pegasust Date: Sun, 14 Aug 2022 00:48:17 -0700 Subject: [PATCH 02/32] add basic vim options --- neovim/init.lua | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 neovim/init.lua diff --git a/neovim/init.lua b/neovim/init.lua new file mode 100644 index 0000000..7e6193a --- /dev/null +++ b/neovim/init.lua @@ -0,0 +1,8 @@ +vim.cmd([[ +set number relativenumber +set tabstop=4 softtabstop=4 +set expandtab +set shiftwidth=4 +set exrc + +]]) From 2d84a6c1d99b2a8bf44e4c2987879e0565a76e06 Mon Sep 17 00:00:00 2001 From: pegasust Date: Sun, 14 Aug 2022 01:57:04 -0700 Subject: [PATCH 03/32] add vim-plug and couple more settings --- neovim/init.lua | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/neovim/init.lua b/neovim/init.lua index 7e6193a..84123ec 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -1,8 +1,34 @@ +-- Basic settings of vim vim.cmd([[ set number relativenumber set tabstop=4 softtabstop=4 set expandtab set shiftwidth=4 +set smartindent set exrc - +set incsearch +set scrolloff=7 +set signcolumn=yes +set colorcolumn=80 +set background=light ]]) +vim.opt.termguicolors = true + +-- vim-plug +vim.cmd([[ +let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' +if empty(glob(data_dir . '/autoload/plug.vim')) + silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC +endif +]]) + +local Plug = vim.fn['plug#'] +vim.call('plug#begin', '~/.config/nvim/plugged') +Plug('nvim-lua/plenary.nvim') +Plug('nvim-telescope/telescope.nvim', {tag = '0.1.0'}) +Plug('gruvbox-community/gruvbox') +vim.call('plug#end') + +vim.cmd.colorscheme('gruvbox') + From 04543adb0526a18540cb9b6d490e3fc3c4eca191 Mon Sep 17 00:00:00 2001 From: pegasust Date: Sun, 14 Aug 2022 23:45:08 -0700 Subject: [PATCH 04/32] add devexp plugins and their mappings --- neovim/init.lua | 119 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 116 insertions(+), 3 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index 84123ec..ab2d4b4 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -7,12 +7,30 @@ set shiftwidth=4 set smartindent set exrc set incsearch -set scrolloff=7 +set scrolloff=15 set signcolumn=yes set colorcolumn=80 -set background=light +set background=dark ]]) vim.opt.termguicolors = true +-- some plugins misbehave when we do swap files +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" +vim.opt.undofile = true +vim.opt.completeopt = 'menuone,noselect' + +vim.g.mapleader = ' ' + +-- basic keymaps +vim.keymap.set({'n','v'}, '', '', {silent=true}) -- since we're using space for leader + +-- diagnostics (errors/warnings to be shown) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next) +vim.keymap.set('n', 'e', vim.diagnostic.open_float) -- opens diag in box (floating) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist) + -- vim-plug vim.cmd([[ @@ -25,10 +43,105 @@ endif local Plug = vim.fn['plug#'] vim.call('plug#begin', '~/.config/nvim/plugged') +-- libs and dependencies Plug('nvim-lua/plenary.nvim') -Plug('nvim-telescope/telescope.nvim', {tag = '0.1.0'}) + +-- plugins +Plug('nvim-treesitter/nvim-treesitter') -- language parser engine +Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects +Plug('nvim-telescope/telescope.nvim', {tag = '0.1.0'}) -- fuzzy search thru files +-- cmp: auto-complete/suggestions +Plug('neovim/nvim-lspconfig') -- built-in LSP configurations +Plug('hrsh7th/cmp-nvim-lsp') +Plug('hrsh7th/cmp-buffer') +Plug('hrsh7th/nvim-cmp') +Plug('onsails/lspkind-nvim') +-- DevExp +Plug('numToStr/Comment.nvim') -- "gc" to comment visual regions/lines +Plug('lewis6991/gitsigns.nvim') -- add git info to sign columns +Plug('tpope/vim-fugitive') -- git commands in nvim + +-- UI & colorscheme Plug('gruvbox-community/gruvbox') +Plug('nvim-lualine/lualine.nvim') -- fancy status line +Plug('lukas-reineke/indent-blankline.nvim') -- identation lines on blank lines + +-- other +Plug('nvim-treesitter/nvim-treesitter', {run = ':TSUpdate'}) + +--------- vim.call('plug#end') +-- color, highlighting, UI stuffs vim.cmd.colorscheme('gruvbox') +-- plugin keymaps +function remap(mode, key_cmd, binded_fn, opts) + opts = opts or {remap = true} + return vim.keymap.set(mode, key_cmd, binded_fn, opts) +end +-- Comment.nvim +require('Comment').setup() +-- lukas-reineke/indent-blankline.nvim +require('indent_blankline').setup { + char = '┊', + show_trailing_blankline_indent = false, +} +-- telescope +require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + } + } + } +} +pcall(require('telescope').load_extension, 'fzf') +remap('n', '','Telescope', {desc = 'Open Telescope general search'}) +remap('n', 'ff',function() + require('telescope.builtin').find_files() +end, {desc = '[F]ind [F]iles'}) +remap('n', 'fg',function() + require('telescope.builtin').live_grep() +end, {desc = '[F]ind by [G]rep'}) +remap('n', 'fb',function() + require('telescope.builtin').buffers() +end, {desc = '[F]ind existing [B]uffers'}) +remap('n', 'fh',function() + require('telescope.builtin').help_tags() +end, {desc = '[F]ind [H]elp'}) +remap('n', 'fd',function() + require('telescope.builtin').live_grep() +end, {desc = '[F]ind [D]iagnostics'}) +-- treesitter +require('nvim-treesitter.configs').setup { + ensure_installed = {'lua', 'typescript', 'rust', 'go', 'python'}, + highlight = {enable = true}, + indent = {enable = true}, + incremental_selection = { + enable = true, + keymap = { + init_selection = '', + node_incremental = '', + node_decremental = '' + } + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + }, + +} + + + From a097dab16777ec26a927a813831eb857c8c999d4 Mon Sep 17 00:00:00 2001 From: pegasust Date: Mon, 15 Aug 2022 02:05:14 -0700 Subject: [PATCH 05/32] more plugins and their mappings --- neovim/init.lua | 198 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 175 insertions(+), 23 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index ab2d4b4..4f639b1 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -19,17 +19,17 @@ vim.opt.backup = false vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" vim.opt.undofile = true vim.opt.completeopt = 'menuone,noselect' - vim.g.mapleader = ' ' -- basic keymaps -vim.keymap.set({'n','v'}, '', '', {silent=true}) -- since we're using space for leader +vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) -- since we're using space for leader +vim.keymap.set('t', '', ')') -- make :terminal escape out -- diagnostics (errors/warnings to be shown) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) vim.keymap.set('n', ']d', vim.diagnostic.goto_next) vim.keymap.set('n', 'e', vim.diagnostic.open_float) -- opens diag in box (floating) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist) -- opens list of diags -- vim-plug @@ -46,10 +46,10 @@ vim.call('plug#begin', '~/.config/nvim/plugged') -- libs and dependencies Plug('nvim-lua/plenary.nvim') --- plugins +-- plugins Plug('nvim-treesitter/nvim-treesitter') -- language parser engine Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects -Plug('nvim-telescope/telescope.nvim', {tag = '0.1.0'}) -- fuzzy search thru files +Plug('nvim-telescope/telescope.nvim', { tag = '0.1.0' }) -- file browser -- cmp: auto-complete/suggestions Plug('neovim/nvim-lspconfig') -- built-in LSP configurations Plug('hrsh7th/cmp-nvim-lsp') @@ -57,9 +57,11 @@ Plug('hrsh7th/cmp-buffer') Plug('hrsh7th/nvim-cmp') Plug('onsails/lspkind-nvim') -- DevExp -Plug('numToStr/Comment.nvim') -- "gc" to comment visual regions/lines +Plug('numToStr/Comment.nvim') -- "gc" to comment visual regions/lines Plug('lewis6991/gitsigns.nvim') -- add git info to sign columns Plug('tpope/vim-fugitive') -- git commands in nvim +Plug('williamboman/mason.nvim') -- LSP, debuggers,... package manager +Plug('williamboman/mason-lspconfig.nvim') -- lsp config for mason -- UI & colorscheme Plug('gruvbox-community/gruvbox') @@ -67,7 +69,9 @@ Plug('nvim-lualine/lualine.nvim') -- fancy status line Plug('lukas-reineke/indent-blankline.nvim') -- identation lines on blank lines -- other -Plug('nvim-treesitter/nvim-treesitter', {run = ':TSUpdate'}) +Plug('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }) +Plug('saadparwaiz1/cmp_luasnip') -- snippet engine +Plug('L3MON4D3/LuaSnip') -- snippet engine --------- vim.call('plug#end') @@ -76,10 +80,11 @@ vim.call('plug#end') vim.cmd.colorscheme('gruvbox') -- plugin keymaps -function remap(mode, key_cmd, binded_fn, opts) - opts = opts or {remap = true} +local function remap(mode, key_cmd, binded_fn, opts) + opts = opts or { remap = true } return vim.keymap.set(mode, key_cmd, binded_fn, opts) end + -- Comment.nvim require('Comment').setup() -- lukas-reineke/indent-blankline.nvim @@ -99,27 +104,27 @@ require('telescope').setup { } } pcall(require('telescope').load_extension, 'fzf') -remap('n', '','Telescope', {desc = 'Open Telescope general search'}) -remap('n', 'ff',function() +remap('n', '', 'Telescope', { desc = 'Open Telescope general search' }) +remap('n', 'ff', function() require('telescope.builtin').find_files() -end, {desc = '[F]ind [F]iles'}) -remap('n', 'fg',function() +end, { desc = '[F]ind [F]iles' }) +remap('n', 'fg', function() require('telescope.builtin').live_grep() -end, {desc = '[F]ind by [G]rep'}) -remap('n', 'fb',function() +end, { desc = '[F]ind by [G]rep' }) +remap('n', 'fb', function() require('telescope.builtin').buffers() -end, {desc = '[F]ind existing [B]uffers'}) -remap('n', 'fh',function() +end, { desc = '[F]ind existing [B]uffers' }) +remap('n', 'fh', function() require('telescope.builtin').help_tags() -end, {desc = '[F]ind [H]elp'}) -remap('n', 'fd',function() +end, { desc = '[F]ind [H]elp' }) +remap('n', 'fd', function() require('telescope.builtin').live_grep() -end, {desc = '[F]ind [D]iagnostics'}) +end, { desc = '[F]ind [D]iagnostics' }) -- treesitter require('nvim-treesitter.configs').setup { - ensure_installed = {'lua', 'typescript', 'rust', 'go', 'python'}, - highlight = {enable = true}, - indent = {enable = true}, + ensure_installed = { 'lua', 'typescript', 'rust', 'go', 'python' }, + highlight = { enable = true }, + indent = { enable = true }, incremental_selection = { enable = true, keymap = { @@ -143,5 +148,152 @@ require('nvim-treesitter.configs').setup { } +-- LSP settings +-- This function gets run when an LSP connects to a particular buffer. +local on_attach = function(_, bufnr) + -- NOTE: Remember that lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself + -- many times. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + end + + nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + + -- symbols and gotos + nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation') + nmap('gr', require('telescope.builtin').lsp_references) + nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + -- documentations. See `:help K` for why this keymap + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') + nmap('ja', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, '[W]orkspace [L]ist Folders') + + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, 'Format', vim.lsp.buf.format or vim.lsp.buf.formatting, + { desc = 'Format current buffer with LSP' }) +end +-- nvim-cmp supports additional completion capabilities +local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) +-- default language servers +local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua' } +require("mason").setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + } + } +}) +require('mason-lspconfig').setup({ + ensure_installed = servers, + -- automatic_installation = true +}) +for _, lsp in ipairs(servers) do + require('lspconfig')[lsp].setup { + on_attach = on_attach, + capabilities = capabilities, + } +end +-- config overwrites +require('lspconfig').sumneko_lua.setup { + on_attach = on_attach, + capabilities = capabilities, + settings = { + Lua = { + runtime = { + version = "LuaJIT", + path = vim.split(package.path, ";"), + }, + diagnostics = { + globals = {"vim"} + }, + workspace = { + library = vim.api.nvim_get_runtime_file('', true) + }, + telemetry = {enable = false} + } + } +} +-- nvim-cmp +local cmp = require 'cmp' +local luasnip = require 'luasnip' + +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, +} + +-- Gitsigns +require('gitsigns').setup { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + } +} +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'onedark', + component_separators = '|', + section_separators = '', + }, +} From e65b2f308f5c5203dddb013953668c6f73247716 Mon Sep 17 00:00:00 2001 From: pegasust Date: Mon, 15 Aug 2022 18:59:31 -0700 Subject: [PATCH 06/32] migrate to mason-lspconfig --- neovim/init.lua | 109 ++++++++++++++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 40 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index 4f639b1..6b4507a 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -1,3 +1,11 @@ +-- What: Mono-file nvim configuration file +-- Why: Easy to see through everything without needing to navigate thru files +-- Features: +-- - LSP +-- - Auto-complete (in insert mode: ctrl-space, navigate w/ Tab+S-Tab, confirm: Enter) +-- - cmd: ":Format" to format +-- - + -- Basic settings of vim vim.cmd([[ set number relativenumber @@ -13,13 +21,19 @@ set colorcolumn=80 set background=dark ]]) vim.opt.termguicolors = true +vim.opt.cursorline = true -- some plugins misbehave when we do swap files vim.opt.swapfile = false vim.opt.backup = false vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" vim.opt.undofile = true vim.opt.completeopt = 'menuone,noselect' +vim.opt.clipboard = "unnamedplus" +vim.opt.lazyredraw = true + + vim.g.mapleader = ' ' +vim.g.gruvbox_termcolors=16 -- basic keymaps vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) -- since we're using space for leader @@ -47,9 +61,10 @@ vim.call('plug#begin', '~/.config/nvim/plugged') Plug('nvim-lua/plenary.nvim') -- plugins -Plug('nvim-treesitter/nvim-treesitter') -- language parser engine +Plug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighting Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects Plug('nvim-telescope/telescope.nvim', { tag = '0.1.0' }) -- file browser +Plug('nvim-telescope/telescope-fzf-native.nvim', {['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build'}) -- cmp: auto-complete/suggestions Plug('neovim/nvim-lspconfig') -- built-in LSP configurations Plug('hrsh7th/cmp-nvim-lsp') @@ -88,9 +103,13 @@ end -- Comment.nvim require('Comment').setup() -- lukas-reineke/indent-blankline.nvim -require('indent_blankline').setup { - char = '┊', - show_trailing_blankline_indent = false, +vim.opt.list = true +vim.opt.listchars:append "space:⋅" +vim.opt.listchars:append "eol:↴" + +require("indent_blankline").setup { + show_end_of_line = true, + space_char_blankline = " ", } -- telescope require('telescope').setup { @@ -99,7 +118,15 @@ require('telescope').setup { i = { [''] = false, [''] = false, - } + }, + }, + }, + extensions = { + fzf = { + fuzzy = true, -- allow fuzzy matches + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case' } } } @@ -118,19 +145,20 @@ remap('n', 'fh', function() require('telescope.builtin').help_tags() end, { desc = '[F]ind [H]elp' }) remap('n', 'fd', function() - require('telescope.builtin').live_grep() + require('telescope.builtin').diagnostics() end, { desc = '[F]ind [D]iagnostics' }) -- treesitter require('nvim-treesitter.configs').setup { - ensure_installed = { 'lua', 'typescript', 'rust', 'go', 'python' }, + ensure_installed = { 'lua', 'typescript', 'rust', 'go', 'python', 'prisma' }, highlight = { enable = true }, indent = { enable = true }, incremental_selection = { enable = true, - keymap = { + keymaps = { init_selection = '', node_incremental = '', - node_decremental = '' + node_decremental = '', + scope_incremental = '' } }, textobjects = { @@ -195,7 +223,7 @@ end -- nvim-cmp supports additional completion capabilities local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) -- default language servers -local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua' } +local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', "prisma-language-server" } require("mason").setup({ ui = { icons = { @@ -207,34 +235,39 @@ require("mason").setup({ }) require('mason-lspconfig').setup({ ensure_installed = servers, - -- automatic_installation = true + automatic_installation = true }) -for _, lsp in ipairs(servers) do - require('lspconfig')[lsp].setup { - on_attach = on_attach, - capabilities = capabilities, - } -end --- config overwrites -require('lspconfig').sumneko_lua.setup { - on_attach = on_attach, - capabilities = capabilities, - settings = { - Lua = { - runtime = { - version = "LuaJIT", - path = vim.split(package.path, ";"), - }, - diagnostics = { - globals = {"vim"} - }, - workspace = { - library = vim.api.nvim_get_runtime_file('', true) - }, - telemetry = {enable = false} +require('mason-lspconfig').setup_handlers({ + -- default handler + function(server_name) + require('lspconfig')[server_name].setup { + on_attach = on_attach, + capabilities = capabilities, } - } -} + end, + ["sumneko_lua"] = function() + require('lspconfig').sumneko_lua.setup { + on_attach = on_attach, + capabilities = capabilities, + settings = { + Lua = { + runtime = { + version = "LuaJIT", + path = vim.split(package.path, ";"), + }, + diagnostics = { + globals = { "vim" } + }, + workspace = { + library = vim.api.nvim_get_runtime_file('', true) + }, + telemetry = { enable = false } + } + } + } + end +}) + -- nvim-cmp local cmp = require 'cmp' local luasnip = require 'luasnip' @@ -291,9 +324,5 @@ require('gitsigns').setup { require('lualine').setup { options = { icons_enabled = true, - theme = 'onedark', - component_separators = '|', - section_separators = '', }, } - From 03f3094a4374aed739b816f88f1a75535fb787a4 Mon Sep 17 00:00:00 2001 From: pegasust Date: Mon, 15 Aug 2022 19:51:52 -0700 Subject: [PATCH 07/32] before investigate weird redraw --- neovim/init.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index 6b4507a..f2431c4 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -31,9 +31,7 @@ vim.opt.completeopt = 'menuone,noselect' vim.opt.clipboard = "unnamedplus" vim.opt.lazyredraw = true - vim.g.mapleader = ' ' -vim.g.gruvbox_termcolors=16 -- basic keymaps vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) -- since we're using space for leader From 97303b8a69f8a83661433d6b7fe5c7fe288f06fc Mon Sep 17 00:00:00 2001 From: pegasust Date: Mon, 15 Aug 2022 20:21:45 -0700 Subject: [PATCH 08/32] looks like it's win-term/wsl problem since it may have skipped couple frames --- neovim/init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/neovim/init.lua b/neovim/init.lua index f2431c4..2ae5129 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -1,3 +1,4 @@ +local function_component = require "function_component" -- What: Mono-file nvim configuration file -- Why: Easy to see through everything without needing to navigate thru files -- Features: @@ -29,7 +30,6 @@ vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" vim.opt.undofile = true vim.opt.completeopt = 'menuone,noselect' vim.opt.clipboard = "unnamedplus" -vim.opt.lazyredraw = true vim.g.mapleader = ' ' @@ -171,6 +171,10 @@ require('nvim-treesitter.configs').setup { }, }, }, + text = function () + + end(), + CanWinBeReordered, } From c5475444d52b2022854fa9dfd104254cc28b5b9e Mon Sep 17 00:00:00 2001 From: pegasust Date: Mon, 15 Aug 2022 21:59:49 -0700 Subject: [PATCH 09/32] Add tmux configuration --- neovim/init.lua | 13 +++++-------- tmux/.tmux.conf | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 tmux/.tmux.conf diff --git a/neovim/init.lua b/neovim/init.lua index 2ae5129..59bff20 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -1,11 +1,10 @@ -local function_component = require "function_component" -- What: Mono-file nvim configuration file -- Why: Easy to see through everything without needing to navigate thru files -- Features: -- - LSP -- - Auto-complete (in insert mode: ctrl-space, navigate w/ Tab+S-Tab, confirm: Enter) -- - cmd: ":Format" to format --- - +-- - Harpoon marks: Navigate through main files within each project -- Basic settings of vim vim.cmd([[ @@ -19,8 +18,9 @@ set incsearch set scrolloff=15 set signcolumn=yes set colorcolumn=80 -set background=dark +set background=light ]]) +vim.opt.lazyredraw = true vim.opt.termguicolors = true vim.opt.cursorline = true -- some plugins misbehave when we do swap files @@ -36,6 +36,7 @@ vim.g.mapleader = ' ' -- basic keymaps vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) -- since we're using space for leader vim.keymap.set('t', '', ')') -- make :terminal escape out +vim.keymap.set({'n','i','v'}, '', ':mode') -- redraw on every mode -- diagnostics (errors/warnings to be shown) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) @@ -75,6 +76,7 @@ Plug('lewis6991/gitsigns.nvim') -- add git info to sign columns Plug('tpope/vim-fugitive') -- git commands in nvim Plug('williamboman/mason.nvim') -- LSP, debuggers,... package manager Plug('williamboman/mason-lspconfig.nvim') -- lsp config for mason +Plug('ThePrimeagen/harpoon') -- 1-click through marked files per project -- UI & colorscheme Plug('gruvbox-community/gruvbox') @@ -171,11 +173,6 @@ require('nvim-treesitter.configs').setup { }, }, }, - text = function () - - end(), - CanWinBeReordered, - } -- LSP settings diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf new file mode 100644 index 0000000..5f2db16 --- /dev/null +++ b/tmux/.tmux.conf @@ -0,0 +1,14 @@ +# Configuration for tmux +set -g default-terminal "screen-256color" # more colors +set -ga terminal-overrides ",xterm-256color*:Tc" # more colors +set -s escape-time 0 + +bind r source-file ~/.tmux.conf \; display "tmux.conf reloaded at ~/.tmux.conf" +set -g base-index 1 # rebind to start from 0 +setw -g pane-base-index 1 +set-option -g renumber-windows on + +# status bar +set -g status-style 'bg=#333333 fg=#5eacd3' + + From 6d79654021aedd3835008819c3e7849cf6a4cc43 Mon Sep 17 00:00:00 2001 From: pegasust Date: Mon, 22 Aug 2022 02:17:11 -0700 Subject: [PATCH 10/32] Add harpoon; telescope: ' fa': search all, ' ff': search respect hidden and ignore --- neovim/init.lua | 71 +++++++++++++++++++++++++++++++++++++++++++------ tmux/.tmux.conf | 6 ++++- 2 files changed, 68 insertions(+), 9 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index 59bff20..b691238 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -4,7 +4,7 @@ -- - LSP -- - Auto-complete (in insert mode: ctrl-space, navigate w/ Tab+S-Tab, confirm: Enter) -- - cmd: ":Format" to format --- - Harpoon marks: Navigate through main files within each project +-- - Harpoon marks: Navigate through main files within each project -- Basic settings of vim vim.cmd([[ @@ -36,7 +36,7 @@ vim.g.mapleader = ' ' -- basic keymaps vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) -- since we're using space for leader vim.keymap.set('t', '', ')') -- make :terminal escape out -vim.keymap.set({'n','i','v'}, '', ':mode') -- redraw on every mode +vim.keymap.set({ 'n', 'i', 'v' }, '', ':mode') -- redraw on every mode -- diagnostics (errors/warnings to be shown) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) @@ -63,7 +63,9 @@ Plug('nvim-lua/plenary.nvim') Plug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighting Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects Plug('nvim-telescope/telescope.nvim', { tag = '0.1.0' }) -- file browser -Plug('nvim-telescope/telescope-fzf-native.nvim', {['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build'}) +Plug('nvim-telescope/telescope-fzf-native.nvim', + { ['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build' }) +Plug('nvim-telescope/telescope-file-browser.nvim') -- cmp: auto-complete/suggestions Plug('neovim/nvim-lspconfig') -- built-in LSP configurations Plug('hrsh7th/cmp-nvim-lsp') @@ -108,10 +110,11 @@ vim.opt.listchars:append "space:⋅" vim.opt.listchars:append "eol:↴" require("indent_blankline").setup { - show_end_of_line = true, - space_char_blankline = " ", + show_end_of_line = true, + space_char_blankline = " ", } -- telescope +local fb_actions = require "telescope".extensions.file_browser.actions require('telescope').setup { defaults = { mappings = { @@ -123,30 +126,75 @@ require('telescope').setup { }, extensions = { fzf = { - fuzzy = true, -- allow fuzzy matches + fuzzy = true, -- allow fuzzy matches override_generic_sorter = true, override_file_sorter = true, case_mode = 'smart_case' + }, + file_browser = { + theme = "ivy", + hiject_netrw = true, -- disables netrw and use file-browser instead + mappings = { + ["i"] = {}, -- disable any shortcut in insert mode for now + ["n"] = { + ["c"] = fb_actions.create, + ["r"] = fb_actions.rename, + ["m"] = fb_actions.move, + ["y"] = fb_actions.copy, + ["d"] = fb_actions.remove, + ["o"] = fb_actions.open, + ["g"] = fb_actions.goto_parent_dir, + ["e"] = fb_actions.goto_home_dir, + ["w"] = fb_actions.goto_cwd, + ["t"] = fb_actions.change_cwd, + ["f"] = fb_actions.toggle_browser, + ["h"] = fb_actions.toggle_hidden, + ["s"] = fb_actions.toggle_all, + } + } } } } pcall(require('telescope').load_extension, 'fzf') +pcall(require('telescope').load_extension, 'file_browser') remap('n', '', 'Telescope', { desc = 'Open Telescope general search' }) + +remap('n', 'fm', function() + require("telescope").extensions.file_browser.file_browser() +end, { desc = '[F]ile [M]utation' }) + remap('n', 'ff', function() - require('telescope.builtin').find_files() -end, { desc = '[F]ind [F]iles' }) + require('telescope.builtin').find_files({ + hidden = false, + no_ignore = false, + follow = false, + }) +end, { desc = '[F]ind [F]ile' }) + +remap('n', 'fa', function() + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = true, + follow = true, + }) +end, { desc = '[F]ind [A]ll files' }) + remap('n', 'fg', function() require('telescope.builtin').live_grep() end, { desc = '[F]ind by [G]rep' }) + remap('n', 'fb', function() require('telescope.builtin').buffers() end, { desc = '[F]ind existing [B]uffers' }) + remap('n', 'fh', function() require('telescope.builtin').help_tags() end, { desc = '[F]ind [H]elp' }) + remap('n', 'fd', function() require('telescope.builtin').diagnostics() end, { desc = '[F]ind [D]iagnostics' }) + -- treesitter require('nvim-treesitter.configs').setup { ensure_installed = { 'lua', 'typescript', 'rust', 'go', 'python', 'prisma' }, @@ -174,6 +222,13 @@ require('nvim-treesitter.configs').setup { }, }, } +-- harpoon: mark significant files & switch between them +remap('n', 'm', function() require('harpoon.mark').add_file() end) +remap('n', 'hf', function() require('harpoon.ui').nav_file(1) end) +remap('n', 'hj', function() require('harpoon.ui').nav_file(2) end) +remap('n', 'hd', function() require('harpoon.ui').nav_file(3) end) +remap('n', 'hk', function() require('harpoon.ui').nav_file(4) end) +remap('n', 'hh', function() require('harpoon.ui').toggle_quick_menu() end) -- LSP settings -- This function gets run when an LSP connects to a particular buffer. diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf index 5f2db16..c324075 100644 --- a/tmux/.tmux.conf +++ b/tmux/.tmux.conf @@ -2,6 +2,11 @@ set -g default-terminal "screen-256color" # more colors set -ga terminal-overrides ",xterm-256color*:Tc" # more colors set -s escape-time 0 +set -g display-time 1500 + +# rebind C-b to C-a; easier to type on qwerty +unbind C-b +set -g prefix C-a bind r source-file ~/.tmux.conf \; display "tmux.conf reloaded at ~/.tmux.conf" set -g base-index 1 # rebind to start from 0 @@ -11,4 +16,3 @@ set-option -g renumber-windows on # status bar set -g status-style 'bg=#333333 fg=#5eacd3' - From 71d59ea39fe9f40913af99f3577024ff82ac89cb Mon Sep 17 00:00:00 2001 From: pegasust Date: Sat, 27 Aug 2022 05:34:55 -0700 Subject: [PATCH 11/32] add zk note taking & harpoon number bindings --- neovim/init.lua | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index b691238..56bba35 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -29,7 +29,7 @@ vim.opt.backup = false vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" vim.opt.undofile = true vim.opt.completeopt = 'menuone,noselect' -vim.opt.clipboard = "unnamedplus" +-- vim.opt.clipboard = "unnamedplus" vim.g.mapleader = ' ' @@ -89,12 +89,13 @@ Plug('lukas-reineke/indent-blankline.nvim') -- identation lines on blank lines Plug('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }) Plug('saadparwaiz1/cmp_luasnip') -- snippet engine Plug('L3MON4D3/LuaSnip') -- snippet engine +Plug('mickael-menu/zk-nvim') -- Zettelkasten --------- vim.call('plug#end') -- color, highlighting, UI stuffs -vim.cmd.colorscheme('gruvbox') +vim.cmd([[ colorscheme gruvbox ]]) -- plugin keymaps local function remap(mode, key_cmd, binded_fn, opts) @@ -155,6 +156,10 @@ require('telescope').setup { } } } + +require('zk').setup({ +}) + pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'file_browser') remap('n', '', 'Telescope', { desc = 'Open Telescope general search' }) @@ -224,11 +229,30 @@ require('nvim-treesitter.configs').setup { } -- harpoon: mark significant files & switch between them remap('n', 'm', function() require('harpoon.mark').add_file() end) -remap('n', 'hf', function() require('harpoon.ui').nav_file(1) end) -remap('n', 'hj', function() require('harpoon.ui').nav_file(2) end) -remap('n', 'hd', function() require('harpoon.ui').nav_file(3) end) -remap('n', 'hk', function() require('harpoon.ui').nav_file(4) end) +local function harpoon_nav(key, nav_file_index, lead_keybind) + lead_keybind = lead_keybind or 'h' + assert(type(key) == "string", "expect key to be string(keybind)") + assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index") + return remap('n', lead_keybind .. key, function() require('harpoon.ui').nav_file(nav_file_index) end) +end +-- remap letters to index. Inspired by alternating number of Dvorak programmer +-- best practices: try to keep marked files to be around 4 +harpoon_nav('f', 1) +harpoon_nav('j', 2) +harpoon_nav('d', 3) +harpoon_nav('k', 4) remap('n', 'hh', function() require('harpoon.ui').toggle_quick_menu() end) +-- harpoon: navigate by numbers +harpoon_nav('1',1) +harpoon_nav('2',2) +harpoon_nav('3',3) +harpoon_nav('4',4) +harpoon_nav('5',5) +harpoon_nav('6',6) +harpoon_nav('7',7) +harpoon_nav('8',8) +harpoon_nav('9',9) +harpoon_nav('0',10) -- LSP settings -- This function gets run when an LSP connects to a particular buffer. From 6aba37e473eda92414aab17bc786d1d79528c854 Mon Sep 17 00:00:00 2001 From: pegasust Date: Mon, 29 Aug 2022 05:36:44 -0700 Subject: [PATCH 12/32] add zk & update README --- README.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ neovim/init.lua | 11 +++++++++++ zk/config.toml | 23 ++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 zk/config.toml diff --git a/README.md b/README.md index 96bf7ed..7d65ad3 100644 --- a/README.md +++ b/README.md @@ -1 +1,53 @@ # dotfiles + +Contains my configurations for the software I use. + +I'm looking to move forward to configuration with NixOS, but until I get +a bit more experiment on NixOS, I'll keep this repository as simple as possible. + +## How do I apply these config + +- I will always first clone this repository, preferably from local source before +going from the github. `git clone https://github.com/pegasust/dotfiles` + +### neovim + +My main text editor. It's based on `vim`, but stays loyal to `lua` ecosystem + +- Config file: `./nvim/init.lua` +- Command: `ln [-s] $PWD/nvim/init.lua ~/.config/nvim` + +#### Notes + +- Ensure that neovim is installed and invocable by `nvim`. +- My config based on rather experimental version of`nvim` (>=0.7.2) +- For information on installing neovim, visit their [github page](https://github.com/neovim/neovim/wiki/Installing-Neovim) + +### tmux + +Terminal multiplexor. Allows creating persistent sessions and multiple terminal windows +from one terminal. + +- Config file: `./tmux/.tmux.conf` +- Command: `ln [-s] $PWD/tmux/.tmux.conf ~/.tmux.conf` + +#### Notes + +- Unsure if the minimum version of tmux. I have had an ancient HPC server +that does not respond well to one of the config lines. + +### zk + +Zettelkasten notebook. This is how I document my learning and reflect on myself +via writing and typing. + +I am in the process of moving away from Obsidian so that I can write ZK notes +text-editor agnostically. + +- Config file: `zk/config.toml` +- Command: `ln [-s] $PWD/zk/config.toml ~/.config/zk/config.toml` + +- Templates: `zk/templates/` +- Command: `ln -s $PWD/zk/templates ~/.config/zk/templates` + + diff --git a/neovim/init.lua b/neovim/init.lua index 56bba35..df1c02b 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -158,6 +158,17 @@ require('telescope').setup { } require('zk').setup({ + picker = "telescope", + lsp = { + config = { + cmd = {"zk", "lsp"}, + name = "zk", + }, + auto_attach = { + enable = true, + filetypes = {"markdown"} + }, + }, }) pcall(require('telescope').load_extension, 'fzf') diff --git a/zk/config.toml b/zk/config.toml new file mode 100644 index 0000000..6817b68 --- /dev/null +++ b/zk/config.toml @@ -0,0 +1,23 @@ +[note] # Settings that reflect the creation of a new note +language = "en" +default-title = "Untitled" +filename = "{{date now 'timestamp'}}" # Loyal to my current style: 202208201345 +extension = "md" # might switch to mdx + +[extra] +author = "Hung Tran" + +[format.markdown] +hashtags = true +multiword-tags = true +link-format = "wiki" +link-drop-extension = true + +[tool] +editor = "nvim" + +[lsp] +[lsp.diagnostics] +wiki-title = "hint" +dead-link = "error" + From e88df8f9683879de1a0d0974153ccf166e43fe63 Mon Sep 17 00:00:00 2001 From: pegasust Date: Mon, 29 Aug 2022 13:16:53 -0700 Subject: [PATCH 13/32] add zk and harpoon bindings --- neovim/init.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/neovim/init.lua b/neovim/init.lua index 56bba35..c59da19 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -158,6 +158,18 @@ require('telescope').setup { } require('zk').setup({ + picker = "telescope", + lsp = { + config = { + cmd = {"zk", "lsp"}, + name = "zk", + }, + auto_attach = { + enabled = true, + filetypes = {"markdown"}, + + }, + } }) pcall(require('telescope').load_extension, 'fzf') From e7f3facc2c857e04772cbe8c91a495f0d540ceb9 Mon Sep 17 00:00:00 2001 From: pegasust Date: Tue, 30 Aug 2022 22:41:56 -0700 Subject: [PATCH 14/32] update init.lua --- neovim/init.lua | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index c59da19..e23c758 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -43,6 +43,7 @@ vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) vim.keymap.set('n', ']d', vim.diagnostic.goto_next) vim.keymap.set('n', 'e', vim.diagnostic.open_float) -- opens diag in box (floating) vim.keymap.set('n', 'q', vim.diagnostic.setloclist) -- opens list of diags +vim.keymap.set('n', 'wq', vim.diagnostic.setqflist) -- workspace diags -- vim-plug @@ -157,21 +158,6 @@ require('telescope').setup { } } -require('zk').setup({ - picker = "telescope", - lsp = { - config = { - cmd = {"zk", "lsp"}, - name = "zk", - }, - auto_attach = { - enabled = true, - filetypes = {"markdown"}, - - }, - } -}) - pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'file_browser') remap('n', '', 'Telescope', { desc = 'Open Telescope general search' }) @@ -357,6 +343,20 @@ require('mason-lspconfig').setup_handlers({ } end }) +require('zk').setup({ + picker = "telescope", + lsp = { + config = { + cmd = {"zk", "lsp"}, + name = "zk", + on_attach = on_attach, + }, + auto_attach = { + enable = true, + filetypes = {"markdown"} + }, + }, +}) -- nvim-cmp local cmp = require 'cmp' @@ -416,3 +416,4 @@ require('lualine').setup { icons_enabled = true, }, } + From fbbc1dea983c3f8477e6e758f27b2a3f68d4affd Mon Sep 17 00:00:00 2001 From: pegasust Date: Wed, 31 Aug 2022 07:39:47 -0700 Subject: [PATCH 15/32] + :ZkOrphans :ZkGrep bracket & html matching --- neovim/init.lua | 432 ++++++++++++++++++++++++++---------------------- 1 file changed, 235 insertions(+), 197 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index e23c758..71ba3cd 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -65,7 +65,7 @@ Plug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighti Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects Plug('nvim-telescope/telescope.nvim', { tag = '0.1.0' }) -- file browser Plug('nvim-telescope/telescope-fzf-native.nvim', - { ['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build' }) + { ['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build' }) Plug('nvim-telescope/telescope-file-browser.nvim') -- cmp: auto-complete/suggestions Plug('neovim/nvim-lspconfig') -- built-in LSP configurations @@ -74,6 +74,8 @@ Plug('hrsh7th/cmp-buffer') Plug('hrsh7th/nvim-cmp') Plug('onsails/lspkind-nvim') -- DevExp +Plug('windwp/nvim-autopairs') -- matches pairs like [] (),... +Plug('windwp/nvim-ts-autotag') -- matches tags hello Plug('numToStr/Comment.nvim') -- "gc" to comment visual regions/lines Plug('lewis6991/gitsigns.nvim') -- add git info to sign columns Plug('tpope/vim-fugitive') -- git commands in nvim @@ -100,8 +102,8 @@ vim.cmd([[ colorscheme gruvbox ]]) -- plugin keymaps local function remap(mode, key_cmd, binded_fn, opts) - opts = opts or { remap = true } - return vim.keymap.set(mode, key_cmd, binded_fn, opts) + opts = opts or { remap = true } + return vim.keymap.set(mode, key_cmd, binded_fn, opts) end -- Comment.nvim @@ -112,50 +114,50 @@ vim.opt.listchars:append "space:⋅" vim.opt.listchars:append "eol:↴" require("indent_blankline").setup { - show_end_of_line = true, - space_char_blankline = " ", + show_end_of_line = true, + space_char_blankline = " ", } -- telescope local fb_actions = require "telescope".extensions.file_browser.actions require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, }, - }, - extensions = { - fzf = { - fuzzy = true, -- allow fuzzy matches - override_generic_sorter = true, - override_file_sorter = true, - case_mode = 'smart_case' - }, - file_browser = { - theme = "ivy", - hiject_netrw = true, -- disables netrw and use file-browser instead - mappings = { - ["i"] = {}, -- disable any shortcut in insert mode for now - ["n"] = { - ["c"] = fb_actions.create, - ["r"] = fb_actions.rename, - ["m"] = fb_actions.move, - ["y"] = fb_actions.copy, - ["d"] = fb_actions.remove, - ["o"] = fb_actions.open, - ["g"] = fb_actions.goto_parent_dir, - ["e"] = fb_actions.goto_home_dir, - ["w"] = fb_actions.goto_cwd, - ["t"] = fb_actions.change_cwd, - ["f"] = fb_actions.toggle_browser, - ["h"] = fb_actions.toggle_hidden, - ["s"] = fb_actions.toggle_all, + extensions = { + fzf = { + fuzzy = true, -- allow fuzzy matches + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case' + }, + file_browser = { + theme = "ivy", + hiject_netrw = true, -- disables netrw and use file-browser instead + mappings = { + ["i"] = {}, -- disable any shortcut in insert mode for now + ["n"] = { + ["c"] = fb_actions.create, + ["r"] = fb_actions.rename, + ["m"] = fb_actions.move, + ["y"] = fb_actions.copy, + ["d"] = fb_actions.remove, + ["o"] = fb_actions.open, + ["g"] = fb_actions.goto_parent_dir, + ["e"] = fb_actions.goto_home_dir, + ["w"] = fb_actions.goto_cwd, + ["t"] = fb_actions.change_cwd, + ["f"] = fb_actions.toggle_browser, + ["h"] = fb_actions.toggle_hidden, + ["s"] = fb_actions.toggle_all, + } + } } - } } - } } pcall(require('telescope').load_extension, 'fzf') @@ -163,11 +165,11 @@ pcall(require('telescope').load_extension, 'file_browser') remap('n', '', 'Telescope', { desc = 'Open Telescope general search' }) remap('n', 'fm', function() - require("telescope").extensions.file_browser.file_browser() + require("telescope").extensions.file_browser.file_browser() end, { desc = '[F]ile [M]utation' }) remap('n', 'ff', function() - require('telescope.builtin').find_files({ + require('telescope.builtin').find_files({ hidden = false, no_ignore = false, follow = false, @@ -180,51 +182,61 @@ remap('n', 'fa', function() no_ignore = true, follow = true, }) -end, { desc = '[F]ind [A]ll files' }) +end, { desc = '[F]ind [A]ll files' }) remap('n', 'fg', function() - require('telescope.builtin').live_grep() + require('telescope.builtin').live_grep() end, { desc = '[F]ind by [G]rep' }) remap('n', 'fb', function() - require('telescope.builtin').buffers() + require('telescope.builtin').buffers() end, { desc = '[F]ind existing [B]uffers' }) remap('n', 'fh', function() - require('telescope.builtin').help_tags() + require('telescope.builtin').help_tags() end, { desc = '[F]ind [H]elp' }) remap('n', 'fd', function() - require('telescope.builtin').diagnostics() + require('telescope.builtin').diagnostics() end, { desc = '[F]ind [D]iagnostics' }) -- treesitter require('nvim-treesitter.configs').setup { - ensure_installed = { 'lua', 'typescript', 'rust', 'go', 'python', 'prisma' }, - highlight = { enable = true }, - indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - node_decremental = '', - scope_incremental = '' - } - }, - textobjects = { - select = { - enable = true, - lookahead = true, - keymaps = { - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, + ensure_installed = { 'lua', 'typescript', 'rust', 'go', 'python', 'prisma' }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + node_decremental = '', + scope_incremental = '' + } + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + }, + -- automatically close and modify HTML and TSX tags + autotag = { + enable = true, }, - }, } + +require('nvim-autopairs').setup { + check_ts = true, +} + -- harpoon: mark significant files & switch between them remap('n', 'm', function() require('harpoon.mark').add_file() end) local function harpoon_nav(key, nav_file_index, lead_keybind) @@ -233,6 +245,7 @@ local function harpoon_nav(key, nav_file_index, lead_keybind) assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index") return remap('n', lead_keybind .. key, function() require('harpoon.ui').nav_file(nav_file_index) end) end + -- remap letters to index. Inspired by alternating number of Dvorak programmer -- best practices: try to keep marked files to be around 4 harpoon_nav('f', 1) @@ -241,179 +254,204 @@ harpoon_nav('d', 3) harpoon_nav('k', 4) remap('n', 'hh', function() require('harpoon.ui').toggle_quick_menu() end) -- harpoon: navigate by numbers -harpoon_nav('1',1) -harpoon_nav('2',2) -harpoon_nav('3',3) -harpoon_nav('4',4) -harpoon_nav('5',5) -harpoon_nav('6',6) -harpoon_nav('7',7) -harpoon_nav('8',8) -harpoon_nav('9',9) -harpoon_nav('0',10) +harpoon_nav('1', 1) +harpoon_nav('2', 2) +harpoon_nav('3', 3) +harpoon_nav('4', 4) +harpoon_nav('5', 5) +harpoon_nav('6', 6) +harpoon_nav('7', 7) +harpoon_nav('8', 8) +harpoon_nav('9', 9) +harpoon_nav('0', 10) -- LSP settings -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_, bufnr) - -- NOTE: Remember that lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself - -- many times. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local nmap = function(keys, func, desc) - if desc then - desc = 'LSP: ' .. desc + -- NOTE: Remember that lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself + -- many times. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) end - vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) - end + nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + -- symbols and gotos + nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation') + nmap('gr', require('telescope.builtin').lsp_references) + nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - -- symbols and gotos - nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') - nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation') - nmap('gr', require('telescope.builtin').lsp_references) - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + -- documentations. See `:help K` for why this keymap + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') - -- documentations. See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') + nmap('ja', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, '[W]orkspace [L]ist Folders') - -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') - nmap('ja', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, '[W]orkspace [L]ist Folders') - - -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, 'Format', vim.lsp.buf.format or vim.lsp.buf.formatting, - { desc = 'Format current buffer with LSP' }) + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, 'Format', vim.lsp.buf.format or vim.lsp.buf.formatting, + { desc = 'Format current buffer with LSP' }) end -- nvim-cmp supports additional completion capabilities local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) -- default language servers local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', "prisma-language-server" } require("mason").setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + } } - } }) require('mason-lspconfig').setup({ - ensure_installed = servers, - automatic_installation = true + ensure_installed = servers, + automatic_installation = true }) require('mason-lspconfig').setup_handlers({ - -- default handler - function(server_name) - require('lspconfig')[server_name].setup { - on_attach = on_attach, - capabilities = capabilities, - } - end, - ["sumneko_lua"] = function() - require('lspconfig').sumneko_lua.setup { - on_attach = on_attach, - capabilities = capabilities, - settings = { - Lua = { - runtime = { - version = "LuaJIT", - path = vim.split(package.path, ";"), - }, - diagnostics = { - globals = { "vim" } - }, - workspace = { - library = vim.api.nvim_get_runtime_file('', true) - }, - telemetry = { enable = false } + -- default handler + function(server_name) + require('lspconfig')[server_name].setup { + on_attach = on_attach, + capabilities = capabilities, } - } - } - end + end, + ["sumneko_lua"] = function() + require('lspconfig').sumneko_lua.setup { + on_attach = on_attach, + capabilities = capabilities, + settings = { + Lua = { + runtime = { + version = "LuaJIT", + path = vim.split(package.path, ";"), + }, + diagnostics = { + globals = { "vim" } + }, + workspace = { + library = vim.api.nvim_get_runtime_file('', true) + }, + telemetry = { enable = false } + } + } + } + end }) require('zk').setup({ picker = "telescope", lsp = { config = { - cmd = {"zk", "lsp"}, + cmd = { "zk", "lsp" }, name = "zk", on_attach = on_attach, }, auto_attach = { enable = true, - filetypes = {"markdown"} + filetypes = { "markdown" } }, }, }) +-- Custom ZkOrphans that determines unlinked notes +-- `:ZkOrphans {tags = {"work"}}` +require('zk.commands').add("ZkOrphans", function(options) + options = vim.tbl_extend("force", { orphan = true }, options or {}) + -- zk.edit opens notes picker + require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" }) +end) +-- ZkGrep: opens file picker +-- In the case where `match_ctor` is falsy, create a prompt. +-- This is so that we distinguish between ZkGrep and ZkNotes +-- Params: +-- match_ctor: string | {match= :string,...} | "" | nil +require('zk.commands').add("ZkGrep", function(match_ctor) + -- handle polymorphic `match_ctor` + local grep_str = "" + local match + if match_ctor == nil or match_ctor == '' then + vim.fn.inputsave() + grep_str = vim.fn.input('Grep string: >') + vim.fn.inputrestore() + + match = { match = grep_str } + end + require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'" }) +end) + -- nvim-cmp local cmp = require 'cmp' local luasnip = require 'luasnip' cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, }, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }), - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - }, } -- Gitsigns require('gitsigns').setup { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - } + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + } } require('lualine').setup { - options = { - icons_enabled = true, - }, + options = { + icons_enabled = true, + }, } - From c5bf754ec85b326366dd08698a8e64a99b7a29ff Mon Sep 17 00:00:00 2001 From: pegasust Date: Wed, 31 Aug 2022 08:13:43 -0700 Subject: [PATCH 16/32] fix zkgrep --- neovim/init.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index 71ba3cd..3667696 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -385,13 +385,14 @@ end) -- match_ctor: string | {match= :string,...} | "" | nil require('zk.commands').add("ZkGrep", function(match_ctor) -- handle polymorphic `match_ctor` - local grep_str = "" + local grep_str = match_ctor local match if match_ctor == nil or match_ctor == '' then vim.fn.inputsave() grep_str = vim.fn.input('Grep string: >') vim.fn.inputrestore() - + match = { match = grep_str } + elseif type(match_ctor) == 'string' then match = { match = grep_str } end require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'" }) From 019a04c5b2ccd1bc30df5d0cd52893d0eb7cb3f0 Mon Sep 17 00:00:00 2001 From: pegasust Date: Fri, 2 Sep 2022 07:00:54 -0700 Subject: [PATCH 17/32] nvim: add GuessIndent --- neovim/init.lua | 473 +++++++++++++++++++++++++----------------------- 1 file changed, 244 insertions(+), 229 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index 3667696..e27276a 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -65,7 +65,7 @@ Plug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighti Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects Plug('nvim-telescope/telescope.nvim', { tag = '0.1.0' }) -- file browser Plug('nvim-telescope/telescope-fzf-native.nvim', - { ['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build' }) + { ['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build' }) Plug('nvim-telescope/telescope-file-browser.nvim') -- cmp: auto-complete/suggestions Plug('neovim/nvim-lspconfig') -- built-in LSP configurations @@ -76,6 +76,7 @@ Plug('onsails/lspkind-nvim') -- DevExp Plug('windwp/nvim-autopairs') -- matches pairs like [] (),... Plug('windwp/nvim-ts-autotag') -- matches tags hello +Plug('NMAC427/guess-indent.nvim') -- guesses the indentation of an opened buffer Plug('numToStr/Comment.nvim') -- "gc" to comment visual regions/lines Plug('lewis6991/gitsigns.nvim') -- add git info to sign columns Plug('tpope/vim-fugitive') -- git commands in nvim @@ -102,8 +103,8 @@ vim.cmd([[ colorscheme gruvbox ]]) -- plugin keymaps local function remap(mode, key_cmd, binded_fn, opts) - opts = opts or { remap = true } - return vim.keymap.set(mode, key_cmd, binded_fn, opts) + opts = opts or { remap = true } + return vim.keymap.set(mode, key_cmd, binded_fn, opts) end -- Comment.nvim @@ -114,50 +115,50 @@ vim.opt.listchars:append "space:⋅" vim.opt.listchars:append "eol:↴" require("indent_blankline").setup { - show_end_of_line = true, - space_char_blankline = " ", + show_end_of_line = true, + space_char_blankline = " ", } -- telescope local fb_actions = require "telescope".extensions.file_browser.actions require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, }, - extensions = { - fzf = { - fuzzy = true, -- allow fuzzy matches - override_generic_sorter = true, - override_file_sorter = true, - case_mode = 'smart_case' - }, - file_browser = { - theme = "ivy", - hiject_netrw = true, -- disables netrw and use file-browser instead - mappings = { - ["i"] = {}, -- disable any shortcut in insert mode for now - ["n"] = { - ["c"] = fb_actions.create, - ["r"] = fb_actions.rename, - ["m"] = fb_actions.move, - ["y"] = fb_actions.copy, - ["d"] = fb_actions.remove, - ["o"] = fb_actions.open, - ["g"] = fb_actions.goto_parent_dir, - ["e"] = fb_actions.goto_home_dir, - ["w"] = fb_actions.goto_cwd, - ["t"] = fb_actions.change_cwd, - ["f"] = fb_actions.toggle_browser, - ["h"] = fb_actions.toggle_hidden, - ["s"] = fb_actions.toggle_all, - } - } + }, + extensions = { + fzf = { + fuzzy = true, -- allow fuzzy matches + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case' + }, + file_browser = { + theme = "ivy", + hiject_netrw = true, -- disables netrw and use file-browser instead + mappings = { + ["i"] = {}, -- disable any shortcut in insert mode for now + ["n"] = { + ["c"] = fb_actions.create, + ["r"] = fb_actions.rename, + ["m"] = fb_actions.move, + ["y"] = fb_actions.copy, + ["d"] = fb_actions.remove, + ["o"] = fb_actions.open, + ["g"] = fb_actions.goto_parent_dir, + ["e"] = fb_actions.goto_home_dir, + ["w"] = fb_actions.goto_cwd, + ["t"] = fb_actions.change_cwd, + ["f"] = fb_actions.toggle_browser, + ["h"] = fb_actions.toggle_hidden, + ["s"] = fb_actions.toggle_all, } + } } + } } pcall(require('telescope').load_extension, 'fzf') @@ -165,85 +166,99 @@ pcall(require('telescope').load_extension, 'file_browser') remap('n', '', 'Telescope', { desc = 'Open Telescope general search' }) remap('n', 'fm', function() - require("telescope").extensions.file_browser.file_browser() + require("telescope").extensions.file_browser.file_browser() end, { desc = '[F]ile [M]utation' }) remap('n', 'ff', function() - require('telescope.builtin').find_files({ - hidden = false, - no_ignore = false, - follow = false, - }) + require('telescope.builtin').find_files({ + hidden = false, + no_ignore = false, + follow = false, + }) end, { desc = '[F]ind [F]ile' }) remap('n', 'fa', function() - require('telescope.builtin').find_files({ - hidden = true, - no_ignore = true, - follow = true, - }) + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = true, + follow = true, + }) end, { desc = '[F]ind [A]ll files' }) remap('n', 'fg', function() - require('telescope.builtin').live_grep() + require('telescope.builtin').live_grep() end, { desc = '[F]ind by [G]rep' }) remap('n', 'fb', function() - require('telescope.builtin').buffers() + require('telescope.builtin').buffers() end, { desc = '[F]ind existing [B]uffers' }) remap('n', 'fh', function() - require('telescope.builtin').help_tags() + require('telescope.builtin').help_tags() end, { desc = '[F]ind [H]elp' }) remap('n', 'fd', function() - require('telescope.builtin').diagnostics() + require('telescope.builtin').diagnostics() end, { desc = '[F]ind [D]iagnostics' }) -- treesitter require('nvim-treesitter.configs').setup { - ensure_installed = { 'lua', 'typescript', 'rust', 'go', 'python', 'prisma' }, - sync_install = false, - highlight = { enable = true }, - indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - node_decremental = '', - scope_incremental = '' - } - }, - textobjects = { - select = { - enable = true, - lookahead = true, - keymaps = { - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, - }, - }, - -- automatically close and modify HTML and TSX tags - autotag = { - enable = true, + ensure_installed = { 'lua', 'typescript', 'rust', 'go', 'python', 'prisma' }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + node_decremental = '', + scope_incremental = '' + } + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, }, + }, + -- automatically close and modify HTML and TSX tags + autotag = { + enable = true, + }, } require('nvim-autopairs').setup { - check_ts = true, + check_ts = true, +} + +require('guess-indent').setup { + auto_cmd = true, -- Set to false to disable automatic execution + filetype_exclude = { -- A list of filetypes for which the auto command gets disabled + "netrw", + "tutor", + }, + buftype_exclude = { -- A list of buffer types for which the auto command gets disabled + "help", + "nofile", + "terminal", + "prompt", + }, } -- harpoon: mark significant files & switch between them remap('n', 'm', function() require('harpoon.mark').add_file() end) local function harpoon_nav(key, nav_file_index, lead_keybind) - lead_keybind = lead_keybind or 'h' - assert(type(key) == "string", "expect key to be string(keybind)") - assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index") - return remap('n', lead_keybind .. key, function() require('harpoon.ui').nav_file(nav_file_index) end) + lead_keybind = lead_keybind or 'h' + assert(type(key) == "string", "expect key to be string(keybind)") + assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index") + return remap('n', lead_keybind .. key, function() require('harpoon.ui').nav_file(nav_file_index) end) end -- remap letters to index. Inspired by alternating number of Dvorak programmer @@ -268,115 +283,115 @@ harpoon_nav('0', 10) -- LSP settings -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_, bufnr) - -- NOTE: Remember that lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself - -- many times. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local nmap = function(keys, func, desc) - if desc then - desc = 'LSP: ' .. desc - end - - vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + -- NOTE: Remember that lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself + -- many times. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc end - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + end - -- symbols and gotos - nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') - nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation') - nmap('gr', require('telescope.builtin').lsp_references) - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - -- documentations. See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + -- symbols and gotos + nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation') + nmap('gr', require('telescope.builtin').lsp_references) + nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') - nmap('ja', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, '[W]orkspace [L]ist Folders') +-- documentations. See `:help K` for why this keymap + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') - -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, 'Format', vim.lsp.buf.format or vim.lsp.buf.formatting, - { desc = 'Format current buffer with LSP' }) + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') +nmap('ja', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, '[W]orkspace [L]ist Folders') + + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, 'Format', vim.lsp.buf.format or vim.lsp.buf.formatting, + { desc = 'Format current buffer with LSP' }) end -- nvim-cmp supports additional completion capabilities local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) -- default language servers local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', "prisma-language-server" } require("mason").setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - } + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" } + } }) require('mason-lspconfig').setup({ - ensure_installed = servers, - automatic_installation = true + ensure_installed = servers, + automatic_installation = true }) require('mason-lspconfig').setup_handlers({ - -- default handler - function(server_name) - require('lspconfig')[server_name].setup { - on_attach = on_attach, - capabilities = capabilities, + -- default handler + function(server_name) + require('lspconfig')[server_name].setup { + on_attach = on_attach, + capabilities = capabilities, + } + end, + ["sumneko_lua"] = function() + require('lspconfig').sumneko_lua.setup { + on_attach = on_attach, + capabilities = capabilities, + settings = { + Lua = { + runtime = { + version = "LuaJIT", + path = vim.split(package.path, ";"), + }, + diagnostics = { + globals = { "vim" } + }, + workspace = { + library = vim.api.nvim_get_runtime_file('', true) +}, + telemetry = { enable = false } } - end, - ["sumneko_lua"] = function() - require('lspconfig').sumneko_lua.setup { - on_attach = on_attach, - capabilities = capabilities, - settings = { - Lua = { - runtime = { - version = "LuaJIT", - path = vim.split(package.path, ";"), - }, - diagnostics = { - globals = { "vim" } - }, - workspace = { - library = vim.api.nvim_get_runtime_file('', true) - }, - telemetry = { enable = false } - } - } - } - end + } +} + end }) require('zk').setup({ - picker = "telescope", - lsp = { - config = { - cmd = { "zk", "lsp" }, - name = "zk", - on_attach = on_attach, - }, - auto_attach = { - enable = true, - filetypes = { "markdown" } - }, + picker = "telescope", + lsp = { + config = { + cmd = { "zk", "lsp" }, + name = "zk", + on_attach = on_attach, +}, + auto_attach = { + enable = true, + filetypes = { "markdown" } }, + }, }) -- Custom ZkOrphans that determines unlinked notes -- `:ZkOrphans {tags = {"work"}}` require('zk.commands').add("ZkOrphans", function(options) - options = vim.tbl_extend("force", { orphan = true }, options or {}) - -- zk.edit opens notes picker - require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" }) + options = vim.tbl_extend("force", { orphan = true }, options or {}) + -- zk.edit opens notes picker + require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" }) end) -- ZkGrep: opens file picker -- In the case where `match_ctor` is falsy, create a prompt. @@ -384,18 +399,18 @@ end) -- Params: -- match_ctor: string | {match= :string,...} | "" | nil require('zk.commands').add("ZkGrep", function(match_ctor) - -- handle polymorphic `match_ctor` - local grep_str = match_ctor - local match - if match_ctor == nil or match_ctor == '' then - vim.fn.inputsave() - grep_str = vim.fn.input('Grep string: >') - vim.fn.inputrestore() - match = { match = grep_str } - elseif type(match_ctor) == 'string' then - match = { match = grep_str } - end - require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'" }) + -- handle polymorphic `match_ctor` + local grep_str = match_ctor + local match + if match_ctor == nil or match_ctor == '' then + vim.fn.inputsave() + grep_str = vim.fn.input('Grep string: >') + vim.fn.inputrestore() + match = { match = grep_str } + elseif type(match_ctor) == 'string' then + match = { match = grep_str } + end + require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'" }) end) -- nvim-cmp @@ -403,56 +418,56 @@ local cmp = require 'cmp' local luasnip = require 'luasnip' cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }), - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), +[''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, +select = true, +}, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() +end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, } -- Gitsigns require('gitsigns').setup { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - } + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + } } require('lualine').setup { - options = { - icons_enabled = true, - }, + options = { + icons_enabled = true, + }, } From 6e4b9d5a7193e6990b15fee449d9e2c5c31e68c8 Mon Sep 17 00:00:00 2001 From: pegasust Date: Tue, 6 Sep 2022 23:06:13 -0700 Subject: [PATCH 18/32] Add dockerfile treesitter --- neovim/init.lua | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/neovim/init.lua b/neovim/init.lua index e27276a..2103419 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -5,6 +5,10 @@ -- - Auto-complete (in insert mode: ctrl-space, navigate w/ Tab+S-Tab, confirm: Enter) -- - cmd: ":Format" to format -- - Harpoon marks: Navigate through main files within each project +-- +-- REQUIREMENTS: +-- - zk @ https://github.com/mickael-menu/zk +-- - prettierd @ npm install -g @fsouza/prettierd -- Basic settings of vim vim.cmd([[ @@ -161,6 +165,7 @@ require('telescope').setup { } } +-- Telescope key remap stuffs pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'file_browser') remap('n', '', 'Telescope', { desc = 'Open Telescope general search' }) @@ -201,9 +206,21 @@ remap('n', 'fd', function() require('telescope.builtin').diagnostics() end, { desc = '[F]ind [D]iagnostics' }) +-- ZK remap stuffs +remap('n', 'zf', function() + vim.cmd([[:ZkNotes]]) +end, { desc = '[Z]ettelkasten [F]iles' }) + +remap('n', 'zg', function() + vim.cmd([[:ZkGrep]]) +end, { desc = '[Z]ettelkasten [G]rep' }) + -- treesitter require('nvim-treesitter.configs').setup { - ensure_installed = { 'lua', 'typescript', 'rust', 'go', 'python', 'prisma' }, + ensure_installed = { + 'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css', + 'python', 'prisma', 'html', "dockerfile" + }, sync_install = false, highlight = { enable = true }, indent = { enable = true }, @@ -238,6 +255,10 @@ require('nvim-autopairs').setup { check_ts = true, } +local parser_config = require('nvim-treesitter.parsers').get_parser_configs() +parser_config.tsx.filetype_to_parsername = {"javascript", "typescript.tsx"} + + require('guess-indent').setup { auto_cmd = true, -- Set to false to disable automatic execution filetype_exclude = { -- A list of filetypes for which the auto command gets disabled From e5ecfa32da34993b24480722d6a70b3fe0c6bd7a Mon Sep 17 00:00:00 2001 From: pegasust Date: Mon, 12 Sep 2022 16:20:01 -0700 Subject: [PATCH 19/32] add hlargs and shade --- neovim/init.lua | 503 +++++++++++++++++++++++++----------------------- 1 file changed, 258 insertions(+), 245 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index 2103419..b60f918 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -92,23 +92,36 @@ Plug('ThePrimeagen/harpoon') -- 1-click through marked files per project Plug('gruvbox-community/gruvbox') Plug('nvim-lualine/lualine.nvim') -- fancy status line Plug('lukas-reineke/indent-blankline.nvim') -- identation lines on blank lines +Plug('sunjon/shade.nvim') -- other Plug('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }) Plug('saadparwaiz1/cmp_luasnip') -- snippet engine Plug('L3MON4D3/LuaSnip') -- snippet engine Plug('mickael-menu/zk-nvim') -- Zettelkasten +Plug('m-demare/hlargs.nvim') -- highlights arguments; great for func prog --------- vim.call('plug#end') -- color, highlighting, UI stuffs vim.cmd([[ colorscheme gruvbox ]]) +require('hlargs').setup() +require('shade').setup{ + overlay_opacity = 60, + opacity_step = 1, + keys = { + brightness_up = '', + brightness_down = '', + toggle = 's', -- s: sha + } +} -- plugin keymaps + local function remap(mode, key_cmd, binded_fn, opts) - opts = opts or { remap = true } - return vim.keymap.set(mode, key_cmd, binded_fn, opts) + opts = opts or { remap = true } + return vim.keymap.set(mode, key_cmd, binded_fn, opts) end -- Comment.nvim @@ -119,50 +132,50 @@ vim.opt.listchars:append "space:⋅" vim.opt.listchars:append "eol:↴" require("indent_blankline").setup { - show_end_of_line = true, - space_char_blankline = " ", + show_end_of_line = true, + space_char_blankline = " ", } -- telescope local fb_actions = require "telescope".extensions.file_browser.actions require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, }, - }, - extensions = { - fzf = { - fuzzy = true, -- allow fuzzy matches - override_generic_sorter = true, - override_file_sorter = true, - case_mode = 'smart_case' - }, - file_browser = { - theme = "ivy", - hiject_netrw = true, -- disables netrw and use file-browser instead - mappings = { - ["i"] = {}, -- disable any shortcut in insert mode for now - ["n"] = { - ["c"] = fb_actions.create, - ["r"] = fb_actions.rename, - ["m"] = fb_actions.move, - ["y"] = fb_actions.copy, - ["d"] = fb_actions.remove, - ["o"] = fb_actions.open, - ["g"] = fb_actions.goto_parent_dir, - ["e"] = fb_actions.goto_home_dir, - ["w"] = fb_actions.goto_cwd, - ["t"] = fb_actions.change_cwd, - ["f"] = fb_actions.toggle_browser, - ["h"] = fb_actions.toggle_hidden, - ["s"] = fb_actions.toggle_all, + extensions = { + fzf = { + fuzzy = true, -- allow fuzzy matches + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case' + }, + file_browser = { + theme = "ivy", + hiject_netrw = true, -- disables netrw and use file-browser instead + mappings = { + ["i"] = {}, -- disable any shortcut in insert mode for now + ["n"] = { + ["c"] = fb_actions.create, + ["r"] = fb_actions.rename, + ["m"] = fb_actions.move, + ["y"] = fb_actions.copy, + ["d"] = fb_actions.remove, + ["o"] = fb_actions.open, + ["g"] = fb_actions.goto_parent_dir, + ["e"] = fb_actions.goto_home_dir, + ["w"] = fb_actions.goto_cwd, + ["t"] = fb_actions.change_cwd, + ["f"] = fb_actions.toggle_browser, + ["h"] = fb_actions.toggle_hidden, + ["s"] = fb_actions.toggle_all, + } + } } - } } - } } -- Telescope key remap stuffs @@ -171,115 +184,115 @@ pcall(require('telescope').load_extension, 'file_browser') remap('n', '', 'Telescope', { desc = 'Open Telescope general search' }) remap('n', 'fm', function() - require("telescope").extensions.file_browser.file_browser() + require("telescope").extensions.file_browser.file_browser() end, { desc = '[F]ile [M]utation' }) remap('n', 'ff', function() - require('telescope.builtin').find_files({ - hidden = false, - no_ignore = false, - follow = false, - }) + require('telescope.builtin').find_files({ + hidden = false, + no_ignore = false, + follow = false, + }) end, { desc = '[F]ind [F]ile' }) remap('n', 'fa', function() - require('telescope.builtin').find_files({ - hidden = true, - no_ignore = true, - follow = true, - }) + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = true, + follow = true, + }) end, { desc = '[F]ind [A]ll files' }) remap('n', 'fg', function() - require('telescope.builtin').live_grep() + require('telescope.builtin').live_grep() end, { desc = '[F]ind by [G]rep' }) remap('n', 'fb', function() - require('telescope.builtin').buffers() + require('telescope.builtin').buffers() end, { desc = '[F]ind existing [B]uffers' }) remap('n', 'fh', function() - require('telescope.builtin').help_tags() + require('telescope.builtin').help_tags() end, { desc = '[F]ind [H]elp' }) remap('n', 'fd', function() - require('telescope.builtin').diagnostics() + require('telescope.builtin').diagnostics() end, { desc = '[F]ind [D]iagnostics' }) -- ZK remap stuffs remap('n', 'zf', function() - vim.cmd([[:ZkNotes]]) + vim.cmd([[:ZkNotes]]) end, { desc = '[Z]ettelkasten [F]iles' }) remap('n', 'zg', function() - vim.cmd([[:ZkGrep]]) + vim.cmd([[:ZkGrep]]) end, { desc = '[Z]ettelkasten [G]rep' }) -- treesitter require('nvim-treesitter.configs').setup { - ensure_installed = { - 'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css', - 'python', 'prisma', 'html', "dockerfile" - }, - sync_install = false, - highlight = { enable = true }, - indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - node_decremental = '', - scope_incremental = '' - } - }, - textobjects = { - select = { - enable = true, - lookahead = true, - keymaps = { - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, + ensure_installed = { + 'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css', + 'python', 'prisma', 'html', "dockerfile", "c", "cpp", + }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + node_decremental = '', + scope_incremental = '' + } + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + }, + -- automatically close and modify HTML and TSX tags + autotag = { + enable = true, }, - }, - -- automatically close and modify HTML and TSX tags - autotag = { - enable = true, - }, } require('nvim-autopairs').setup { - check_ts = true, + check_ts = true, } local parser_config = require('nvim-treesitter.parsers').get_parser_configs() -parser_config.tsx.filetype_to_parsername = {"javascript", "typescript.tsx"} +parser_config.tsx.filetype_to_parsername = { "javascript", "typescript.tsx" } require('guess-indent').setup { - auto_cmd = true, -- Set to false to disable automatic execution - filetype_exclude = { -- A list of filetypes for which the auto command gets disabled - "netrw", - "tutor", - }, - buftype_exclude = { -- A list of buffer types for which the auto command gets disabled - "help", - "nofile", - "terminal", - "prompt", - }, + auto_cmd = true, -- Set to false to disable automatic execution + filetype_exclude = { -- A list of filetypes for which the auto command gets disabled + "netrw", + "tutor", + }, + buftype_exclude = { -- A list of buffer types for which the auto command gets disabled + "help", + "nofile", + "terminal", + "prompt", + }, } -- harpoon: mark significant files & switch between them remap('n', 'm', function() require('harpoon.mark').add_file() end) local function harpoon_nav(key, nav_file_index, lead_keybind) - lead_keybind = lead_keybind or 'h' - assert(type(key) == "string", "expect key to be string(keybind)") - assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index") - return remap('n', lead_keybind .. key, function() require('harpoon.ui').nav_file(nav_file_index) end) + lead_keybind = lead_keybind or 'h' + assert(type(key) == "string", "expect key to be string(keybind)") + assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index") + return remap('n', lead_keybind .. key, function() require('harpoon.ui').nav_file(nav_file_index) end) end -- remap letters to index. Inspired by alternating number of Dvorak programmer @@ -304,115 +317,115 @@ harpoon_nav('0', 10) -- LSP settings -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_, bufnr) - -- NOTE: Remember that lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself - -- many times. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local nmap = function(keys, func, desc) - if desc then - desc = 'LSP: ' .. desc + -- NOTE: Remember that lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself + -- many times. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) end - vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) - end + nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + -- symbols and gotos + nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation') + nmap('gr', require('telescope.builtin').lsp_references) + nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - -- symbols and gotos - nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') - nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation') - nmap('gr', require('telescope.builtin').lsp_references) - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + -- documentations. See `:help K` for why this keymap + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') --- documentations. See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') + nmap('ja', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, '[W]orkspace [L]ist Folders') - -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') -nmap('ja', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, '[W]orkspace [L]ist Folders') - - -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, 'Format', vim.lsp.buf.format or vim.lsp.buf.formatting, - { desc = 'Format current buffer with LSP' }) + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, 'Format', vim.lsp.buf.format or vim.lsp.buf.formatting, + { desc = 'Format current buffer with LSP' }) end -- nvim-cmp supports additional completion capabilities local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) -- default language servers local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', "prisma-language-server" } require("mason").setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + } } - } }) require('mason-lspconfig').setup({ - ensure_installed = servers, - automatic_installation = true + ensure_installed = servers, + automatic_installation = true }) require('mason-lspconfig').setup_handlers({ - -- default handler - function(server_name) - require('lspconfig')[server_name].setup { - on_attach = on_attach, - capabilities = capabilities, - } - end, - ["sumneko_lua"] = function() - require('lspconfig').sumneko_lua.setup { - on_attach = on_attach, - capabilities = capabilities, - settings = { - Lua = { - runtime = { - version = "LuaJIT", - path = vim.split(package.path, ";"), - }, - diagnostics = { - globals = { "vim" } - }, - workspace = { - library = vim.api.nvim_get_runtime_file('', true) -}, - telemetry = { enable = false } + -- default handler + function(server_name) + require('lspconfig')[server_name].setup { + on_attach = on_attach, + capabilities = capabilities, } - } -} - end + end, + ["sumneko_lua"] = function() + require('lspconfig').sumneko_lua.setup { + on_attach = on_attach, + capabilities = capabilities, + settings = { + Lua = { + runtime = { + version = "LuaJIT", + path = vim.split(package.path, ";"), + }, + diagnostics = { + globals = { "vim" } + }, + workspace = { + library = vim.api.nvim_get_runtime_file('', true) + }, + telemetry = { enable = false } + } + } + } + end }) require('zk').setup({ - picker = "telescope", - lsp = { - config = { - cmd = { "zk", "lsp" }, - name = "zk", - on_attach = on_attach, -}, - auto_attach = { - enable = true, - filetypes = { "markdown" } + picker = "telescope", + lsp = { + config = { + cmd = { "zk", "lsp" }, + name = "zk", + on_attach = on_attach, + }, + auto_attach = { + enable = true, + filetypes = { "markdown" } + }, }, - }, }) -- Custom ZkOrphans that determines unlinked notes -- `:ZkOrphans {tags = {"work"}}` require('zk.commands').add("ZkOrphans", function(options) - options = vim.tbl_extend("force", { orphan = true }, options or {}) - -- zk.edit opens notes picker - require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" }) + options = vim.tbl_extend("force", { orphan = true }, options or {}) + -- zk.edit opens notes picker + require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" }) end) -- ZkGrep: opens file picker -- In the case where `match_ctor` is falsy, create a prompt. @@ -420,18 +433,18 @@ end) -- Params: -- match_ctor: string | {match= :string,...} | "" | nil require('zk.commands').add("ZkGrep", function(match_ctor) - -- handle polymorphic `match_ctor` - local grep_str = match_ctor - local match - if match_ctor == nil or match_ctor == '' then - vim.fn.inputsave() - grep_str = vim.fn.input('Grep string: >') - vim.fn.inputrestore() - match = { match = grep_str } - elseif type(match_ctor) == 'string' then - match = { match = grep_str } - end - require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'" }) + -- handle polymorphic `match_ctor` + local grep_str = match_ctor + local match + if match_ctor == nil or match_ctor == '' then + vim.fn.inputsave() + grep_str = vim.fn.input('Grep string: >') + vim.fn.inputrestore() + match = { match = grep_str } + elseif type(match_ctor) == 'string' then + match = { match = grep_str } + end + require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'" }) end) -- nvim-cmp @@ -439,56 +452,56 @@ local cmp = require 'cmp' local luasnip = require 'luasnip' cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), -[''] = cmp.mapping.complete(), - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, -select = true, -}, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() -end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }), - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, } -- Gitsigns require('gitsigns').setup { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - } + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + } } require('lualine').setup { - options = { - icons_enabled = true, - }, + options = { + icons_enabled = true, + }, } From 51105a3e83c321dc01a329219e58a14cc2c6e9ae Mon Sep 17 00:00:00 2001 From: pegasust Date: Thu, 15 Sep 2022 07:33:10 -0700 Subject: [PATCH 20/32] add more langauges --- neovim/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neovim/init.lua b/neovim/init.lua index b60f918..8a043f2 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -361,7 +361,7 @@ end -- nvim-cmp supports additional completion capabilities local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) -- default language servers -local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', "prisma-language-server" } +local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals', 'rnix', 'eslint' } require("mason").setup({ ui = { icons = { From e3c44147696eafd48687e3cd8109fcdb374cc4c4 Mon Sep 17 00:00:00 2001 From: pegasust Date: Mon, 19 Sep 2022 12:52:25 -0700 Subject: [PATCH 21/32] fix issues that may prevent lsp.buf.format to perform --- neovim/init.lua | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index 8a043f2..5d4007f 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -69,7 +69,7 @@ Plug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighti Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects Plug('nvim-telescope/telescope.nvim', { tag = '0.1.0' }) -- file browser Plug('nvim-telescope/telescope-fzf-native.nvim', - { ['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build' }) + { ['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build' }) Plug('nvim-telescope/telescope-file-browser.nvim') -- cmp: auto-complete/suggestions Plug('neovim/nvim-lspconfig') -- built-in LSP configurations @@ -107,11 +107,11 @@ vim.call('plug#end') -- color, highlighting, UI stuffs vim.cmd([[ colorscheme gruvbox ]]) require('hlargs').setup() -require('shade').setup{ - overlay_opacity = 60, - opacity_step = 1, - keys = { - brightness_up = '', +require('shade').setup { + overlay_opacity = 60, + opacity_step = 1, + keys = { + brightness_up = '', brightness_down = '', toggle = 's', -- s: sha } @@ -316,7 +316,7 @@ harpoon_nav('0', 10) -- LSP settings -- This function gets run when an LSP connects to a particular buffer. -local on_attach = function(_, bufnr) +local on_attach = function(_client, bufnr) -- NOTE: Remember that lua is a real programming language, and as such it is possible -- to define small helper and utility functions so you don't have to repeat yourself -- many times. @@ -328,11 +328,13 @@ local on_attach = function(_, bufnr) desc = 'LSP: ' .. desc end - vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc }) end nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + nmap('df', function() vim.lsp.buf.format({ async = true }) end, '[D]ocument [F]ormat') -- symbols and gotos nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') @@ -348,20 +350,18 @@ local on_attach = function(_, bufnr) -- Lesser used LSP functionality nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') - nmap('ja', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') nmap('wl', function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, '[W]orkspace [L]ist Folders') - -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, 'Format', vim.lsp.buf.format or vim.lsp.buf.formatting, - { desc = 'Format current buffer with LSP' }) end -- nvim-cmp supports additional completion capabilities local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) -- default language servers -local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals', 'rnix', 'eslint' } +local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals', + 'rnix', 'eslint' } require("mason").setup({ ui = { icons = { @@ -399,7 +399,14 @@ require('mason-lspconfig').setup_handlers({ workspace = { library = vim.api.nvim_get_runtime_file('', true) }, - telemetry = { enable = false } + telemetry = { enable = false }, + format = { + enable = true, + defaultConfig = { + indent_style = "space", + indent_size = 2, + } + } } } } From fb8f2363d385441ca008d4d0e2bdbf04403e72aa Mon Sep 17 00:00:00 2001 From: pegasust Date: Fri, 23 Sep 2022 23:03:47 -0700 Subject: [PATCH 22/32] fix lsp setup and add neogit --- neovim/init.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/neovim/init.lua b/neovim/init.lua index 5d4007f..2e762e8 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -87,6 +87,7 @@ Plug('tpope/vim-fugitive') -- git commands in nvim Plug('williamboman/mason.nvim') -- LSP, debuggers,... package manager Plug('williamboman/mason-lspconfig.nvim') -- lsp config for mason Plug('ThePrimeagen/harpoon') -- 1-click through marked files per project +Plug('TimUntersberger/neogit') -- Easy-to-see git status -- UI & colorscheme Plug('gruvbox-community/gruvbox') @@ -314,7 +315,12 @@ harpoon_nav('8', 8) harpoon_nav('9', 9) harpoon_nav('0', 10) +-- neogit: easy-to-see git status +require('neogit').setup {} +remap('n', 'gs', function() require('neogit').open({}) end); + -- LSP settings +require('nvim-lsp-installer').setup {} -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_client, bufnr) -- NOTE: Remember that lua is a real programming language, and as such it is possible @@ -511,4 +517,32 @@ require('lualine').setup { options = { icons_enabled = true, }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff', 'diagnostics' }, + lualine_c = { + {'filename', + file_status = true, + newfile_status = false, + path = 1, + symbols = { + modified = '[+]', + readonly = '[-]', + unnamed = '[Unnamed]', + newfile = '[New]', + }, + }, + }, + lualine_x = { 'encoding', 'fileformat', 'filetype', }, + lualine_y = { 'progress' }, + lualine_z = { 'location' }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { {'filename', path = 1, file_status = true, },}, + lualine_x = { 'location' }, + lualine_y = {}, + lualine_z = {}, + } } From 6b4da6304f732fb958526fedf9b3ed2393f75596 Mon Sep 17 00:00:00 2001 From: pegasust Date: Sat, 24 Sep 2022 16:49:40 -0700 Subject: [PATCH 23/32] add half-space and double-space user commands --- neovim/init.lua | 67 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index 2e762e8..68d9266 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -3,12 +3,12 @@ -- Features: -- - LSP -- - Auto-complete (in insert mode: ctrl-space, navigate w/ Tab+S-Tab, confirm: Enter) --- - cmd: ":Format" to format +-- - df to format document -- - Harpoon marks: Navigate through main files within each project -- -- REQUIREMENTS: --- - zk @ https://github.com/mickael-menu/zk --- - prettierd @ npm install -g @fsouza/prettierd +-- - zk @ https://github.com/mickael-menu/zk +-- - prettierd @ npm install -g @fsouza/prettierd -- Basic settings of vim vim.cmd([[ @@ -46,21 +46,24 @@ vim.keymap.set({ 'n', 'i', 'v' }, '', ':mode') -- redraw on every vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) vim.keymap.set('n', ']d', vim.diagnostic.goto_next) vim.keymap.set('n', 'e', vim.diagnostic.open_float) -- opens diag in box (floating) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist) -- opens list of diags -vim.keymap.set('n', 'wq', vim.diagnostic.setqflist) -- workspace diags +-- vim.keymap.set('n', 'q', vim.diagnostic.setloclist) -- opens list of diags +-- vim.keymap.set('n', 'wq', vim.diagnostic.setqflist) -- workspace diags +vim.keymap.set('n', 'q', 'TroubleToggle loclist') +vim.keymap.set('n', 'wq', 'TroubleToggle workspace_diagnostics') -- vim-plug vim.cmd([[ let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' if empty(glob(data_dir . '/autoload/plug.vim')) - silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' - autocmd VimEnter * PlugInstall --sync | source $MYVIMRC + silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif ]]) local Plug = vim.fn['plug#'] vim.call('plug#begin', '~/.config/nvim/plugged') + -- libs and dependencies Plug('nvim-lua/plenary.nvim') @@ -71,12 +74,14 @@ Plug('nvim-telescope/telescope.nvim', { tag = '0.1.0' }) -- file browser Plug('nvim-telescope/telescope-fzf-native.nvim', { ['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build' }) Plug('nvim-telescope/telescope-file-browser.nvim') + -- cmp: auto-complete/suggestions Plug('neovim/nvim-lspconfig') -- built-in LSP configurations Plug('hrsh7th/cmp-nvim-lsp') Plug('hrsh7th/cmp-buffer') Plug('hrsh7th/nvim-cmp') Plug('onsails/lspkind-nvim') + -- DevExp Plug('windwp/nvim-autopairs') -- matches pairs like [] (),... Plug('windwp/nvim-ts-autotag') -- matches tags hello @@ -88,19 +93,22 @@ Plug('williamboman/mason.nvim') -- LSP, debuggers,... package manager Plug('williamboman/mason-lspconfig.nvim') -- lsp config for mason Plug('ThePrimeagen/harpoon') -- 1-click through marked files per project Plug('TimUntersberger/neogit') -- Easy-to-see git status +Plug('folke/trouble.nvim') -- File-grouped workspace diagnostics -- UI & colorscheme -Plug('gruvbox-community/gruvbox') +Plug('gruvbox-community/gruvbox') -- theme provider Plug('nvim-lualine/lualine.nvim') -- fancy status line Plug('lukas-reineke/indent-blankline.nvim') -- identation lines on blank lines -Plug('sunjon/shade.nvim') +Plug('sunjon/shade.nvim') -- make inactive panes have lower opacity +Plug('kyazdani42/nvim-web-devicons') -- icons for folder and filetypes +Plug('m-demare/hlargs.nvim') -- highlights arguments; great for func prog +Plug('folke/todo-comments.nvim') -- Highlights TODO --- other +-- other utilities Plug('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }) Plug('saadparwaiz1/cmp_luasnip') -- snippet engine Plug('L3MON4D3/LuaSnip') -- snippet engine Plug('mickael-menu/zk-nvim') -- Zettelkasten -Plug('m-demare/hlargs.nvim') -- highlights arguments; great for func prog --------- vim.call('plug#end') @@ -117,6 +125,9 @@ require('shade').setup { toggle = 's', -- s: sha } } +require('nvim-web-devicons').setup() +require('trouble').setup() +require('todo-comments').setup() -- plugin keymaps @@ -136,6 +147,30 @@ require("indent_blankline").setup { show_end_of_line = true, space_char_blankline = " ", } +-- User command that transform into 2-spaces by translating to tabstop +vim.api.nvim_create_user_command( + 'HalfSpaces', + function(opts) + vim.api.nvim_command("set ts=2 sts=2 noet") + vim.api.nvim_command("retab!") + vim.api.nvim_command("set ts=1 sts=1 et") + vim.api.nvim_command("retab") + vim.api.nvim_command("GuessIndent") + end, + { nargs = 0 } +) +vim.api.nvim_create_user_command( + 'DoubleSpaces', + function(opts) + vim.api.nvim_command("set ts=1 sts=1 noet") + vim.api.nvim_command("retab!") + vim.api.nvim_command("set ts=2 sts=2 et") + vim.api.nvim_command("retab") + vim.api.nvim_command("GuessIndent") + end, + { nargs = 0 } +) + -- telescope local fb_actions = require "telescope".extensions.file_browser.actions require('telescope').setup { @@ -321,7 +356,7 @@ remap('n', 'gs', function() require('neogit').open({}) end); -- LSP settings require('nvim-lsp-installer').setup {} --- This function gets run when an LSP connects to a particular buffer. +-- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_client, bufnr) -- NOTE: Remember that lua is a real programming language, and as such it is possible -- to define small helper and utility functions so you don't have to repeat yourself @@ -444,7 +479,7 @@ end) -- In the case where `match_ctor` is falsy, create a prompt. -- This is so that we distinguish between ZkGrep and ZkNotes -- Params: --- match_ctor: string | {match= :string,...} | "" | nil +-- match_ctor: string | {match= :string,...} | "" | nil require('zk.commands').add("ZkGrep", function(match_ctor) -- handle polymorphic `match_ctor` local grep_str = match_ctor @@ -521,7 +556,7 @@ require('lualine').setup { lualine_a = { 'mode' }, lualine_b = { 'branch', 'diff', 'diagnostics' }, lualine_c = { - {'filename', + { 'filename', file_status = true, newfile_status = false, path = 1, @@ -533,14 +568,14 @@ require('lualine').setup { }, }, }, - lualine_x = { 'encoding', 'fileformat', 'filetype', }, + lualine_x = { 'encoding', 'fileformat', 'filetype', }, lualine_y = { 'progress' }, lualine_z = { 'location' }, }, inactive_sections = { lualine_a = {}, lualine_b = {}, - lualine_c = { {'filename', path = 1, file_status = true, },}, + lualine_c = { { 'filename', path = 1, file_status = true, }, }, lualine_x = { 'location' }, lualine_y = {}, lualine_z = {}, From 01d84e12ffea771e73ed8f19d904f7ca6d753534 Mon Sep 17 00:00:00 2001 From: pegasust Date: Tue, 4 Oct 2022 22:37:18 -0700 Subject: [PATCH 24/32] add terraform ls --- neovim/init.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index 68d9266..cc65b33 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -268,7 +268,7 @@ end, { desc = '[Z]ettelkasten [G]rep' }) require('nvim-treesitter.configs').setup { ensure_installed = { 'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css', - 'python', 'prisma', 'html', "dockerfile", "c", "cpp", + 'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", }, sync_install = false, highlight = { enable = true }, @@ -318,7 +318,7 @@ require('guess-indent').setup { "help", "nofile", "terminal", - "prompt", + -- "prompt", }, } @@ -402,14 +402,15 @@ end local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) -- default language servers local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals', - 'rnix', 'eslint' } + 'rnix', 'eslint' , 'terraform-ls', 'tflint'} require("mason").setup({ ui = { icons = { package_installed = "✓", package_pending = "➜", package_uninstalled = "✗" - } + }, + check_outdated_packages_on_open = true, } }) require('mason-lspconfig').setup({ From 5cc0c3d3d75fe69930311b2a993017cb08c622bb Mon Sep 17 00:00:00 2001 From: pegasust Date: Sat, 8 Oct 2022 15:10:19 -0700 Subject: [PATCH 25/32] add tabnine and astro --- neovim/init.lua | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index cc65b33..a842c40 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -81,6 +81,7 @@ Plug('hrsh7th/cmp-nvim-lsp') Plug('hrsh7th/cmp-buffer') Plug('hrsh7th/nvim-cmp') Plug('onsails/lspkind-nvim') +Plug('tzachar/cmp-tabnine', { ['do'] = './install.sh' }) -- DevExp Plug('windwp/nvim-autopairs') -- matches pairs like [] (),... @@ -268,7 +269,7 @@ end, { desc = '[Z]ettelkasten [G]rep' }) require('nvim-treesitter.configs').setup { ensure_installed = { 'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css', - 'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", + 'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", "svelte", "astro" }, sync_install = false, highlight = { enable = true }, @@ -400,9 +401,19 @@ local on_attach = function(_client, bufnr) end -- nvim-cmp supports additional completion capabilities local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) +local tabnine = require('cmp_tabnine.config') +tabnine.setup({ + max_lines = 1000, + max_num_results = 20, + sort = true, + run_on_every_keystroke = true, + snippet_placeholder = '..', + ignored_file_types = {}, + show_prediction_strength = true, +}) -- default language servers local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals', - 'rnix', 'eslint' , 'terraform-ls', 'tflint'} + 'rnix', 'eslint' , 'terraform-ls', 'tflint', 'svelte', 'astro'} require("mason").setup({ ui = { icons = { @@ -499,6 +510,14 @@ end) -- nvim-cmp local cmp = require 'cmp' local luasnip = require 'luasnip' +local lspkind = require('lspkind') +local source_mapping = { + buffer = '[Buffer]', + nvim_lsp = '[LSP]', + nvim_lua = '[Lua]', + cmp_tabnine = '[T9]', + path = '[Path]', +} cmp.setup { snippet = { @@ -533,9 +552,30 @@ cmp.setup { end end, { 'i', 's' }), }, + formatting = { + format = function(entry, vim_item) + vim_item.kind = lspkind.symbolic(vim_item.kind, {mode = 'symbol'}) + vim_item.menu = source_mapping[entry.source_name] + if entry.source.name == "cmp_tabnine" then + local detail = (entry.completion_item.data or {}).detail + vim_item.kind = "" + if detail and detail:find('.*%%.*') then + vim_item.kind = vim_item.kind .. ' ' .. detail + end + + if (entry.completion_item.data or {}).multiline then + vim_item.kind = vim_item.kind .. ' ' .. '[ML]' + end + end + local maxwidth = 80 + vim_item.abbr = string.sub(vim_item.abbr, 1, maxwidth) + return vim_item + end, + }, sources = { { name = 'nvim_lsp' }, { name = 'luasnip' }, + { name = 'cmp_tabnine' }, }, } @@ -582,3 +622,4 @@ require('lualine').setup { lualine_z = {}, } } + From 6484e98f9270b235c2b113982ae76fd7aa3f73c1 Mon Sep 17 00:00:00 2001 From: pegasust Date: Sun, 9 Oct 2022 20:40:48 -0700 Subject: [PATCH 26/32] add clojure --- neovim/init.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index a842c40..6ef8124 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -269,7 +269,8 @@ end, { desc = '[Z]ettelkasten [G]rep' }) require('nvim-treesitter.configs').setup { ensure_installed = { 'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css', - 'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", "svelte", "astro" + 'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", "svelte", "astro", + "clojure" }, sync_install = false, highlight = { enable = true }, @@ -413,7 +414,7 @@ tabnine.setup({ }) -- default language servers local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals', - 'rnix', 'eslint' , 'terraform-ls', 'tflint', 'svelte', 'astro'} + 'rnix', 'eslint', 'terraform-ls', 'tflint', 'svelte', 'astro', 'clojure_lsp' } require("mason").setup({ ui = { icons = { @@ -554,7 +555,7 @@ cmp.setup { }, formatting = { format = function(entry, vim_item) - vim_item.kind = lspkind.symbolic(vim_item.kind, {mode = 'symbol'}) + vim_item.kind = lspkind.symbolic(vim_item.kind, { mode = 'symbol' }) vim_item.menu = source_mapping[entry.source_name] if entry.source.name == "cmp_tabnine" then local detail = (entry.completion_item.data or {}).detail @@ -622,4 +623,3 @@ require('lualine').setup { lualine_z = {}, } } - From 0ecc6c07ef09009c86f51693a3c5734c4609b49c Mon Sep 17 00:00:00 2001 From: pegasust Date: Tue, 11 Oct 2022 17:06:09 -0700 Subject: [PATCH 27/32] half spaces --- neovim/init.lua | 707 +++++++++++++++++++++++++----------------------- 1 file changed, 364 insertions(+), 343 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index 6ef8124..79675c2 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -7,7 +7,7 @@ -- - Harpoon marks: Navigate through main files within each project -- -- REQUIREMENTS: --- - zk @ https://github.com/mickael-menu/zk +-- - zk @ https://github.com/mickael-menu/zk -- - prettierd @ npm install -g @fsouza/prettierd -- Basic settings of vim @@ -36,6 +36,7 @@ vim.opt.completeopt = 'menuone,noselect' -- vim.opt.clipboard = "unnamedplus" vim.g.mapleader = ' ' +vim.g.maplocalleader = ',' -- basic keymaps vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) -- since we're using space for leader @@ -53,10 +54,11 @@ vim.keymap.set('n', 'wq', 'TroubleToggle workspace_diagnostics' -- vim-plug +local data_dir = vim.fn.stdpath('data') vim.cmd([[ let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' if empty(glob(data_dir . '/autoload/plug.vim')) - silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif ]]) @@ -72,7 +74,7 @@ Plug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighti Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects Plug('nvim-telescope/telescope.nvim', { tag = '0.1.0' }) -- file browser Plug('nvim-telescope/telescope-fzf-native.nvim', - { ['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build' }) + { ['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build' }) Plug('nvim-telescope/telescope-file-browser.nvim') -- cmp: auto-complete/suggestions @@ -81,7 +83,7 @@ Plug('hrsh7th/cmp-nvim-lsp') Plug('hrsh7th/cmp-buffer') Plug('hrsh7th/nvim-cmp') Plug('onsails/lspkind-nvim') -Plug('tzachar/cmp-tabnine', { ['do'] = './install.sh' }) +-- Plug('tzachar/cmp-tabnine', { ['do'] = './install.sh' }) -- DevExp Plug('windwp/nvim-autopairs') -- matches pairs like [] (),... @@ -95,6 +97,10 @@ Plug('williamboman/mason-lspconfig.nvim') -- lsp config for mason Plug('ThePrimeagen/harpoon') -- 1-click through marked files per project Plug('TimUntersberger/neogit') -- Easy-to-see git status Plug('folke/trouble.nvim') -- File-grouped workspace diagnostics +Plug('tpope/vim-dispatch') -- Allows quick build/compile/test vim commands +Plug('clojure-vim/vim-jack-in') -- Clojure: ":Boot", ":Clj", ":Lein" +Plug('radenling/vim-dispatch-neovim') -- Add support for neovim's terminal emulator +Plug('Olical/conjure') -- REPL on the source for Clojure (and other LISPs) -- UI & colorscheme Plug('gruvbox-community/gruvbox') -- theme provider @@ -118,13 +124,13 @@ vim.call('plug#end') vim.cmd([[ colorscheme gruvbox ]]) require('hlargs').setup() require('shade').setup { - overlay_opacity = 60, - opacity_step = 1, - keys = { - brightness_up = '', - brightness_down = '', - toggle = 's', -- s: sha - } + overlay_opacity = 60, + opacity_step = 1, + keys = { + brightness_up = '', + brightness_down = '', + toggle = 's', -- s: sha + } } require('nvim-web-devicons').setup() require('trouble').setup() @@ -133,8 +139,8 @@ require('todo-comments').setup() -- plugin keymaps local function remap(mode, key_cmd, binded_fn, opts) - opts = opts or { remap = true } - return vim.keymap.set(mode, key_cmd, binded_fn, opts) + opts = opts or { remap = true } + return vim.keymap.set(mode, key_cmd, binded_fn, opts) end -- Comment.nvim @@ -145,74 +151,74 @@ vim.opt.listchars:append "space:⋅" vim.opt.listchars:append "eol:↴" require("indent_blankline").setup { - show_end_of_line = true, - space_char_blankline = " ", + show_end_of_line = true, + space_char_blankline = " ", } -- User command that transform into 2-spaces by translating to tabstop vim.api.nvim_create_user_command( - 'HalfSpaces', - function(opts) - vim.api.nvim_command("set ts=2 sts=2 noet") - vim.api.nvim_command("retab!") - vim.api.nvim_command("set ts=1 sts=1 et") - vim.api.nvim_command("retab") - vim.api.nvim_command("GuessIndent") - end, - { nargs = 0 } + 'HalfSpaces', + function(opts) + vim.api.nvim_command("set ts=2 sts=2 noet") + vim.api.nvim_command("retab!") + vim.api.nvim_command("set ts=1 sts=1 et") + vim.api.nvim_command("retab") + vim.api.nvim_command("GuessIndent") + end, + { nargs = 0 } ) vim.api.nvim_create_user_command( - 'DoubleSpaces', - function(opts) - vim.api.nvim_command("set ts=1 sts=1 noet") - vim.api.nvim_command("retab!") - vim.api.nvim_command("set ts=2 sts=2 et") - vim.api.nvim_command("retab") - vim.api.nvim_command("GuessIndent") - end, - { nargs = 0 } + 'DoubleSpaces', + function(opts) + vim.api.nvim_command("set ts=1 sts=1 noet") + vim.api.nvim_command("retab!") + vim.api.nvim_command("set ts=2 sts=2 et") + vim.api.nvim_command("retab") + vim.api.nvim_command("GuessIndent") + end, + { nargs = 0 } ) -- telescope local fb_actions = require "telescope".extensions.file_browser.actions require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, }, - extensions = { - fzf = { - fuzzy = true, -- allow fuzzy matches - override_generic_sorter = true, - override_file_sorter = true, - case_mode = 'smart_case' - }, - file_browser = { - theme = "ivy", - hiject_netrw = true, -- disables netrw and use file-browser instead - mappings = { - ["i"] = {}, -- disable any shortcut in insert mode for now - ["n"] = { - ["c"] = fb_actions.create, - ["r"] = fb_actions.rename, - ["m"] = fb_actions.move, - ["y"] = fb_actions.copy, - ["d"] = fb_actions.remove, - ["o"] = fb_actions.open, - ["g"] = fb_actions.goto_parent_dir, - ["e"] = fb_actions.goto_home_dir, - ["w"] = fb_actions.goto_cwd, - ["t"] = fb_actions.change_cwd, - ["f"] = fb_actions.toggle_browser, - ["h"] = fb_actions.toggle_hidden, - ["s"] = fb_actions.toggle_all, - } - } + }, + extensions = { + fzf = { + fuzzy = true, -- allow fuzzy matches + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case' + }, + file_browser = { + theme = "ivy", + hiject_netrw = true, -- disables netrw and use file-browser instead + mappings = { + ["i"] = {}, -- disable any shortcut in insert mode for now + ["n"] = { + ["c"] = fb_actions.create, + ["r"] = fb_actions.rename, + ["m"] = fb_actions.move, + ["y"] = fb_actions.copy, + ["d"] = fb_actions.remove, + ["o"] = fb_actions.open, + ["g"] = fb_actions.goto_parent_dir, + ["e"] = fb_actions.goto_home_dir, + ["w"] = fb_actions.goto_cwd, + ["t"] = fb_actions.change_cwd, + ["f"] = fb_actions.toggle_browser, + ["h"] = fb_actions.toggle_hidden, + ["s"] = fb_actions.toggle_all, } + } } + } } -- Telescope key remap stuffs @@ -221,116 +227,118 @@ pcall(require('telescope').load_extension, 'file_browser') remap('n', '', 'Telescope', { desc = 'Open Telescope general search' }) remap('n', 'fm', function() - require("telescope").extensions.file_browser.file_browser() + require("telescope").extensions.file_browser.file_browser() end, { desc = '[F]ile [M]utation' }) remap('n', 'ff', function() - require('telescope.builtin').find_files({ - hidden = false, - no_ignore = false, - follow = false, - }) + require('telescope.builtin').find_files({ + hidden = false, + no_ignore = false, + follow = false, + }) end, { desc = '[F]ind [F]ile' }) remap('n', 'fa', function() - require('telescope.builtin').find_files({ - hidden = true, - no_ignore = true, - follow = true, - }) + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = true, + follow = true, + }) end, { desc = '[F]ind [A]ll files' }) remap('n', 'fg', function() - require('telescope.builtin').live_grep() + require('telescope.builtin').live_grep() end, { desc = '[F]ind by [G]rep' }) remap('n', 'fb', function() - require('telescope.builtin').buffers() + require('telescope.builtin').buffers() end, { desc = '[F]ind existing [B]uffers' }) remap('n', 'fh', function() - require('telescope.builtin').help_tags() + require('telescope.builtin').help_tags() end, { desc = '[F]ind [H]elp' }) remap('n', 'fd', function() - require('telescope.builtin').diagnostics() + require('telescope.builtin').diagnostics() end, { desc = '[F]ind [D]iagnostics' }) -- ZK remap stuffs remap('n', 'zf', function() - vim.cmd([[:ZkNotes]]) + vim.cmd([[:ZkNotes]]) end, { desc = '[Z]ettelkasten [F]iles' }) remap('n', 'zg', function() - vim.cmd([[:ZkGrep]]) + vim.cmd([[:ZkGrep]]) end, { desc = '[Z]ettelkasten [G]rep' }) -- treesitter require('nvim-treesitter.configs').setup { - ensure_installed = { - 'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css', - 'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", "svelte", "astro", - "clojure" - }, - sync_install = false, - highlight = { enable = true }, - indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - node_decremental = '', - scope_incremental = '' - } - }, - textobjects = { - select = { - enable = true, - lookahead = true, - keymaps = { - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, - }, - }, - -- automatically close and modify HTML and TSX tags - autotag = { - enable = true, + ensure_installed = { + 'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css', + 'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", "svelte", "astro", + "clojure", "fennel" + }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + node_decremental = '', + scope_incremental = '' + } + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, }, + }, + -- automatically close and modify HTML and TSX tags + autotag = { + enable = true, + }, } require('nvim-autopairs').setup { - check_ts = true, + check_ts = true, + } local parser_config = require('nvim-treesitter.parsers').get_parser_configs() parser_config.tsx.filetype_to_parsername = { "javascript", "typescript.tsx" } +parser_config.astro.filetype_to_parsername = { "javascript", "typescript.tsx", "astro" } require('guess-indent').setup { - auto_cmd = true, -- Set to false to disable automatic execution - filetype_exclude = { -- A list of filetypes for which the auto command gets disabled - "netrw", - "tutor", - }, - buftype_exclude = { -- A list of buffer types for which the auto command gets disabled - "help", - "nofile", - "terminal", - -- "prompt", - }, + auto_cmd = true, -- Set to false to disable automatic execution + filetype_exclude = { -- A list of filetypes for which the auto command gets disabled + "netrw", + "tutor", + }, + buftype_exclude = { -- A list of buffer types for which the auto command gets disabled + "help", + "nofile", + "terminal", + -- "prompt", + }, } -- harpoon: mark significant files & switch between them remap('n', 'm', function() require('harpoon.mark').add_file() end) local function harpoon_nav(key, nav_file_index, lead_keybind) - lead_keybind = lead_keybind or 'h' - assert(type(key) == "string", "expect key to be string(keybind)") - assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index") - return remap('n', lead_keybind .. key, function() require('harpoon.ui').nav_file(nav_file_index) end) + lead_keybind = lead_keybind or 'h' + assert(type(key) == "string", "expect key to be string(keybind)") + assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index") + return remap('n', lead_keybind .. key, function() require('harpoon.ui').nav_file(nav_file_index) end) end -- remap letters to index. Inspired by alternating number of Dvorak programmer @@ -360,133 +368,146 @@ remap('n', 'gs', function() require('neogit').open({}) end); require('nvim-lsp-installer').setup {} -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_client, bufnr) - -- NOTE: Remember that lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself - -- many times. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local nmap = function(keys, func, desc) - if desc then - desc = 'LSP: ' .. desc - end - - vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc }) + -- NOTE: Remember that lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself + -- many times. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc end - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - nmap('df', function() vim.lsp.buf.format({ async = true }) end, '[D]ocument [F]ormat') + vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc }) + end - -- symbols and gotos - nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') - nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation') - nmap('gr', require('telescope.builtin').lsp_references) - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + nmap('df', function() vim.lsp.buf.format({ async = true }) end, '[D]ocument [F]ormat') - -- documentations. See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + -- symbols and gotos + nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation') + nmap('gr', require('telescope.builtin').lsp_references) + nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') - nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, '[W]orkspace [L]ist Folders') + -- documentations. See `:help K` for why this keymap + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') + nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, '[W]orkspace [L]ist Folders') end -- nvim-cmp supports additional completion capabilities local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) -local tabnine = require('cmp_tabnine.config') -tabnine.setup({ - max_lines = 1000, - max_num_results = 20, - sort = true, - run_on_every_keystroke = true, - snippet_placeholder = '..', - ignored_file_types = {}, - show_prediction_strength = true, -}) +-- local tabnine = require('cmp_tabnine.config') +-- tabnine.setup({ +-- max_lines = 1000, +-- max_num_results = 20, +-- sort = true, +-- run_on_every_keystroke = true, +-- snippet_placeholder = '..', +-- ignored_file_types = {}, +-- show_prediction_strength = true, +-- }) -- default language servers local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals', - 'rnix', 'eslint', 'terraform-ls', 'tflint', 'svelte', 'astro', 'clojure_lsp' } + 'rnix', 'eslint', 'terraform-ls', 'tflint', 'svelte', 'astro', 'clojure_lsp' } require("mason").setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - }, - check_outdated_packages_on_open = true, - } + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + }, + check_outdated_packages_on_open = true, + } }) require('mason-lspconfig').setup({ - ensure_installed = servers, - automatic_installation = true + ensure_installed = servers, + automatic_installation = true }) require('mason-lspconfig').setup_handlers({ - -- default handler - function(server_name) - require('lspconfig')[server_name].setup { - on_attach = on_attach, - capabilities = capabilities, - } - end, - ["sumneko_lua"] = function() - require('lspconfig').sumneko_lua.setup { - on_attach = on_attach, - capabilities = capabilities, - settings = { - Lua = { - runtime = { - version = "LuaJIT", - path = vim.split(package.path, ";"), - }, - diagnostics = { - globals = { "vim" } - }, - workspace = { - library = vim.api.nvim_get_runtime_file('', true) - }, - telemetry = { enable = false }, - format = { - enable = true, - defaultConfig = { - indent_style = "space", - indent_size = 2, - } - } - } + -- default handler + function(server_name) + require('lspconfig')[server_name].setup { + on_attach = on_attach, + capabilities = capabilities, + } + end, + ["sumneko_lua"] = function() + require('lspconfig').sumneko_lua.setup { + on_attach = on_attach, + capabilities = capabilities, + settings = { + Lua = { + runtime = { + version = "LuaJIT", + path = vim.split(package.path, ";"), + }, + diagnostics = { + globals = { "vim" } + }, + workspace = { + library = vim.api.nvim_get_runtime_file('', true) + }, + telemetry = { enable = false }, + format = { + enable = true, + defaultConfig = { + indent_style = "space", + indent_size = 2, } + } } - end + } + } + end, + -- ["astro"] = function() + -- print('configuring astro') + -- require('lspconfig').astro.setup { + -- on_attach = on_attach, + -- capabilities = capabilities, + -- init_options = { + -- configuration = {}, + -- typescript = { + -- serverPath = data_dir + -- } + -- } + -- } + -- end }) require('zk').setup({ - picker = "telescope", - lsp = { - config = { - cmd = { "zk", "lsp" }, - name = "zk", - on_attach = on_attach, - }, - auto_attach = { - enable = true, - filetypes = { "markdown" } - }, + picker = "telescope", + lsp = { + config = { + cmd = { "zk", "lsp" }, + name = "zk", + on_attach = on_attach, }, + auto_attach = { + enable = true, + filetypes = { "markdown" } + }, + }, }) -- Custom ZkOrphans that determines unlinked notes -- `:ZkOrphans {tags = {"work"}}` require('zk.commands').add("ZkOrphans", function(options) - options = vim.tbl_extend("force", { orphan = true }, options or {}) - -- zk.edit opens notes picker - require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" }) + options = vim.tbl_extend("force", { orphan = true }, options or {}) + -- zk.edit opens notes picker + require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" }) end) -- ZkGrep: opens file picker -- In the case where `match_ctor` is falsy, create a prompt. @@ -494,18 +515,18 @@ end) -- Params: -- match_ctor: string | {match= :string,...} | "" | nil require('zk.commands').add("ZkGrep", function(match_ctor) - -- handle polymorphic `match_ctor` - local grep_str = match_ctor - local match - if match_ctor == nil or match_ctor == '' then - vim.fn.inputsave() - grep_str = vim.fn.input('Grep string: >') - vim.fn.inputrestore() - match = { match = grep_str } - elseif type(match_ctor) == 'string' then - match = { match = grep_str } - end - require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'" }) + -- handle polymorphic `match_ctor` + local grep_str = match_ctor + local match + if match_ctor == nil or match_ctor == '' then + vim.fn.inputsave() + grep_str = vim.fn.input('Grep string: >') + vim.fn.inputrestore() + match = { match = grep_str } + elseif type(match_ctor) == 'string' then + match = { match = grep_str } + end + require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'" }) end) -- nvim-cmp @@ -513,113 +534,113 @@ local cmp = require 'cmp' local luasnip = require 'luasnip' local lspkind = require('lspkind') local source_mapping = { - buffer = '[Buffer]', - nvim_lsp = '[LSP]', - nvim_lua = '[Lua]', - cmp_tabnine = '[T9]', - path = '[Path]', + buffer = '[Buffer]', + nvim_lsp = '[LSP]', + nvim_lua = '[Lua]', + -- cmp_tabnine = '[T9]', + path = '[Path]', } cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }), - }, - formatting = { - format = function(entry, vim_item) - vim_item.kind = lspkind.symbolic(vim_item.kind, { mode = 'symbol' }) - vim_item.menu = source_mapping[entry.source_name] - if entry.source.name == "cmp_tabnine" then - local detail = (entry.completion_item.data or {}).detail - vim_item.kind = "" - if detail and detail:find('.*%%.*') then - vim_item.kind = vim_item.kind .. ' ' .. detail - end - - if (entry.completion_item.data or {}).multiline then - vim_item.kind = vim_item.kind .. ' ' .. '[ML]' - end - end - local maxwidth = 80 - vim_item.abbr = string.sub(vim_item.abbr, 1, maxwidth) - return vim_item - end, - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'cmp_tabnine' }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + formatting = { + format = function(entry, vim_item) + vim_item.kind = lspkind.symbolic(vim_item.kind, { mode = 'symbol' }) + vim_item.menu = source_mapping[entry.source_name] + -- if entry.source.name == "cmp_tabnine" then + -- local detail = (entry.completion_item.data or {}).detail + -- vim_item.kind = "" + -- if detail and detail:find('.*%%.*') then + -- vim_item.kind = vim_item.kind .. ' ' .. detail + -- end + -- + -- if (entry.completion_item.data or {}).multiline then + -- vim_item.kind = vim_item.kind .. ' ' .. '[ML]' + -- end + -- end + local maxwidth = 80 + vim_item.abbr = string.sub(vim_item.abbr, 1, maxwidth) + return vim_item + end, + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + -- { name = 'cmp_tabnine' }, + }, } -- Gitsigns require('gitsigns').setup { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - } + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + } } require('lualine').setup { - options = { - icons_enabled = true, - }, - sections = { - lualine_a = { 'mode' }, - lualine_b = { 'branch', 'diff', 'diagnostics' }, - lualine_c = { - { 'filename', - file_status = true, - newfile_status = false, - path = 1, - symbols = { - modified = '[+]', - readonly = '[-]', - unnamed = '[Unnamed]', - newfile = '[New]', - }, - }, + options = { + icons_enabled = true, + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff', 'diagnostics' }, + lualine_c = { + { 'filename', + file_status = true, + newfile_status = false, + path = 1, + symbols = { + modified = '[+]', + readonly = '[-]', + unnamed = '[Unnamed]', + newfile = '[New]', }, - lualine_x = { 'encoding', 'fileformat', 'filetype', }, - lualine_y = { 'progress' }, - lualine_z = { 'location' }, + }, }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { { 'filename', path = 1, file_status = true, }, }, - lualine_x = { 'location' }, - lualine_y = {}, - lualine_z = {}, - } + lualine_x = { 'encoding', 'fileformat', 'filetype', }, + lualine_y = { 'progress' }, + lualine_z = { 'location' }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { { 'filename', path = 1, file_status = true, }, }, + lualine_x = { 'location' }, + lualine_y = {}, + lualine_z = {}, + } } From 0bdbb733a2384dcef82a288db7a6f20d06596b83 Mon Sep 17 00:00:00 2001 From: pegasust Date: Tue, 11 Oct 2022 17:13:07 -0700 Subject: [PATCH 28/32] add dependencies installs --- neovim/scripts/deps.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 neovim/scripts/deps.sh diff --git a/neovim/scripts/deps.sh b/neovim/scripts/deps.sh new file mode 100644 index 0000000..98017b3 --- /dev/null +++ b/neovim/scripts/deps.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# This file installs dependencies needed for the Neovim plugins +echo "Please run this in sudo mode for sudo apt* commands" + +# Pip and Python3 +PYTHON_3=${PYTHON_3:-"python3.10"} +apt install $PYTHON_3 +$PYTHON_3 -m ensurepip --upgrade +$PYTHON_3 -m pip install --upgrade pip + +# Neovim vim-plug +sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ + https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + From 52e998c85b587d83b3919b675c8887ea0a8eadc6 Mon Sep 17 00:00:00 2001 From: pegasust Date: Wed, 12 Oct 2022 17:47:16 -0700 Subject: [PATCH 29/32] remove tabnine --- neovim/init.lua | 9 ++++++--- neovim/scripts/deps.sh | 11 +++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index 79675c2..3581a84 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -101,6 +101,8 @@ Plug('tpope/vim-dispatch') -- Allows quick build/compile/test vim commands Plug('clojure-vim/vim-jack-in') -- Clojure: ":Boot", ":Clj", ":Lein" Plug('radenling/vim-dispatch-neovim') -- Add support for neovim's terminal emulator Plug('Olical/conjure') -- REPL on the source for Clojure (and other LISPs) +Plug('gennaro-tedesco/nvim-jqx') -- JSON formatter (use :Jqx*) +Plug('kylechui/nvim-surround') -- surrounds with tags/parenthesis -- UI & colorscheme Plug('gruvbox-community/gruvbox') -- theme provider @@ -276,7 +278,7 @@ require('nvim-treesitter.configs').setup { ensure_installed = { 'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css', 'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", "svelte", "astro", - "clojure", "fennel" + "clojure", "fennel", "bash" }, sync_install = false, highlight = { enable = true }, @@ -365,7 +367,6 @@ require('neogit').setup {} remap('n', 'gs', function() require('neogit').open({}) end); -- LSP settings -require('nvim-lsp-installer').setup {} -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_client, bufnr) -- NOTE: Remember that lua is a real programming language, and as such it is possible @@ -422,7 +423,7 @@ local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protoco -- }) -- default language servers local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals', - 'rnix', 'eslint', 'terraform-ls', 'tflint', 'svelte', 'astro', 'clojure_lsp' } + 'rnix', 'eslint', 'terraform-ls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls" } require("mason").setup({ ui = { icons = { @@ -644,3 +645,5 @@ require('lualine').setup { lualine_z = {}, } } + +require('nvim-surround').setup {} diff --git a/neovim/scripts/deps.sh b/neovim/scripts/deps.sh index 98017b3..7a39f30 100644 --- a/neovim/scripts/deps.sh +++ b/neovim/scripts/deps.sh @@ -4,12 +4,15 @@ echo "Please run this in sudo mode for sudo apt* commands" # Pip and Python3 -PYTHON_3=${PYTHON_3:-"python3.10"} -apt install $PYTHON_3 -$PYTHON_3 -m ensurepip --upgrade -$PYTHON_3 -m pip install --upgrade pip +if [ ! python3 --version ] ; then + PYTHON_3=${PYTHON_3:-"python3.10"} + apt install $PYTHON_3 + $PYTHON_3 -m ensurepip --upgrade + $PYTHON_3 -m pip install --upgrade pip +fi # Neovim vim-plug sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + From d8e9004a8e8d39b4313469d45697034079c54654 Mon Sep 17 00:00:00 2001 From: pegasust Date: Wed, 26 Oct 2022 05:09:47 -0700 Subject: [PATCH 30/32] remove conjure mapping on doc_word and add inlay hints for rust-analyzer --- neovim/init.lua | 894 +++++++++++++++++++++++++++++------------------- 1 file changed, 549 insertions(+), 345 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index 3581a84..49ffd95 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -74,7 +74,7 @@ Plug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighti Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects Plug('nvim-telescope/telescope.nvim', { tag = '0.1.0' }) -- file browser Plug('nvim-telescope/telescope-fzf-native.nvim', - { ['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build' }) + { ['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build' }) Plug('nvim-telescope/telescope-file-browser.nvim') -- cmp: auto-complete/suggestions @@ -103,6 +103,7 @@ Plug('radenling/vim-dispatch-neovim') -- Add support for neovim's terminal emula Plug('Olical/conjure') -- REPL on the source for Clojure (and other LISPs) Plug('gennaro-tedesco/nvim-jqx') -- JSON formatter (use :Jqx*) Plug('kylechui/nvim-surround') -- surrounds with tags/parenthesis +Plug('simrat39/rust-tools.nvim') -- config rust-analyzer and nvim integration -- UI & colorscheme Plug('gruvbox-community/gruvbox') -- theme provider @@ -126,13 +127,13 @@ vim.call('plug#end') vim.cmd([[ colorscheme gruvbox ]]) require('hlargs').setup() require('shade').setup { - overlay_opacity = 60, - opacity_step = 1, - keys = { - brightness_up = '', - brightness_down = '', - toggle = 's', -- s: sha - } + overlay_opacity = 60, + opacity_step = 1, + keys = { + brightness_up = '', + brightness_down = '', + toggle = 's', -- s: sha + } } require('nvim-web-devicons').setup() require('trouble').setup() @@ -141,8 +142,8 @@ require('todo-comments').setup() -- plugin keymaps local function remap(mode, key_cmd, binded_fn, opts) - opts = opts or { remap = true } - return vim.keymap.set(mode, key_cmd, binded_fn, opts) + opts = opts or { remap = true } + return vim.keymap.set(mode, key_cmd, binded_fn, opts) end -- Comment.nvim @@ -153,74 +154,74 @@ vim.opt.listchars:append "space:⋅" vim.opt.listchars:append "eol:↴" require("indent_blankline").setup { - show_end_of_line = true, - space_char_blankline = " ", + show_end_of_line = true, + space_char_blankline = " ", } -- User command that transform into 2-spaces by translating to tabstop vim.api.nvim_create_user_command( - 'HalfSpaces', - function(opts) - vim.api.nvim_command("set ts=2 sts=2 noet") - vim.api.nvim_command("retab!") - vim.api.nvim_command("set ts=1 sts=1 et") - vim.api.nvim_command("retab") - vim.api.nvim_command("GuessIndent") - end, - { nargs = 0 } + 'HalfSpaces', + function(opts) + vim.api.nvim_command("set ts=2 sts=2 noet") + vim.api.nvim_command("retab!") + vim.api.nvim_command("set ts=1 sts=1 et") + vim.api.nvim_command("retab") + vim.api.nvim_command("GuessIndent") + end, + { nargs = 0 } ) vim.api.nvim_create_user_command( - 'DoubleSpaces', - function(opts) - vim.api.nvim_command("set ts=1 sts=1 noet") - vim.api.nvim_command("retab!") - vim.api.nvim_command("set ts=2 sts=2 et") - vim.api.nvim_command("retab") - vim.api.nvim_command("GuessIndent") - end, - { nargs = 0 } + 'DoubleSpaces', + function(opts) + vim.api.nvim_command("set ts=1 sts=1 noet") + vim.api.nvim_command("retab!") + vim.api.nvim_command("set ts=2 sts=2 et") + vim.api.nvim_command("retab") + vim.api.nvim_command("GuessIndent") + end, + { nargs = 0 } ) -- telescope local fb_actions = require "telescope".extensions.file_browser.actions require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, }, - }, - extensions = { - fzf = { - fuzzy = true, -- allow fuzzy matches - override_generic_sorter = true, - override_file_sorter = true, - case_mode = 'smart_case' - }, - file_browser = { - theme = "ivy", - hiject_netrw = true, -- disables netrw and use file-browser instead - mappings = { - ["i"] = {}, -- disable any shortcut in insert mode for now - ["n"] = { - ["c"] = fb_actions.create, - ["r"] = fb_actions.rename, - ["m"] = fb_actions.move, - ["y"] = fb_actions.copy, - ["d"] = fb_actions.remove, - ["o"] = fb_actions.open, - ["g"] = fb_actions.goto_parent_dir, - ["e"] = fb_actions.goto_home_dir, - ["w"] = fb_actions.goto_cwd, - ["t"] = fb_actions.change_cwd, - ["f"] = fb_actions.toggle_browser, - ["h"] = fb_actions.toggle_hidden, - ["s"] = fb_actions.toggle_all, + extensions = { + fzf = { + fuzzy = true, -- allow fuzzy matches + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case' + }, + file_browser = { + theme = "ivy", + hiject_netrw = true, -- disables netrw and use file-browser instead + mappings = { + ["i"] = {}, -- disable any shortcut in insert mode for now + ["n"] = { + ["c"] = fb_actions.create, + ["r"] = fb_actions.rename, + ["m"] = fb_actions.move, + ["y"] = fb_actions.copy, + ["d"] = fb_actions.remove, + ["o"] = fb_actions.open, + ["g"] = fb_actions.goto_parent_dir, + ["e"] = fb_actions.goto_home_dir, + ["w"] = fb_actions.goto_cwd, + ["t"] = fb_actions.change_cwd, + ["f"] = fb_actions.toggle_browser, + ["h"] = fb_actions.toggle_hidden, + ["s"] = fb_actions.toggle_all, + } + } } - } } - } } -- Telescope key remap stuffs @@ -229,89 +230,89 @@ pcall(require('telescope').load_extension, 'file_browser') remap('n', '', 'Telescope', { desc = 'Open Telescope general search' }) remap('n', 'fm', function() - require("telescope").extensions.file_browser.file_browser() + require("telescope").extensions.file_browser.file_browser() end, { desc = '[F]ile [M]utation' }) remap('n', 'ff', function() - require('telescope.builtin').find_files({ - hidden = false, - no_ignore = false, - follow = false, - }) + require('telescope.builtin').find_files({ + hidden = false, + no_ignore = false, + follow = false, + }) end, { desc = '[F]ind [F]ile' }) remap('n', 'fa', function() - require('telescope.builtin').find_files({ - hidden = true, - no_ignore = true, - follow = true, - }) + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = true, + follow = true, + }) end, { desc = '[F]ind [A]ll files' }) remap('n', 'fg', function() - require('telescope.builtin').live_grep() + require('telescope.builtin').live_grep() end, { desc = '[F]ind by [G]rep' }) remap('n', 'fb', function() - require('telescope.builtin').buffers() + require('telescope.builtin').buffers() end, { desc = '[F]ind existing [B]uffers' }) remap('n', 'fh', function() - require('telescope.builtin').help_tags() + require('telescope.builtin').help_tags() end, { desc = '[F]ind [H]elp' }) remap('n', 'fd', function() - require('telescope.builtin').diagnostics() + require('telescope.builtin').diagnostics() end, { desc = '[F]ind [D]iagnostics' }) -- ZK remap stuffs remap('n', 'zf', function() - vim.cmd([[:ZkNotes]]) + vim.cmd([[:ZkNotes]]) end, { desc = '[Z]ettelkasten [F]iles' }) remap('n', 'zg', function() - vim.cmd([[:ZkGrep]]) + vim.cmd([[:ZkGrep]]) end, { desc = '[Z]ettelkasten [G]rep' }) -- treesitter require('nvim-treesitter.configs').setup { - ensure_installed = { - 'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css', - 'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", "svelte", "astro", - "clojure", "fennel", "bash" - }, - sync_install = false, - highlight = { enable = true }, - indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - node_decremental = '', - scope_incremental = '' - } - }, - textobjects = { - select = { - enable = true, - lookahead = true, - keymaps = { - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, + ensure_installed = { + 'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css', + 'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", "svelte", "astro", + "clojure", "fennel", "bash" + }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + node_decremental = '', + scope_incremental = '' + } + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + }, + -- automatically close and modify HTML and TSX tags + autotag = { + enable = true, }, - }, - -- automatically close and modify HTML and TSX tags - autotag = { - enable = true, - }, } require('nvim-autopairs').setup { - check_ts = true, + check_ts = true, } @@ -321,26 +322,26 @@ parser_config.astro.filetype_to_parsername = { "javascript", "typescript.tsx", " require('guess-indent').setup { - auto_cmd = true, -- Set to false to disable automatic execution - filetype_exclude = { -- A list of filetypes for which the auto command gets disabled - "netrw", - "tutor", - }, - buftype_exclude = { -- A list of buffer types for which the auto command gets disabled - "help", - "nofile", - "terminal", - -- "prompt", - }, + auto_cmd = true, -- Set to false to disable automatic execution + filetype_exclude = { -- A list of filetypes for which the auto command gets disabled + "netrw", + "tutor", + }, + buftype_exclude = { -- A list of buffer types for which the auto command gets disabled + "help", + "nofile", + "terminal", + -- "prompt", + }, } -- harpoon: mark significant files & switch between them remap('n', 'm', function() require('harpoon.mark').add_file() end) local function harpoon_nav(key, nav_file_index, lead_keybind) - lead_keybind = lead_keybind or 'h' - assert(type(key) == "string", "expect key to be string(keybind)") - assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index") - return remap('n', lead_keybind .. key, function() require('harpoon.ui').nav_file(nav_file_index) end) + lead_keybind = lead_keybind or 'h' + assert(type(key) == "string", "expect key to be string(keybind)") + assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index") + return remap('n', lead_keybind .. key, function() require('harpoon.ui').nav_file(nav_file_index) end) end -- remap letters to index. Inspired by alternating number of Dvorak programmer @@ -369,44 +370,44 @@ remap('n', 'gs', function() require('neogit').open({}) end); -- LSP settings -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_client, bufnr) - -- NOTE: Remember that lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself - -- many times. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local nmap = function(keys, func, desc) - if desc then - desc = 'LSP: ' .. desc + -- NOTE: Remember that lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself + -- many times. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc }) end - vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc }) - end + nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + nmap('df', function() vim.lsp.buf.format({ async = true }) end, '[D]ocument [F]ormat') - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - nmap('df', function() vim.lsp.buf.format({ async = true }) end, '[D]ocument [F]ormat') + -- symbols and gotos + nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation') + nmap('gr', require('telescope.builtin').lsp_references) + nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - -- symbols and gotos - nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') - nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation') - nmap('gr', require('telescope.builtin').lsp_references) - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + -- documentations. See `:help K` for why this keymap + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') - -- documentations. See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') - - -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') - nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, '[W]orkspace [L]ist Folders') + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') + nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, '[W]orkspace [L]ist Folders') end -- nvim-cmp supports additional completion capabilities @@ -423,92 +424,291 @@ local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protoco -- }) -- default language servers local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals', - 'rnix', 'eslint', 'terraform-ls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls" } + 'rnix', 'eslint', 'terraform-ls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls", 'yamlls' } require("mason").setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - }, - check_outdated_packages_on_open = true, - } + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + }, + check_outdated_packages_on_open = true, + } }) require('mason-lspconfig').setup({ - ensure_installed = servers, - automatic_installation = true + ensure_installed = servers, + automatic_installation = true }) require('mason-lspconfig').setup_handlers({ - -- default handler - function(server_name) - require('lspconfig')[server_name].setup { - on_attach = on_attach, - capabilities = capabilities, - } - end, - ["sumneko_lua"] = function() - require('lspconfig').sumneko_lua.setup { - on_attach = on_attach, - capabilities = capabilities, - settings = { - Lua = { - runtime = { - version = "LuaJIT", - path = vim.split(package.path, ";"), - }, - diagnostics = { - globals = { "vim" } - }, - workspace = { - library = vim.api.nvim_get_runtime_file('', true) - }, - telemetry = { enable = false }, - format = { - enable = true, - defaultConfig = { - indent_style = "space", - indent_size = 2, - } - } + -- default handler + function(server_name) + require('lspconfig')[server_name].setup { + on_attach = on_attach, + capabilities = capabilities, } - } - } - end, - -- ["astro"] = function() - -- print('configuring astro') - -- require('lspconfig').astro.setup { - -- on_attach = on_attach, - -- capabilities = capabilities, - -- init_options = { - -- configuration = {}, - -- typescript = { - -- serverPath = data_dir - -- } - -- } - -- } - -- end + end, + ["sumneko_lua"] = function() + require('lspconfig').sumneko_lua.setup { + on_attach = on_attach, + capabilities = capabilities, + settings = { + Lua = { + runtime = { + version = "LuaJIT", + path = vim.split(package.path, ";"), + }, + diagnostics = { + globals = { "vim" } + }, + workspace = { + library = vim.api.nvim_get_runtime_file('', true) + }, + telemetry = { enable = false }, + format = { + enable = true, + defaultConfig = { + indent_style = "space", + indent_size = 2, + } + } + } + } + } + end, + -- ["rust_analyzer"] = function() + -- require('lspconfig').rust_analyzer.setup { + -- on_attach = on_attach, + -- capabilities = capabilities, + -- settings = { + -- checkOnSave = { + -- command = "clippy", + -- } + -- } + -- } + -- end, + -- ["astro"] = function() + -- print('configuring astro') + -- require('lspconfig').astro.setup { + -- on_attach = on_attach, + -- capabilities = capabilities, + -- init_options = { + -- configuration = {}, + -- typescript = { + -- serverPath = data_dir + -- } + -- } + -- } + -- end }) +require("rust-tools").setup { + tools = { -- rust-tools options + + -- how to execute terminal commands + -- options right now: termopen / quickfix + executor = require("rust-tools/executors").termopen, + + -- callback to execute once rust-analyzer is done initializing the workspace + -- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error" + on_initialized = nil, + + -- automatically call RustReloadWorkspace when writing to a Cargo.toml file. + reload_workspace_from_cargo_toml = true, + + -- These apply to the default RustSetInlayHints command + inlay_hints = { + -- automatically set inlay hints (type hints) + -- default: true + auto = true, + + -- Only show inlay hints for the current line + only_current_line = false, + + -- whether to show parameter hints with the inlay hints or not + -- default: true + show_parameter_hints = true, + + -- prefix for parameter hints + -- default: "<-" + parameter_hints_prefix = "<- ", + + -- prefix for all the other hints (type, chaining) + -- default: "=>" + other_hints_prefix = "=> ", + + -- whether to align to the length of the longest line in the file + max_len_align = false, + + -- padding from the left if max_len_align is true + max_len_align_padding = 1, + + -- whether to align to the extreme right or not + right_align = false, + + -- padding from the right if right_align is true + right_align_padding = 7, + + -- The color of the hints + highlight = "Comment", + }, + + -- options same as lsp hover / vim.lsp.util.open_floating_preview() + hover_actions = { + + -- the border that is used for the hover window + -- see vim.api.nvim_open_win() + border = { + { "╭", "FloatBorder" }, + { "─", "FloatBorder" }, + { "╮", "FloatBorder" }, + { "│", "FloatBorder" }, + { "╯", "FloatBorder" }, + { "─", "FloatBorder" }, + { "╰", "FloatBorder" }, + { "│", "FloatBorder" }, + }, + + -- whether the hover action window gets automatically focused + -- default: false + auto_focus = false, + }, + + -- settings for showing the crate graph based on graphviz and the dot + -- command + crate_graph = { + -- Backend used for displaying the graph + -- see: https://graphviz.org/docs/outputs/ + -- default: x11 + backend = "x11", + -- where to store the output, nil for no output stored (relative + -- path from pwd) + -- default: nil + output = nil, + -- true for all crates.io and external crates, false only the local + -- crates + -- default: true + full = true, + + -- List of backends found on: https://graphviz.org/docs/outputs/ + -- Is used for input validation and autocompletion + -- Last updated: 2021-08-26 + enabled_graphviz_backends = { + "bmp", + "cgimage", + "canon", + "dot", + "gv", + "xdot", + "xdot1.2", + "xdot1.4", + "eps", + "exr", + "fig", + "gd", + "gd2", + "gif", + "gtk", + "ico", + "cmap", + "ismap", + "imap", + "cmapx", + "imap_np", + "cmapx_np", + "jpg", + "jpeg", + "jpe", + "jp2", + "json", + "json0", + "dot_json", + "xdot_json", + "pdf", + "pic", + "pct", + "pict", + "plain", + "plain-ext", + "png", + "pov", + "ps", + "ps2", + "psd", + "sgi", + "svg", + "svgz", + "tga", + "tiff", + "tif", + "tk", + "vml", + "vmlz", + "wbmp", + "webp", + "xlib", + "x11", + }, + }, + }, + + -- all the opts to send to nvim-lspconfig + -- these override the defaults set by rust-tools.nvim + -- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer + server = { + -- standalone file support + -- setting it to false may improve startup time + standalone = true, + on_attach = function(client, bufnr) + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc }) + end + on_attach(client, bufnr); + nmap('K', require'rust-tools'.hover_actions.hover_actions, 'Hover Documentation') + + end, + capabilities = capabilities, + settings = { + checkOnSave = { + command = "clippy", + } + } + + }, -- rust-analyzer options + + -- debugging stuff + dap = { + adapter = { + type = "executable", + command = "lldb-vscode", + name = "rt_lldb", + }, + }, +} + require('zk').setup({ - picker = "telescope", - lsp = { - config = { - cmd = { "zk", "lsp" }, - name = "zk", - on_attach = on_attach, + picker = "telescope", + lsp = { + config = { + cmd = { "zk", "lsp" }, + name = "zk", + on_attach = on_attach, + }, + auto_attach = { + enable = true, + filetypes = { "markdown" } + }, }, - auto_attach = { - enable = true, - filetypes = { "markdown" } - }, - }, }) -- Custom ZkOrphans that determines unlinked notes -- `:ZkOrphans {tags = {"work"}}` require('zk.commands').add("ZkOrphans", function(options) - options = vim.tbl_extend("force", { orphan = true }, options or {}) - -- zk.edit opens notes picker - require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" }) + options = vim.tbl_extend("force", { orphan = true }, options or {}) + -- zk.edit opens notes picker + require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" }) end) -- ZkGrep: opens file picker -- In the case where `match_ctor` is falsy, create a prompt. @@ -516,18 +716,18 @@ end) -- Params: -- match_ctor: string | {match= :string,...} | "" | nil require('zk.commands').add("ZkGrep", function(match_ctor) - -- handle polymorphic `match_ctor` - local grep_str = match_ctor - local match - if match_ctor == nil or match_ctor == '' then - vim.fn.inputsave() - grep_str = vim.fn.input('Grep string: >') - vim.fn.inputrestore() - match = { match = grep_str } - elseif type(match_ctor) == 'string' then - match = { match = grep_str } - end - require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'" }) + -- handle polymorphic `match_ctor` + local grep_str = match_ctor + local match + if match_ctor == nil or match_ctor == '' then + vim.fn.inputsave() + grep_str = vim.fn.input('Grep string: >') + vim.fn.inputrestore() + match = { match = grep_str } + elseif type(match_ctor) == 'string' then + match = { match = grep_str } + end + require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'" }) end) -- nvim-cmp @@ -535,115 +735,119 @@ local cmp = require 'cmp' local luasnip = require 'luasnip' local lspkind = require('lspkind') local source_mapping = { - buffer = '[Buffer]', - nvim_lsp = '[LSP]', - nvim_lua = '[Lua]', - -- cmp_tabnine = '[T9]', - path = '[Path]', + buffer = '[Buffer]', + nvim_lsp = '[LSP]', + nvim_lua = '[Lua]', + -- cmp_tabnine = '[T9]', + path = '[Path]', } cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + formatting = { + format = function(entry, vim_item) + vim_item.kind = lspkind.symbolic(vim_item.kind, { mode = 'symbol' }) + vim_item.menu = source_mapping[entry.source_name] + -- if entry.source.name == "cmp_tabnine" then + -- local detail = (entry.completion_item.data or {}).detail + -- vim_item.kind = "" + -- if detail and detail:find('.*%%.*') then + -- vim_item.kind = vim_item.kind .. ' ' .. detail + -- end + -- + -- if (entry.completion_item.data or {}).multiline then + -- vim_item.kind = vim_item.kind .. ' ' .. '[ML]' + -- end + -- end + local maxwidth = 80 + vim_item.abbr = string.sub(vim_item.abbr, 1, maxwidth) + return vim_item + end, + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + -- { name = 'cmp_tabnine' }, }, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }), - }, - formatting = { - format = function(entry, vim_item) - vim_item.kind = lspkind.symbolic(vim_item.kind, { mode = 'symbol' }) - vim_item.menu = source_mapping[entry.source_name] - -- if entry.source.name == "cmp_tabnine" then - -- local detail = (entry.completion_item.data or {}).detail - -- vim_item.kind = "" - -- if detail and detail:find('.*%%.*') then - -- vim_item.kind = vim_item.kind .. ' ' .. detail - -- end - -- - -- if (entry.completion_item.data or {}).multiline then - -- vim_item.kind = vim_item.kind .. ' ' .. '[ML]' - -- end - -- end - local maxwidth = 80 - vim_item.abbr = string.sub(vim_item.abbr, 1, maxwidth) - return vim_item - end, - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - -- { name = 'cmp_tabnine' }, - }, } -- Gitsigns require('gitsigns').setup { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - } + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + } } require('lualine').setup { - options = { - icons_enabled = true, - }, - sections = { - lualine_a = { 'mode' }, - lualine_b = { 'branch', 'diff', 'diagnostics' }, - lualine_c = { - { 'filename', - file_status = true, - newfile_status = false, - path = 1, - symbols = { - modified = '[+]', - readonly = '[-]', - unnamed = '[Unnamed]', - newfile = '[New]', - }, - }, + options = { + icons_enabled = true, }, - lualine_x = { 'encoding', 'fileformat', 'filetype', }, - lualine_y = { 'progress' }, - lualine_z = { 'location' }, - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { { 'filename', path = 1, file_status = true, }, }, - lualine_x = { 'location' }, - lualine_y = {}, - lualine_z = {}, - } + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff', 'diagnostics' }, + lualine_c = { + { 'filename', + file_status = true, + newfile_status = false, + path = 1, + symbols = { + modified = '[+]', + readonly = '[-]', + unnamed = '[Unnamed]', + newfile = '[New]', + }, + }, + }, + lualine_x = { 'encoding', 'fileformat', 'filetype', }, + lualine_y = { 'progress' }, + lualine_z = { 'location' }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { { 'filename', path = 1, file_status = true, }, }, + lualine_x = { 'location' }, + lualine_y = {}, + lualine_z = {}, + } } require('nvim-surround').setup {} + +vim.cmd([[ +let g:conjure#mapping#doc_word = v:false +]]) From 3afa514e6c5810c385b4879b5939d064cf7654f5 Mon Sep 17 00:00:00 2001 From: pegasust Date: Wed, 2 Nov 2022 11:30:40 -0700 Subject: [PATCH 31/32] update_capabilities deprecate, terraformls --- neovim/init.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index 49ffd95..9571296 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -83,6 +83,7 @@ Plug('hrsh7th/cmp-nvim-lsp') Plug('hrsh7th/cmp-buffer') Plug('hrsh7th/nvim-cmp') Plug('onsails/lspkind-nvim') +Plug('yioneko/nvim-yati') -- hopefully fixes Python indentation auto-correct from Tree-sitter -- Plug('tzachar/cmp-tabnine', { ['do'] = './install.sh' }) -- DevExp @@ -276,6 +277,7 @@ end, { desc = '[Z]ettelkasten [G]rep' }) -- treesitter require('nvim-treesitter.configs').setup { + yati = { enable = true }, ensure_installed = { 'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css', 'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", "svelte", "astro", @@ -283,7 +285,7 @@ require('nvim-treesitter.configs').setup { }, sync_install = false, highlight = { enable = true }, - indent = { enable = true }, + indent = { enable = true, disabled = { "python" } }, incremental_selection = { enable = true, keymaps = { @@ -411,7 +413,7 @@ local on_attach = function(_client, bufnr) end -- nvim-cmp supports additional completion capabilities -local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) +local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) -- local tabnine = require('cmp_tabnine.config') -- tabnine.setup({ -- max_lines = 1000, @@ -424,7 +426,7 @@ local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protoco -- }) -- default language servers local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals', - 'rnix', 'eslint', 'terraform-ls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls", 'yamlls' } + 'rnix', 'eslint', 'terraformls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls", 'yamlls' } require("mason").setup({ ui = { icons = { @@ -666,7 +668,7 @@ require("rust-tools").setup { vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc }) end on_attach(client, bufnr); - nmap('K', require'rust-tools'.hover_actions.hover_actions, 'Hover Documentation') + nmap('K', require 'rust-tools'.hover_actions.hover_actions, 'Hover Documentation') end, capabilities = capabilities, From 72a39a056904218f75e7d80e5df25451f5ca714f Mon Sep 17 00:00:00 2001 From: pegasust Date: Thu, 3 Nov 2022 08:28:49 -0700 Subject: [PATCH 32/32] properly add pylsp --- neovim/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/neovim/init.lua b/neovim/init.lua index 9571296..e6aa1b9 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -404,6 +404,7 @@ local on_attach = function(_client, bufnr) -- Lesser used LSP functionality nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('gtd', vim.lsp.buf.type_definition, '[G]oto [T]ype [D]efinition') nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') @@ -426,7 +427,7 @@ local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protoc -- }) -- default language servers local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals', - 'rnix', 'eslint', 'terraformls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls", 'yamlls' } + 'rnix', 'eslint', 'terraformls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls", 'yamlls', "pylsp" } require("mason").setup({ ui = { icons = {