From 75c078c8fc7dcb8d58acdb6c8a082818c4828e58 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 20 Feb 2022 12:10:47 +0100 Subject: [PATCH 01/33] feat: add packer package manager --- init.lua | 1 + lua/plugins.lua | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 init.lua create mode 100644 lua/plugins.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..92cf997 --- /dev/null +++ b/init.lua @@ -0,0 +1 @@ +require('plugins') diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..b443d70 --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,28 @@ +local fn = vim.fn +local cmd = vim.cmd + +-- Boostrap Packer +local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' +local packer_bootstrap +if fn.empty(fn.glob(install_path)) > 0 then + packer_bootstrap = fn.system({'git', 'clone','https://github.com/wbthomason/packer.nvim', install_path}) +end + +-- Rerun PackerSync everytime plugins.lua is updated +cmd([[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins.lua source | PackerSync + augroup end +]]) + +-- Initialize pluggins +return require('packer').startup(function(use) + -- Let Packer manage itself + use('wbthomason/packer.nvim') + + if packer_bootstrap then + require('packer').sync() + end +end) + From f1bc810412fea1646b84364a0abd1c6533736a2c Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 20 Feb 2022 12:11:20 +0100 Subject: [PATCH 02/33] feat: add vim-fugitive --- lua/plugins.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index b443d70..ff2d988 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -21,6 +21,9 @@ return require('packer').startup(function(use) -- Let Packer manage itself use('wbthomason/packer.nvim') + -- git commands + use('tpope/vim-fugitive') + if packer_bootstrap then require('packer').sync() end From 99aba01d7928f8e6e66fa1a68834e442581ae182 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 20 Feb 2022 12:25:12 +0100 Subject: [PATCH 03/33] feat: add solarized dark theme --- init.lua | 1 + lua/plugins.lua | 3 +++ lua/themes.lua | 10 ++++++++++ 3 files changed, 14 insertions(+) create mode 100644 lua/themes.lua diff --git a/init.lua b/init.lua index 92cf997..12e5c9c 100644 --- a/init.lua +++ b/init.lua @@ -1 +1,2 @@ require('plugins') +require('themes') diff --git a/lua/plugins.lua b/lua/plugins.lua index ff2d988..785c34a 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -21,6 +21,9 @@ return require('packer').startup(function(use) -- Let Packer manage itself use('wbthomason/packer.nvim') + -- Themes + use('altercation/vim-colors-solarized') + -- git commands use('tpope/vim-fugitive') diff --git a/lua/themes.lua b/lua/themes.lua new file mode 100644 index 0000000..676b966 --- /dev/null +++ b/lua/themes.lua @@ -0,0 +1,10 @@ +-- source file everytime it changes +vim.cmd([[ + augroup user_theme_config + autocmd! + autocmd BufWritePost themes.lua source + augroup end +]]) + +vim.cmd [[colorscheme solarized]] +vim.opt.background = 'dark' From e31e91a2c2c237719bc45e32ccad90b3488280b6 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 20 Feb 2022 13:08:57 +0100 Subject: [PATCH 04/33] feat: add session handling --- lua/plugins.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index 785c34a..d928db8 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -24,6 +24,10 @@ return require('packer').startup(function(use) -- Themes use('altercation/vim-colors-solarized') + -- session handling + use('tpope/vim-obsession') + use('dhruvasagar/vim-prosession') + -- git commands use('tpope/vim-fugitive') From 55671536735fc19a392f6c3b7a88f499abe1803a Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 20 Feb 2022 13:09:12 +0100 Subject: [PATCH 05/33] feat: enabled line numbers --- init.lua | 1 + lua/settings.lua | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 lua/settings.lua diff --git a/init.lua b/init.lua index 12e5c9c..eb5fb3b 100644 --- a/init.lua +++ b/init.lua @@ -1,2 +1,3 @@ +require('settings') require('plugins') require('themes') diff --git a/lua/settings.lua b/lua/settings.lua new file mode 100644 index 0000000..b6a4fc7 --- /dev/null +++ b/lua/settings.lua @@ -0,0 +1,9 @@ +-- source file everytime it changes +vim.cmd([[ + augroup user_settings + autocmd! + autocmd BufWritePost settings.lua source + augroup end +]]) + +vim.opt.number = true From 5855d9e9ad2f79d593d97d77909067e3db54b406 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 20 Feb 2022 13:19:04 +0100 Subject: [PATCH 06/33] feat: add statusline --- lua/plugins.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index d928db8..c2f516e 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -28,6 +28,15 @@ return require('packer').startup(function(use) use('tpope/vim-obsession') use('dhruvasagar/vim-prosession') + -- status line + use { + 'nvim-lualine/lualine.nvim', + requires = { 'kyazdani42/nvim-web-devicons', opt = true }, + config = function() + require('lualine').setup() + end + } + -- git commands use('tpope/vim-fugitive') From e35c5139acf88a14bbb3dc6c95237e96847abb98 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 20 Feb 2022 20:06:27 +0100 Subject: [PATCH 07/33] feat: show git-signs --- lua/plugins.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index c2f516e..7cbd13c 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -39,6 +39,11 @@ return require('packer').startup(function(use) -- git commands use('tpope/vim-fugitive') + use ({ + 'lewis6991/gitsigns.nvim', + requires = {'nvim-lua/plenary.nvim'}, + config = function() require('gitsigns').setup() end + }) if packer_bootstrap then require('packer').sync() From c11511d34ed4cb89327e7645a1a31d68b5e4b745 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 20 Feb 2022 20:08:17 +0100 Subject: [PATCH 08/33] feat: show indent lines --- lua/plugins.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index 7cbd13c..d7a4dca 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -38,6 +38,16 @@ return require('packer').startup(function(use) } -- git commands + use({ + "lukas-reineke/indent-blankline.nvim", + config = function () + require("indent_blankline").setup { + char = "┊", + buftype_exclude = {"terminal", "help"} + } + end + }) + use('tpope/vim-fugitive') use ({ 'lewis6991/gitsigns.nvim', From 0f42b82bc275d101a9788a68067420823349e3df Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 20 Feb 2022 20:08:36 +0100 Subject: [PATCH 09/33] feat: add autocompletion --- init.lua | 2 ++ lua/plugins.lua | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/init.lua b/init.lua index eb5fb3b..3518476 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,5 @@ require('settings') require('plugins') require('themes') + +vim.cmd('COQnow -s') diff --git a/lua/plugins.lua b/lua/plugins.lua index d7a4dca..6a1de77 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -48,6 +48,13 @@ return require('packer').startup(function(use) end }) + -- autocompletion + use({ + "ms-jpq/coq_nvim", + branch="coq", + }) + use({'ms-jpq/coq.artifacts', branch = 'artifacts'}) + use('tpope/vim-fugitive') use ({ 'lewis6991/gitsigns.nvim', From 28057baf5f184e0f642233a2876173d33b121d69 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 20 Feb 2022 20:09:42 +0100 Subject: [PATCH 10/33] feat: use language-servers --- lua/plugins.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index 6a1de77..fda895d 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -48,6 +48,9 @@ return require('packer').startup(function(use) end }) + -- language server + use("neovim/nvim-lspconfig") + -- autocompletion use({ "ms-jpq/coq_nvim", @@ -55,6 +58,11 @@ return require('packer').startup(function(use) }) use({'ms-jpq/coq.artifacts', branch = 'artifacts'}) + local language_servers = { "bashls", "rls", "sumneko_lua" } + for _, server in pairs(language_servers) do + require("lspconfig")[server].setup(require("coq").lsp_ensure_capabilities({})) + end + use('tpope/vim-fugitive') use ({ 'lewis6991/gitsigns.nvim', From c3416367294158095d539b436c9fa7b100ca0047 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Mon, 21 Feb 2022 15:15:15 +0100 Subject: [PATCH 11/33] feat: finalized config --- .gitignore | 1 + init.lua | 5 +- lua/keymaps.lua | 32 ++++++++ lua/options.lua | 46 +++++++++++ lua/plugins.lua | 156 ++++++++++++++++++++++++------------- lua/plugins/bufferline.lua | 19 +++++ lua/plugins/lspconfig.lua | 97 +++++++++++++++++++++++ lua/plugins/telescope.lua | 12 +++ lua/plugins/treesitter.lua | 21 +++++ lua/settings.lua | 9 --- lua/themes.lua | 2 +- 11 files changed, 333 insertions(+), 67 deletions(-) create mode 100644 .gitignore create mode 100644 lua/keymaps.lua create mode 100644 lua/options.lua create mode 100644 lua/plugins/bufferline.lua create mode 100644 lua/plugins/lspconfig.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/treesitter.lua delete mode 100644 lua/settings.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..87553b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/plugin/ diff --git a/init.lua b/init.lua index 3518476..49b81ae 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,4 @@ -require('settings') +require("keymaps") +require('options') require('plugins') require('themes') - -vim.cmd('COQnow -s') diff --git a/lua/keymaps.lua b/lua/keymaps.lua new file mode 100644 index 0000000..4529acc --- /dev/null +++ b/lua/keymaps.lua @@ -0,0 +1,32 @@ +-- source file everytime it changes +vim.cmd([[ + augroup user_keymaps + autocmd! + autocmd BufWritePost keymaps.lua source + augroup end +]]) + +local function nnoremap(key, command) + vim.api.nvim_set_keymap("n",key,command, { noremap = true, silent = true }) +end + +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +-- Move around windows +nnoremap("", "h") +nnoremap("", "j") +nnoremap("", "k") +nnoremap("", "l") + +-- Switch buffers +nnoremap("", ":TablineBufferNext") +nnoremap("", ":TablineBufferPrevious") + +-- fugitive +nnoremap("G", ":tab G") + +-- telescope +nnoremap("ff", "Telescope find_files theme=dropdown") +nnoremap("fb", "Telescope buffers theme=dropdown") +nnoremap("fg", "Telescope git_files theme=dropdown") diff --git a/lua/options.lua b/lua/options.lua new file mode 100644 index 0000000..7c442f9 --- /dev/null +++ b/lua/options.lua @@ -0,0 +1,46 @@ +-- source file everytime it changes +vim.cmd([[ + augroup user_options + autocmd! + autocmd BufWritePost options.lua source + augroup end +]]) + +-- termguicolors +vim.opt.termguicolors = true + +-- line numbers +vim.opt.number = true + +-- tabwidth +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 + +-- indent with spaces +vim.opt.expandtab = true + +-- scroll offset +vim.opt.scrolloff = 4 + +-- don't warp lines +vim.opt.wrap = false + +-- split to right/below +vim.opt.splitright = true +vim.opt.splitbelow = true + +-- presistent undo +vim.opt.undofile = true + +-- searching +vim.opt.ignorecase = true +vim.opt.smartcase = true + +-- preview commands +vim.opt.inccommand = "split" + +-- enable cursorline +vim.opt.cursorline = true + +-- coq.nvim +vim.g.coq_settings = { auto_start = "shut-up" } diff --git a/lua/plugins.lua b/lua/plugins.lua index fda895d..ec54bce 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,77 +1,125 @@ local fn = vim.fn -local cmd = vim.cmd --- Boostrap Packer -local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' +-- boostrap packer +local install_path = fn.stdpath('data')..'/site/pack/packer/opt/packer.nvim' local packer_bootstrap if fn.empty(fn.glob(install_path)) > 0 then - packer_bootstrap = fn.system({'git', 'clone','https://github.com/wbthomason/packer.nvim', install_path}) + packer_bootstrap = fn.system({'git', 'clone','https://github.com/wbthomason/packer.nvim', install_path}) end --- Rerun PackerSync everytime plugins.lua is updated -cmd([[ +-- run PackerSync everytime plugins.lua is updated +vim.cmd([[ augroup packer_user_config autocmd! autocmd BufWritePost plugins.lua source | PackerSync augroup end ]]) --- Initialize pluggins +vim.cmd([[packadd packer.nvim]]) + +-- initialize plugins return require('packer').startup(function(use) - -- Let Packer manage itself - use('wbthomason/packer.nvim') + -- let packer manage itself + use({'wbthomason/packer.nvim', opt = true}) - -- Themes - use('altercation/vim-colors-solarized') + -- theme + use("ishan9299/nvim-solarized-lua") - -- session handling - use('tpope/vim-obsession') - use('dhruvasagar/vim-prosession') + -- commenting + use("tpope/vim-commentary") - -- status line - use { - 'nvim-lualine/lualine.nvim', - requires = { 'kyazdani42/nvim-web-devicons', opt = true }, - config = function() - require('lualine').setup() - end - } + -- session handling + use('tpope/vim-obsession') + use('dhruvasagar/vim-prosession') - -- git commands - use({ - "lukas-reineke/indent-blankline.nvim", - config = function () - require("indent_blankline").setup { - char = "┊", - buftype_exclude = {"terminal", "help"} - } - end - }) + -- status line + use { + 'nvim-lualine/lualine.nvim', + requires = { 'kyazdani42/nvim-web-devicons', opt = true }, + config = function() + require('lualine').setup() + end + } - -- language server - use("neovim/nvim-lspconfig") + -- tabline + use { + 'kdheepak/tabline.nvim', + config = function() + require'tabline'.setup { + enable = true, + options = { + show_filename_only = true, + } + } + end, + requires = { { 'hoob3rt/lualine.nvim' }, {'kyazdani42/nvim-web-devicons', opt = true} } + } - -- autocompletion - use({ - "ms-jpq/coq_nvim", - branch="coq", - }) - use({'ms-jpq/coq.artifacts', branch = 'artifacts'}) + -- blankline + use({ + "lukas-reineke/indent-blankline.nvim", + config = function () + require("indent_blankline").setup { + char = "┊", + buftype_exclude = {"terminal", "help"} + } + end + }) - local language_servers = { "bashls", "rls", "sumneko_lua" } - for _, server in pairs(language_servers) do - require("lspconfig")[server].setup(require("coq").lsp_ensure_capabilities({})) - end + -- git + use('tpope/vim-fugitive') + use ({ + 'lewis6991/gitsigns.nvim', + requires = {'nvim-lua/plenary.nvim'}, + config = function() require('gitsigns').setup() end + }) - use('tpope/vim-fugitive') - use ({ - 'lewis6991/gitsigns.nvim', - requires = {'nvim-lua/plenary.nvim'}, - config = function() require('gitsigns').setup() end - }) + -- autocompletion + use({ + "ms-jpq/coq_nvim", + branch="coq", + requires = { + {'ms-jpq/coq.artifacts', branch = 'artifacts'}, + }, + }) - if packer_bootstrap then - require('packer').sync() - end + -- highlight current symbol + use({ + "nvim-treesitter/nvim-treesitter-refactor", + config = function () require("nvim-treesitter.configs").setup({ + refactor = { + highlight_definitions = { + enable = true, + clear_on_cursor_move = true, + }, + } + }) + end, + }) + + -- language server + use({ + "neovim/nvim-lspconfig", + config = function() require("plugins.lspconfig") end, + }) + + use('williamboman/nvim-lsp-installer') + + -- treesitter + use({ + 'nvim-treesitter/nvim-treesitter', + config = function() require('plugins.treesitter') end, + run = ':TSUpdate' + }) + + -- Telescope + use({ + 'nvim-telescope/telescope.nvim', + requires = {{'nvim-lua/plenary.nvim'}}, + config = function() require('plugins.telescope') end, + }) + + if packer_bootstrap then + require('packer').sync() + end end) - diff --git a/lua/plugins/bufferline.lua b/lua/plugins/bufferline.lua new file mode 100644 index 0000000..6d4163d --- /dev/null +++ b/lua/plugins/bufferline.lua @@ -0,0 +1,19 @@ +require('bufferline') + +-- format as ". " +local tabname_format = function (opts) + return string.format('%s.', opts.ordinal) +end + +require('bufferline').setup({ + options = { + always_show_bufferline = true, + numbers = tabname_format, + show_buffer_icons = true, + show_buffer_close_icons = false, + show_close_icon = false, + --separator_style = 'slant', + }, + -- Don't use italic on current buffer + highlights = {buffer_selected = { gui = "bold" },}, +}) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua new file mode 100644 index 0000000..e7d575c --- /dev/null +++ b/lua/plugins/lspconfig.lua @@ -0,0 +1,97 @@ +local coq = require("coq") +local lsp_installer = require("nvim-lsp-installer") + +local nvim_runtime_path = vim.split(package.path, ';') +table.insert(nvim_runtime_path, "lua/?.lua") +table.insert(nvim_runtime_path, "lua/?/init.lua") + +local language_servers = { + "ansiblels", + "bashls", + "dockerls", + "eslint", + "html", + "pyright", + "remark_ls", + "rust_analyzer", + "sumneko_lua", + "svelte", + "taplo", + "tsserver", + "volar", +} + +for _, server_name in pairs(language_servers) do + local server_found, server = lsp_installer.get_server(server_name) + if server_found and not server:is_installed() then + print("Installing " .. server_name) + server:install() + end + +end + +local extra_server_opts = { + ["sumneko_lua"] = function(opts) + opts.settings = { + Lua = { + runtime = { + version = 'LuaJIT', + path = nvim_runtime_path, + }, + diagnostics = { + globals = {'vim'}, + }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + }, + telemetry ={ + enable = false, + }, + }, + } + end +} + +local function custom_on_attach(client, buffer_nr) + -- Helper function + local opts = {noremap = true, silent = true} + local function bufnnoremap(key, action) + vim.api.nvim_buf_set_keymap(buffer_nr, 'n', key, action, opts) + end + + -- Inspect function + bufnnoremap("K", "lua vim.lsp.buf.hover()") + + -- Rename all references of symbol + bufnnoremap("R", "lua vim.lsp.buf.rename()") + + -- Navigate diagnostics + bufnnoremap("", "lua vim.diagnostic.goto_next()") + bufnnoremap("", "lua vim.diagnostic.goto_prev()") + + -- Show line diagnostics + bufnnoremap("d", 'lua vim.diagnostic.open_float(0, {scope = "line"})') + + -- Open local diagnostics in local list + bufnnoremap("D", "lua vim.diagnostic.setloclist()") + + -- Open all project diagnostics in quickfix list + bufnnoremap("", "lua vim.diagnostic.setqflist()") + + if client.resolved_capabilities.document_formatting then + vim.cmd("autocmd BufWritePre lua vim.lsp.buf.formatting_sync()") + end +end + +lsp_installer.on_server_ready(function(server) + local opts = coq.lsp_ensure_capabilities({ + on_attach = custom_on_attach, + capabilities = vim.lsp.protocol.make_client_capabilities(), + }) + + if extra_server_opts[server.name] then + extra_server_opts[server.name](opts) + end + + server:setup(opts) +end) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..eef9e52 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,12 @@ +local actions = require("telescope.actions") + +require('telescope').setup({ + defaults = { + mappings = { + i = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + }, + }, + }, +}) diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..c424398 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,21 @@ +require('nvim-treesitter.configs').setup({ + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + indent = { + enable = true, + }, + ensure_installed = { + "bash", + "c", + "cpp", + "json", + "lua", + "markdown", + "python", + "rust", + "vim", + "yaml", + }, +}) diff --git a/lua/settings.lua b/lua/settings.lua deleted file mode 100644 index b6a4fc7..0000000 --- a/lua/settings.lua +++ /dev/null @@ -1,9 +0,0 @@ --- source file everytime it changes -vim.cmd([[ - augroup user_settings - autocmd! - autocmd BufWritePost settings.lua source - augroup end -]]) - -vim.opt.number = true diff --git a/lua/themes.lua b/lua/themes.lua index 676b966..53bc916 100644 --- a/lua/themes.lua +++ b/lua/themes.lua @@ -6,5 +6,5 @@ vim.cmd([[ augroup end ]]) -vim.cmd [[colorscheme solarized]] vim.opt.background = 'dark' +vim.cmd("colorscheme solarized") From 9c8ed18e9ec9af1043d09d1b297b0c79598f97ae Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Mon, 21 Feb 2022 16:46:37 +0100 Subject: [PATCH 12/33] feat: add toggleterm --- lua/keymaps.lua | 12 ++++++++++++ lua/plugins.lua | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 4529acc..2d70872 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -30,3 +30,15 @@ nnoremap("G", ":tab G") nnoremap("ff", "Telescope find_files theme=dropdown") nnoremap("fb", "Telescope buffers theme=dropdown") nnoremap("fg", "Telescope git_files theme=dropdown") + +-- terminal +function _G.set_terminal_keymaps() + local opts = {noremap = true} + vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[h]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[j]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[k]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[l]], opts) +end + +vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') diff --git a/lua/plugins.lua b/lua/plugins.lua index ec54bce..2f550a0 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -119,6 +119,20 @@ return require('packer').startup(function(use) config = function() require('plugins.telescope') end, }) + -- markdown preview + use({'iamcco/markdown-preview.nvim'}) + + -- terminal + use({ + "akinsho/nvim-toggleterm.lua", + config = function() + require("toggleterm").setup({ + size = 32, + open_mapping = [[]], + }) + end, + }) + if packer_bootstrap then require('packer').sync() end From 9007d425b37314dbfe3675b679c63c68ab5e0793 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Mon, 21 Feb 2022 16:46:49 +0100 Subject: [PATCH 13/33] fix: remove remark_ls --- lua/plugins/lspconfig.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index e7d575c..1bc1ef7 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -12,7 +12,6 @@ local language_servers = { "eslint", "html", "pyright", - "remark_ls", "rust_analyzer", "sumneko_lua", "svelte", From 32433cf27f732307bf41c57868b2c05815924518 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Mon, 21 Feb 2022 17:32:12 +0100 Subject: [PATCH 14/33] feat: auto-close brackets --- lua/options.lua | 10 ++++++++-- lua/plugins.lua | 8 ++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lua/options.lua b/lua/options.lua index 7c442f9..b4566c7 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -39,8 +39,14 @@ vim.opt.smartcase = true -- preview commands vim.opt.inccommand = "split" --- enable cursorline -vim.opt.cursorline = true +-- set cursorline in active window +vim.cmd([[ + augroup CursorLine + autocmd! + autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline + autocmd WinLeave * setlocal nocursorline + augroup END +]]) -- coq.nvim vim.g.coq_settings = { auto_start = "shut-up" } diff --git a/lua/plugins.lua b/lua/plugins.lua index 2f550a0..524c7ec 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -133,6 +133,14 @@ return require('packer').startup(function(use) end, }) + -- auto-close brackets + use({ + "windwp/nvim-autopairs", + config = function () + require("nvim-autopairs").setup({}) + end, + }) + if packer_bootstrap then require('packer').sync() end From 9b746f3f95810ac085261ddc64220731444bd58d Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Mon, 21 Feb 2022 17:49:56 +0100 Subject: [PATCH 15/33] fix: prevent remapping --- lua/keymaps.lua | 2 +- lua/options.lua | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 2d70872..feddd39 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -7,7 +7,7 @@ vim.cmd([[ ]]) local function nnoremap(key, command) - vim.api.nvim_set_keymap("n",key,command, { noremap = true, silent = true }) + vim.api.nvim_set_keymap("n",key,command, { noremap = true }) end vim.g.mapleader = " " diff --git a/lua/options.lua b/lua/options.lua index b4566c7..6ec3a60 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -49,4 +49,9 @@ vim.cmd([[ ]]) -- coq.nvim -vim.g.coq_settings = { auto_start = "shut-up" } +vim.g.coq_settings = { + auto_start = "shut-up", + keymap = { + jump_to_mark = "", -- prevent remapping + }, +} From e40ad7ba9b5fe8771c4c16234804dcd4af6f78f7 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Mon, 21 Feb 2022 19:54:49 +0100 Subject: [PATCH 16/33] feat: close buffers with leader-q --- lua/keymaps.lua | 3 +++ lua/plugins.lua | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/lua/keymaps.lua b/lua/keymaps.lua index feddd39..595fa8e 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -42,3 +42,6 @@ function _G.set_terminal_keymaps() end vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') + +-- buffer closing +nnoremap("q", ":Bdelete") diff --git a/lua/plugins.lua b/lua/plugins.lua index 524c7ec..91ef091 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -141,6 +141,11 @@ return require('packer').startup(function(use) end, }) + -- buffer closing + use({ + "sar/bbye.nvim" + }) + if packer_bootstrap then require('packer').sync() end From 8d69edba36ec3306669f28b0735da442a6c49ae2 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Mon, 21 Feb 2022 19:55:01 +0100 Subject: [PATCH 17/33] feat: detect ansible filetype --- lua/plugins.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index 91ef091..7da6758 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -146,6 +146,9 @@ return require('packer').startup(function(use) "sar/bbye.nvim" }) + -- ansible filetype + use({"pearofducks/ansible-vim"}) + if packer_bootstrap then require('packer').sync() end From 9ce3404d79398939ab0820f51b5b331a6cc889c0 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Tue, 22 Feb 2022 08:45:01 +0100 Subject: [PATCH 18/33] feat: add more treesitter syntaxes --- lua/plugins/treesitter.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index c424398..9902a46 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -10,12 +10,17 @@ require('nvim-treesitter.configs').setup({ "bash", "c", "cpp", + "html", + "javascript", "json", "lua", "markdown", "python", "rust", + "svelte", + "typescript", "vim", + "vue", "yaml", }, }) From ec4a2c0af97612d45af56650ba527ec7b073e6c7 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Tue, 22 Feb 2022 08:45:30 +0100 Subject: [PATCH 19/33] feat: map lsp commands --- lua/plugins/lspconfig.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 1bc1ef7..a67d158 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -60,6 +60,14 @@ local function custom_on_attach(client, buffer_nr) -- Inspect function bufnnoremap("K", "lua vim.lsp.buf.hover()") + bufnnoremap("", "lua vim.lsp.buf.signature_help()") + + -- Navigation + bufnnoremap("gd", "lua vim.lsp.buf.definition()") + bufnnoremap("gD", "lua vim.lsp.buf.declaration()") + bufnnoremap("gi", "lua vim.lsp.buf.implementation()") + bufnnoremap("gr", "lua vim.lsp.buf.references()") + bufnnoremap("ga", "lua vim.lsp.buf.code_action()") -- Rename all references of symbol bufnnoremap("R", "lua vim.lsp.buf.rename()") From 9650d6d51cecde9cd023615fc805822446654e08 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Tue, 22 Feb 2022 08:45:55 +0100 Subject: [PATCH 20/33] feat: use vim-illuminate --- lua/plugins.lua | 13 +------------ lua/plugins/lspconfig.lua | 6 ++++++ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index 7da6758..b58e98f 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -84,18 +84,7 @@ return require('packer').startup(function(use) }) -- highlight current symbol - use({ - "nvim-treesitter/nvim-treesitter-refactor", - config = function () require("nvim-treesitter.configs").setup({ - refactor = { - highlight_definitions = { - enable = true, - clear_on_cursor_move = true, - }, - } - }) - end, - }) + use({"RRethy/vim-illuminate"}) -- language server use({ diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index a67d158..c181288 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -52,6 +52,9 @@ local extra_server_opts = { } local function custom_on_attach(client, buffer_nr) + -- onmifunc + vim.api.nvim_buf_set_option(0, "omnifunc", "v:lua.vim.lsp.omnifunc") + -- Helper function local opts = {noremap = true, silent = true} local function bufnnoremap(key, action) @@ -88,6 +91,9 @@ local function custom_on_attach(client, buffer_nr) if client.resolved_capabilities.document_formatting then vim.cmd("autocmd BufWritePre lua vim.lsp.buf.formatting_sync()") end + + -- vim-illuminate + require("illuminate").on_attach(client) end lsp_installer.on_server_ready(function(server) From a893ddf25ce03f6985b221e20c2a452ab1a91450 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Tue, 22 Feb 2022 08:46:12 +0100 Subject: [PATCH 21/33] feat: use delimitMate --- lua/plugins.lua | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index b58e98f..19af637 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -108,6 +108,9 @@ return require('packer').startup(function(use) config = function() require('plugins.telescope') end, }) + -- automatic pairs + use({"Raimondi/delimitMate"}) + -- markdown preview use({'iamcco/markdown-preview.nvim'}) @@ -122,14 +125,6 @@ return require('packer').startup(function(use) end, }) - -- auto-close brackets - use({ - "windwp/nvim-autopairs", - config = function () - require("nvim-autopairs").setup({}) - end, - }) - -- buffer closing use({ "sar/bbye.nvim" From b5489face89e98f77633733eaf5f14c27709f0b7 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Tue, 22 Feb 2022 09:27:45 +0100 Subject: [PATCH 22/33] feat: add lua-format to lsp --- lua/options.lua | 4 +- lua/plugins.lua | 157 ++++++++++++++++++-------------------- lua/plugins/lspconfig.lua | 50 +++++------- 3 files changed, 98 insertions(+), 113 deletions(-) diff --git a/lua/options.lua b/lua/options.lua index 6ec3a60..b865a1d 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -52,6 +52,6 @@ vim.cmd([[ vim.g.coq_settings = { auto_start = "shut-up", keymap = { - jump_to_mark = "", -- prevent remapping - }, + jump_to_mark = "" -- prevent remapping + } } diff --git a/lua/plugins.lua b/lua/plugins.lua index 19af637..8397d52 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,10 +1,13 @@ local fn = vim.fn -- boostrap packer -local install_path = fn.stdpath('data')..'/site/pack/packer/opt/packer.nvim' +local install_path = fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim' local packer_bootstrap if fn.empty(fn.glob(install_path)) > 0 then - packer_bootstrap = fn.system({'git', 'clone','https://github.com/wbthomason/packer.nvim', install_path}) + packer_bootstrap = fn.system({ + 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', + install_path + }) end -- run PackerSync everytime plugins.lua is updated @@ -19,94 +22,91 @@ vim.cmd([[packadd packer.nvim]]) -- initialize plugins return require('packer').startup(function(use) - -- let packer manage itself - use({'wbthomason/packer.nvim', opt = true}) + -- let packer manage itself + use({'wbthomason/packer.nvim', opt = true}) - -- theme + -- theme use("ishan9299/nvim-solarized-lua") -- commenting use("tpope/vim-commentary") - -- session handling - use('tpope/vim-obsession') - use('dhruvasagar/vim-prosession') + -- session handling + use('tpope/vim-obsession') + use('dhruvasagar/vim-prosession') - -- status line - use { - 'nvim-lualine/lualine.nvim', - requires = { 'kyazdani42/nvim-web-devicons', opt = true }, - config = function() - require('lualine').setup() - end - } + -- status line + use { + 'nvim-lualine/lualine.nvim', + requires = {'kyazdani42/nvim-web-devicons', opt = true}, + config = function() require('lualine').setup() end + } - -- tabline - use { - 'kdheepak/tabline.nvim', - config = function() - require'tabline'.setup { - enable = true, - options = { - show_filename_only = true, - } - } - end, - requires = { { 'hoob3rt/lualine.nvim' }, {'kyazdani42/nvim-web-devicons', opt = true} } - } + -- tabline + use { + 'kdheepak/tabline.nvim', + config = function() + require'tabline'.setup { + enable = true, + options = {show_filename_only = true} + } + end, + requires = { + {'hoob3rt/lualine.nvim'}, + {'kyazdani42/nvim-web-devicons', opt = true} + } + } - -- blankline - use({ - "lukas-reineke/indent-blankline.nvim", - config = function () - require("indent_blankline").setup { - char = "┊", - buftype_exclude = {"terminal", "help"} - } - end - }) + -- blankline + use({ + "lukas-reineke/indent-blankline.nvim", + config = function() + require("indent_blankline").setup { + char = "┊", + buftype_exclude = {"terminal", "help"} + } + end + }) - -- git - use('tpope/vim-fugitive') - use ({ - 'lewis6991/gitsigns.nvim', - requires = {'nvim-lua/plenary.nvim'}, - config = function() require('gitsigns').setup() end - }) + -- git + use('tpope/vim-fugitive') + use({ + 'lewis6991/gitsigns.nvim', + requires = {'nvim-lua/plenary.nvim'}, + config = function() require('gitsigns').setup() end + }) - -- autocompletion - use({ - "ms-jpq/coq_nvim", - branch="coq", - requires = { - {'ms-jpq/coq.artifacts', branch = 'artifacts'}, - }, - }) + -- autocompletion + use({ + "ms-jpq/coq_nvim", + branch = "coq", + requires = {{'ms-jpq/coq.artifacts', branch = 'artifacts'}} + }) -- highlight current symbol use({"RRethy/vim-illuminate"}) - -- language server - use({ - "neovim/nvim-lspconfig", - config = function() require("plugins.lspconfig") end, - }) + -- language server + use({ + "neovim/nvim-lspconfig", + config = function() require("plugins.lspconfig") end + }) use('williamboman/nvim-lsp-installer') - -- treesitter - use({ - 'nvim-treesitter/nvim-treesitter', - config = function() require('plugins.treesitter') end, - run = ':TSUpdate' - }) + -- treesitter + use({ + 'nvim-treesitter/nvim-treesitter', + config = function() require('plugins.treesitter') end, + run = ':TSUpdate' + }) - -- Telescope - use({ - 'nvim-telescope/telescope.nvim', - requires = {{'nvim-lua/plenary.nvim'}}, - config = function() require('plugins.telescope') end, - }) + -- Telescope + use({ + 'nvim-telescope/telescope.nvim', + requires = {{'nvim-lua/plenary.nvim'}}, + config = function() require('plugins.telescope') end + }) -- automatic pairs use({"Raimondi/delimitMate"}) @@ -118,22 +118,15 @@ return require('packer').startup(function(use) use({ "akinsho/nvim-toggleterm.lua", config = function() - require("toggleterm").setup({ - size = 32, - open_mapping = [[]], - }) - end, + require("toggleterm").setup({size = 32, open_mapping = [[]]}) + end }) -- buffer closing - use({ - "sar/bbye.nvim" - }) + use({"sar/bbye.nvim"}) -- ansible filetype use({"pearofducks/ansible-vim"}) - if packer_bootstrap then - require('packer').sync() - end + if packer_bootstrap then require('packer').sync() end end) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index c181288..5329850 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -6,18 +6,8 @@ table.insert(nvim_runtime_path, "lua/?.lua") table.insert(nvim_runtime_path, "lua/?/init.lua") local language_servers = { - "ansiblels", - "bashls", - "dockerls", - "eslint", - "html", - "pyright", - "rust_analyzer", - "sumneko_lua", - "svelte", - "taplo", - "tsserver", - "volar", + "ansiblels", "bashls", "dockerls", "efm", "eslint", "html", "pyright", + "rust_analyzer", "sumneko_lua", "svelte", "taplo", "tsserver", "volar" } for _, server_name in pairs(language_servers) do @@ -30,30 +20,31 @@ for _, server_name in pairs(language_servers) do end local extra_server_opts = { + ["efm"] = function(opts) + opts.filetypes = {"lua"} + opts.init_options = {documentFormatting = true} + opts.settings = { + rootMarkers = {".git/"}, + languages = { + lua = {{formatCommand = "lua-format -i", formatStdin = true}} + } + } + end, ["sumneko_lua"] = function(opts) opts.settings = { Lua = { - runtime = { - version = 'LuaJIT', - path = nvim_runtime_path, - }, - diagnostics = { - globals = {'vim'}, - }, - workspace = { - library = vim.api.nvim_get_runtime_file("", true), - }, - telemetry ={ - enable = false, - }, - }, + runtime = {version = 'LuaJIT', path = nvim_runtime_path}, + diagnostics = {globals = {'vim'}}, + workspace = {library = vim.api.nvim_get_runtime_file("", true)}, + telemetry = {enable = false} + } } end } local function custom_on_attach(client, buffer_nr) -- onmifunc - vim.api.nvim_buf_set_option(0, "omnifunc", "v:lua.vim.lsp.omnifunc") + vim.api.nvim_buf_set_option(buffer_nr, "omnifunc", "v:lua.vim.lsp.omnifunc") -- Helper function local opts = {noremap = true, silent = true} @@ -80,7 +71,8 @@ local function custom_on_attach(client, buffer_nr) bufnnoremap("", "lua vim.diagnostic.goto_prev()") -- Show line diagnostics - bufnnoremap("d", 'lua vim.diagnostic.open_float(0, {scope = "line"})') + bufnnoremap("d", + 'lua vim.diagnostic.open_float(0, {scope = "line"})') -- Open local diagnostics in local list bufnnoremap("D", "lua vim.diagnostic.setloclist()") @@ -99,7 +91,7 @@ end lsp_installer.on_server_ready(function(server) local opts = coq.lsp_ensure_capabilities({ on_attach = custom_on_attach, - capabilities = vim.lsp.protocol.make_client_capabilities(), + capabilities = vim.lsp.protocol.make_client_capabilities() }) if extra_server_opts[server.name] then From b20b0afb88d2681ea84f70a98eb22cfa1cc30f56 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Tue, 22 Feb 2022 11:18:59 +0100 Subject: [PATCH 23/33] feat: disable conflicting auto-formatters --- lua/plugins/lspconfig.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 5329850..da98442 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -80,6 +80,11 @@ local function custom_on_attach(client, buffer_nr) -- Open all project diagnostics in quickfix list bufnnoremap("", "lua vim.diagnostic.setqflist()") + -- disable conflicting formatters + if client.name == "tsserver" or client.name == "html" then + client.resolved_capabilities.document_formatting = false + end + if client.resolved_capabilities.document_formatting then vim.cmd("autocmd BufWritePre lua vim.lsp.buf.formatting_sync()") end From 39153f91c171bb72c3d990049c76771b1ed4a23e Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Tue, 22 Feb 2022 11:19:24 +0100 Subject: [PATCH 24/33] feat: use lua-format and prettier via efm --- lua/plugins/lspconfig.lua | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index da98442..6c619d8 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -21,13 +21,36 @@ end local extra_server_opts = { ["efm"] = function(opts) - opts.filetypes = {"lua"} + opts.filetypes = { + "lua", "html", "markdown", "typescript", "typescriptreact" + } opts.init_options = {documentFormatting = true} opts.settings = { rootMarkers = {".git/"}, languages = { - lua = {{formatCommand = "lua-format -i", formatStdin = true}} + lua = {{formatCommand = "lua-format -i", formatStdin = true}}, + html = { + {formatCommand = "yarn run --silent prettier --parser html"} + }, + typescript = { + { + formatCommand = "yarn run --silent prettier --parser typescript" + } + }, + typescriptreact = { + { + formatCommand = "yarn run --silent prettier --parser typescript" + } + }, + markdown = { + { + formatCommand = "yarn run --silent prettier --parser markdown" + } + } } + -- prettier-parser + -- flow|babel|babel-flow|babel-ts|typescript|espree|meriyah|css| + -- less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|glimmer|html|angular|lwc } end, ["sumneko_lua"] = function(opts) From 94a1b5c7bccd4f12b24f87441a2ca68c1b7e0292 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Tue, 22 Feb 2022 20:01:23 +0100 Subject: [PATCH 25/33] feat: close buffers with --- lua/keymaps.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 595fa8e..ca9c3d0 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -7,7 +7,7 @@ vim.cmd([[ ]]) local function nnoremap(key, command) - vim.api.nvim_set_keymap("n",key,command, { noremap = true }) + vim.api.nvim_set_keymap("n", key, command, {noremap = true}) end vim.g.mapleader = " " @@ -24,7 +24,7 @@ nnoremap("", ":TablineBufferNext") nnoremap("", ":TablineBufferPrevious") -- fugitive -nnoremap("G", ":tab G") +nnoremap("g", ":Git") -- telescope nnoremap("ff", "Telescope find_files theme=dropdown") @@ -33,15 +33,15 @@ nnoremap("fg", "Telescope git_files theme=dropdown") -- terminal function _G.set_terminal_keymaps() - local opts = {noremap = true} - vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) - vim.api.nvim_buf_set_keymap(0, 't', '', [[h]], opts) - vim.api.nvim_buf_set_keymap(0, 't', '', [[j]], opts) - vim.api.nvim_buf_set_keymap(0, 't', '', [[k]], opts) - vim.api.nvim_buf_set_keymap(0, 't', '', [[l]], opts) + local opts = {noremap = true} + vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[h]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[j]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[k]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[l]], opts) end vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') -- buffer closing -nnoremap("q", ":Bdelete") +nnoremap("", ":Bdelete") From c5fc9d2e6ab83cf186129a68932b61548de6154b Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Wed, 23 Feb 2022 21:08:05 +0100 Subject: [PATCH 26/33] feat: use Telescope for code actions --- lua/plugins/lspconfig.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 6c619d8..3b50af3 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -84,7 +84,7 @@ local function custom_on_attach(client, buffer_nr) bufnnoremap("gD", "lua vim.lsp.buf.declaration()") bufnnoremap("gi", "lua vim.lsp.buf.implementation()") bufnnoremap("gr", "lua vim.lsp.buf.references()") - bufnnoremap("ga", "lua vim.lsp.buf.code_action()") + bufnnoremap("ga", "Telescope lsp_code_actions theme=cursor") -- Rename all references of symbol bufnnoremap("R", "lua vim.lsp.buf.rename()") From 260a273957a3235305eda4f9dfd33a3f4c559c3e Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Wed, 23 Feb 2022 21:11:30 +0100 Subject: [PATCH 27/33] feat: add find/grep mappings --- lua/keymaps.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/keymaps.lua b/lua/keymaps.lua index ca9c3d0..6fc9e13 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -30,6 +30,8 @@ nnoremap("g", ":Git") nnoremap("ff", "Telescope find_files theme=dropdown") nnoremap("fb", "Telescope buffers theme=dropdown") nnoremap("fg", "Telescope git_files theme=dropdown") +nnoremap("", "Telescope grep_string") +nnoremap("", "Telescope live_grep") -- terminal function _G.set_terminal_keymaps() From 3825a97554365622ebb63175d50f4e3859249ce7 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Wed, 23 Feb 2022 21:22:28 +0100 Subject: [PATCH 28/33] feat: use Telescope for diagnostics --- lua/plugins/lspconfig.lua | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 3b50af3..ca2faf9 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -93,15 +93,8 @@ local function custom_on_attach(client, buffer_nr) bufnnoremap("", "lua vim.diagnostic.goto_next()") bufnnoremap("", "lua vim.diagnostic.goto_prev()") - -- Show line diagnostics - bufnnoremap("d", - 'lua vim.diagnostic.open_float(0, {scope = "line"})') - - -- Open local diagnostics in local list - bufnnoremap("D", "lua vim.diagnostic.setloclist()") - - -- Open all project diagnostics in quickfix list - bufnnoremap("", "lua vim.diagnostic.setqflist()") + -- Open diagnostics + bufnnoremap("d", "Telescope diagnostics") -- disable conflicting formatters if client.name == "tsserver" or client.name == "html" then From 4b560280a606c2f9904b26fdd1b734e484089496 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Wed, 23 Feb 2022 21:31:57 +0100 Subject: [PATCH 29/33] feat: use fzf in Telescope --- lua/plugins.lua | 1 + lua/plugins/telescope.lua | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index 8397d52..7248b0d 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -107,6 +107,7 @@ return require('packer').startup(function(use) requires = {{'nvim-lua/plenary.nvim'}}, config = function() require('plugins.telescope') end }) + use({'nvim-telescope/telescope-fzf-native.nvim', run ='make'}) -- automatic pairs use({"Raimondi/delimitMate"}) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index eef9e52..7d3479e 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,12 +1,22 @@ local actions = require("telescope.actions") require('telescope').setup({ - defaults = { - mappings = { - i = { - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - }, - }, - }, + defaults = { + mappings = { + i = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous + }, + n = {[''] = actions.close} + } + }, + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true + } + } }) + +require('telescope').load_extension('fzf') From e7f411ac8ffb5de2138859dbea569b3ea689cce7 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Thu, 24 Feb 2022 07:54:00 +0100 Subject: [PATCH 30/33] feat: add more treesitter languages --- lua/plugins/treesitter.lua | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 9902a46..ddcbd67 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,26 +1,9 @@ require('nvim-treesitter.configs').setup({ - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - indent = { - enable = true, - }, - ensure_installed = { - "bash", - "c", - "cpp", - "html", - "javascript", - "json", - "lua", - "markdown", - "python", - "rust", - "svelte", - "typescript", - "vim", - "vue", - "yaml", - }, + highlight = {enable = true, additional_vim_regex_highlighting = false}, + indent = {enable = true}, + ensure_installed = { + "bash", "c", "cpp", "css", "dockerfile", "html", "javascript", "json", + "latex", "lua", "markdown", "python", "rust", "svelte", "toml", "tsx", + "typescript", "vim", "vue", "yaml" + } }) From a94b69a34f9577b88c3c503a8f662886c45e9bf8 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Thu, 24 Feb 2022 07:57:25 +0100 Subject: [PATCH 31/33] feat: configure blankline exceptions --- lua/plugins.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index 7248b0d..ff10760 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -63,7 +63,9 @@ return require('packer').startup(function(use) config = function() require("indent_blankline").setup { char = "┊", - buftype_exclude = {"terminal", "help"} + buftype_exclude = {"terminal", "help", "nofile"}, + filetype_exclude = {'help', 'packer'}, + show_trailing_blankline_indent = false } end }) @@ -107,7 +109,7 @@ return require('packer').startup(function(use) requires = {{'nvim-lua/plenary.nvim'}}, config = function() require('plugins.telescope') end }) - use({'nvim-telescope/telescope-fzf-native.nvim', run ='make'}) + use({'nvim-telescope/telescope-fzf-native.nvim', run = 'make'}) -- automatic pairs use({"Raimondi/delimitMate"}) From 1ba082c75ff53e71a5b0d74a980ed7ac37ed7588 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Thu, 24 Feb 2022 08:08:36 +0100 Subject: [PATCH 32/33] feat: revert to leader-q buffer closing --- lua/keymaps.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 6fc9e13..978975e 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -46,4 +46,4 @@ end vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') -- buffer closing -nnoremap("", ":Bdelete") +nnoremap("q", ":Bdelete") From 9708fa7213d35e91fb4902b54293b0d13358dd22 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Thu, 24 Feb 2022 20:39:39 +0100 Subject: [PATCH 33/33] refactor: move all files to subdirectory --- .gitignore => nvim/.gitignore | 0 init.lua => nvim/init.lua | 0 {lua => nvim/lua}/keymaps.lua | 0 {lua => nvim/lua}/options.lua | 0 {lua => nvim/lua}/plugins.lua | 0 {lua => nvim/lua}/plugins/bufferline.lua | 0 {lua => nvim/lua}/plugins/lspconfig.lua | 0 {lua => nvim/lua}/plugins/telescope.lua | 0 {lua => nvim/lua}/plugins/treesitter.lua | 0 {lua => nvim/lua}/themes.lua | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename .gitignore => nvim/.gitignore (100%) rename init.lua => nvim/init.lua (100%) rename {lua => nvim/lua}/keymaps.lua (100%) rename {lua => nvim/lua}/options.lua (100%) rename {lua => nvim/lua}/plugins.lua (100%) rename {lua => nvim/lua}/plugins/bufferline.lua (100%) rename {lua => nvim/lua}/plugins/lspconfig.lua (100%) rename {lua => nvim/lua}/plugins/telescope.lua (100%) rename {lua => nvim/lua}/plugins/treesitter.lua (100%) rename {lua => nvim/lua}/themes.lua (100%) diff --git a/.gitignore b/nvim/.gitignore similarity index 100% rename from .gitignore rename to nvim/.gitignore diff --git a/init.lua b/nvim/init.lua similarity index 100% rename from init.lua rename to nvim/init.lua diff --git a/lua/keymaps.lua b/nvim/lua/keymaps.lua similarity index 100% rename from lua/keymaps.lua rename to nvim/lua/keymaps.lua diff --git a/lua/options.lua b/nvim/lua/options.lua similarity index 100% rename from lua/options.lua rename to nvim/lua/options.lua diff --git a/lua/plugins.lua b/nvim/lua/plugins.lua similarity index 100% rename from lua/plugins.lua rename to nvim/lua/plugins.lua diff --git a/lua/plugins/bufferline.lua b/nvim/lua/plugins/bufferline.lua similarity index 100% rename from lua/plugins/bufferline.lua rename to nvim/lua/plugins/bufferline.lua diff --git a/lua/plugins/lspconfig.lua b/nvim/lua/plugins/lspconfig.lua similarity index 100% rename from lua/plugins/lspconfig.lua rename to nvim/lua/plugins/lspconfig.lua diff --git a/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua similarity index 100% rename from lua/plugins/telescope.lua rename to nvim/lua/plugins/telescope.lua diff --git a/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua similarity index 100% rename from lua/plugins/treesitter.lua rename to nvim/lua/plugins/treesitter.lua diff --git a/lua/themes.lua b/nvim/lua/themes.lua similarity index 100% rename from lua/themes.lua rename to nvim/lua/themes.lua