From 717c7f09e5173430a4af453dfb8ed9c1942dddd2 Mon Sep 17 00:00:00 2001 From: Fabian Schmidt Date: Fri, 24 Feb 2023 21:11:27 +0100 Subject: [PATCH 1/2] First draft after switching to lazy.nvim --- init.lua | 48 +++++++++++++++++++++++--- lazy-lock.json | 33 ++++++++++++++++++ lua/plugins.lua | 70 -------------------------------------- lua/plugins/lsp.lua | 28 +++++++++++++++ lua/plugins/navigation.lua | 67 ++++++++++++++++++++++++++++++++++++ lua/plugins/style.lua | 52 ++++++++++++++++++++++++++++ lua/plugins/writing.lua | 11 ++++++ lua/settings/init.lua | 38 --------------------- lua/settings/theme.lua | 51 --------------------------- lua/settings/tree.lua | 60 -------------------------------- 10 files changed, 235 insertions(+), 223 deletions(-) create mode 100644 lazy-lock.json delete mode 100644 lua/plugins.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/navigation.lua create mode 100644 lua/plugins/style.lua create mode 100644 lua/plugins/writing.lua delete mode 100644 lua/settings/theme.lua delete mode 100644 lua/settings/tree.lua diff --git a/init.lua b/init.lua index 0722d4e..70b3702 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,46 @@ -- init.lua +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) +vim.g.mapleader = " " +require("lazy").setup("plugins") +require("maps").init() +require("commands") +require("settings").init() -require('plugins') -require('settings').init() -require('maps').init() -require('commands') +vim.opt.backup = false +vim.opt.undodir = '/Users/fschmidt/.cache/nvim/undodir' +vim.opt.swapfile = false +vim.opt.undofile = true +vim.opt.smartcase = true +vim.opt.ignorecase = true +vim.opt.laststatus = 2 +vim.opt.hidden = true +vim.opt.hlsearch = false +vim.opt.incsearch = true +vim.opt.scrolloff = 12 +vim.opt.sidescrolloff = 8 +vim.opt.mouse = 'a' +vim.opt.autochdir = true +vim.opt.clipboard = 'unnamed,unnamedplus' +vim.opt.number = true +vim.opt.wrap = false +vim.opt.signcolumn = 'yes:2' +vim.opt.list = true +vim.opt.listchars = 'tab:▸ ,trail:·' +vim.opt.shiftwidth = 4 +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.expandtab = false +vim.opt.autoindent = true +vim.opt.smartindent = true +vim.opt.completeopt = { "menu", "menuone", "noselect" } diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..94a1c23 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,33 @@ +{ + "LuaSnip": { "branch": "master", "commit": "d33cf7de14eea209b8ed4a7edaed72f0b8cedb30" }, + "bufferline.nvim": { "branch": "main", "commit": "52d6acabb79c8c0942f8873a0ca7848eb2159267" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "8fcc934a52af96120fe26358985c10c035984b53" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" }, + "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f3491638d123cfd2c8048aefaf66d246ff250ca6" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "dashboard-nvim": { "branch": "master", "commit": "a6e3536400c79f20d23b904a89d95efc6a6ac717" }, + "fidget.nvim": { "branch": "main", "commit": "688b4fec4517650e29c3e63cfbb6e498b3112ba1" }, + "gitsigns.nvim": { "branch": "main", "commit": "f388995990aba04cfdc7c3ab870c33e280601109" }, + "goyo.vim": { "branch": "master", "commit": "7f5d35a65510083ea5c2d0941797244b9963d4a9" }, + "kanagawa.nvim": { "branch": "master", "commit": "4c8d48726621a7f3998c7ed35b2c2535abc22def" }, + "lazy.nvim": { "branch": "main", "commit": "8077428e63feb0f3bf795d53b23ba1695b28ab0e" }, + "limelight.vim": { "branch": "master", "commit": "86aaec1700b27618d33d6182f44691d84d2cb6e5" }, + "lspkind-nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" }, + "lualine.nvim": { "branch": "master", "commit": "e99d733e0213ceb8f548ae6551b04ae32e590c80" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "93e58e100f37ef4fb0f897deeed20599dae9d128" }, + "mason.nvim": { "branch": "main", "commit": "5b9fd3822d686092c7ee08adfcbd2c764def22c5" }, + "nvim-autopairs": { "branch": "master", "commit": "bde7a1b4534e0a4c2451a738379cd628ba65eba7" }, + "nvim-cmp": { "branch": "main", "commit": "ba7a53478d0726683d1597ad1e814695033dcb4b" }, + "nvim-lspconfig": { "branch": "master", "commit": "91998cef4b1ae3a624901d0f9c894409db24e760" }, + "nvim-tree.lua": { "branch": "master", "commit": "9c97e6449b0b0269bd44e1fd4857184dfa57bb4c" }, + "nvim-treesitter": { "branch": "master", "commit": "2277c0c2a7d1aca2979285621ac5c82787b25dd2" }, + "nvim-web-devicons": { "branch": "master", "commit": "4709a504d2cd2680fb511675e64ef2790d491d36" }, + "playground": { "branch": "master", "commit": "4044b53c4d4fcd7a78eae20b8627f78ce7dc6f56" }, + "plenary.nvim": { "branch": "master", "commit": "253d34830709d690f013daf2853a9d21ad7accab" }, + "rust-tools.nvim": { "branch": "master", "commit": "71d2cf67b5ed120a0e31b2c8adb210dd2834242f" }, + "telescope.nvim": { "branch": "master", "commit": "c1a2af0af69e80e14e6b226d3957a064cd080805" }, + "vimwiki": { "branch": "dev", "commit": "fea8bee382b2051b0137fd2cacf0862823ee69b3" } +} \ No newline at end of file diff --git a/lua/plugins.lua b/lua/plugins.lua deleted file mode 100644 index bd12b92..0000000 --- a/lua/plugins.lua +++ /dev/null @@ -1,70 +0,0 @@ --- plugin.lua - - -require 'paq' { - -- Handle itself - 'savq/paq-nvim'; - - -- Theme - 'kyazdani42/nvim-web-devicons'; - { 'folke/tokyonight.nvim', { branch = 'main' } }; - 'tiagovla/tokyodark.nvim'; - 'rebelot/kanagawa.nvim'; - 'sainnhe/everforest'; - 'navarasu/onedark.nvim'; - 'rose-pine/neovim'; - 'rmehri01/onenord.nvim'; - 'EdenEast/nightfox.nvim'; - 'tanvirtin/monokai.nvim'; - 'catppuccin/nvim'; - 'briones-gabriel/darcula-solid.nvim'; - 'rktjmp/lush.nvim'; - - - -- treesitter - 'nvim-treesitter/nvim-treesitter'; - 'nvim-treesitter/playground'; - - -- Utils - 'akinsho/nvim-bufferline.lua'; - 'hoob3rt/lualine.nvim'; - 'j-hui/fidget.nvim'; - 'airblade/vim-gitgutter'; - 'nvim-lua/popup.nvim'; - 'nvim-lua/plenary.nvim'; - - -- File Navigation - 'kyazdani42/nvim-tree.lua'; - 'nvim-telescope/telescope.nvim'; - - -- lsp - 'williamboman/mason.nvim'; - 'williamboman/mason-lspconfig.nvim'; - 'neovim/nvim-lspconfig'; - 'onsails/lspkind-nvim'; -- pictograms - 'simrat39/rust-tools.nvim'; - - -- completion - 'hrsh7th/cmp-nvim-lsp'; - 'hrsh7th/cmp-nvim-lsp-signature-help'; - 'hrsh7th/cmp-buffer'; - 'hrsh7th/cmp-path'; - 'hrsh7th/cmp-nvim-lua'; - 'hrsh7th/cmp-cmdline'; - 'hrsh7th/nvim-cmp'; - - -- snippets needed for cmp - 'L3MON4D3/LuaSnip'; - 'saadparwaiz1/cmp_luasnip'; - - -- autopair - 'windwp/nvim-autopairs'; - - -- Linting & formtatting - 'jose-elias-alvarez/null-ls.nvim'; - - -- writing - 'vimwiki/vimwiki'; - 'junegunn/goyo.vim'; - 'junegunn/limelight.vim'; -} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..ad7537f --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,28 @@ +return { + -- lsp + { 'williamboman/mason.nvim' }, + { 'williamboman/mason-lspconfig.nvim' }, + { 'neovim/nvim-lspconfig' }, + { 'simrat39/rust-tools.nvim' }, + { 'onsails/lspkind-nvim' }, -- pictograms replace (?) with lspsaga + { 'j-hui/fidget.nvim' }, -- show lsp status + -- completion + { + 'hrsh7th/nvim-cmp', + event = 'InsertEnter', + dependencies = { + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-nvim-lsp-signature-help', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-nvim-lua', + 'hrsh7th/cmp-cmdline', + -- snippets needed for cmp + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + 'windwp/nvim-autopairs', + } + } +} +-- -- Linting & formtatting +-- 'jose-elias-alvarez/null-ls.nvim'; diff --git a/lua/plugins/navigation.lua b/lua/plugins/navigation.lua new file mode 100644 index 0000000..0ebb5da --- /dev/null +++ b/lua/plugins/navigation.lua @@ -0,0 +1,67 @@ +return { + { + 'nvim-telescope/telescope.nvim', + tag = '0.1.1', + dependencies = { 'nvim-lua/plenary.nvim' }, + }, + { + 'nvim-tree/nvim-tree.lua', + config = function () + require('nvim-tree').setup { + disable_netrw = true, + hijack_netrw = true, + open_on_setup = false, + ignore_ft_on_setup = {}, + open_on_tab = false, + hijack_cursor = false, + update_cwd = true, + hijack_directories = { + enable = true, + auto_open = true, + }, + diagnostics = { + enable = false, + icons = { + hint = "", + info = "", + warning = "", + error = "", + } + }, + update_focused_file = { + enable = false, + update_cwd = false, + ignore_list = {} + }, + system_open = { + cmd = nil, + args = {} + }, + filters = { + dotfiles = false, + custom = {} + }, + git = { + enable = true, + ignore = true, + timeout = 500, + }, + view = { + width = 30, + hide_root_folder = false, + side = 'left', + mappings = { + custom_only = false, + list = {} + } + }, + actions = { + open_file = { + resize_window = false + } + } + } + end, + dependencies = { 'nvim-tree/nvim-web-devicons' } + } +} diff --git a/lua/plugins/style.lua b/lua/plugins/style.lua new file mode 100644 index 0000000..0a84f08 --- /dev/null +++ b/lua/plugins/style.lua @@ -0,0 +1,52 @@ +return { + { + 'rebelot/kanagawa.nvim', + config = function() + vim.opt.guifont = 'Source Code Pro for Powerline' + vim.g.limelight_conceal_ctermfg = 'gray' + vim.cmd('colorscheme kanagawa') + vim.cmd('set termguicolors') + vim.opt.syntax = 'on' + end + }, + { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + config = function() + require('nvim-treesitter.configs').setup { + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + indent = { + enable = true, + disable = { "html" } + } + } + end, + dependencies = { 'nvim-treesitter/playground' } + }, + { + 'akinsho/bufferline.nvim', + tag = "v3.3.0", + config = true, + dependencies = { 'nvim-tree/nvim-web-devicons' } + }, + { + 'hoob3rt/lualine.nvim', + config = function() + require('lualine').setup { + options = { + theme = 'kanagawa' + } + } + end + }, + { 'lewis6991/gitsigns.nvim' }, + { + 'glepnir/dashboard-nvim', + event = 'VimEnter', + config = true, + dependencies = { 'nvim-tree/nvim-web-devicons' } + }, +} diff --git a/lua/plugins/writing.lua b/lua/plugins/writing.lua new file mode 100644 index 0000000..5c5fb3d --- /dev/null +++ b/lua/plugins/writing.lua @@ -0,0 +1,11 @@ +return { + -- writing + { + 'vimwiki/vimwiki', + config = function() + vim.g.vimwiki_list = { { path = '~/Documents/Buch/wiki', syntax = 'markdown', ext = '.md' } } + end + }, + { 'junegunn/goyo.vim' }, -- try raplcing these 2 at some point because they don't work that well anymore + { 'junegunn/limelight.vim' }, +} diff --git a/lua/settings/init.lua b/lua/settings/init.lua index 7c60acb..cfdfd3d 100644 --- a/lua/settings/init.lua +++ b/lua/settings/init.lua @@ -2,47 +2,9 @@ local settings = {} -function settings.initMisc() - vim.opt.backup = false - vim.opt.undodir = '/Users/fschmidt/.cache/nvim/undodir' - vim.opt.swapfile = false - vim.opt.undofile = true - vim.opt.smartcase = true - vim.opt.ignorecase = true - vim.opt.laststatus = 2 - vim.opt.hidden = true - vim.opt.hlsearch = false - vim.opt.incsearch = true - vim.opt.scrolloff = 12 - vim.opt.sidescrolloff = 8 - vim.opt.mouse = 'a' - vim.opt.autochdir = true - vim.opt.clipboard = 'unnamed,unnamedplus' - vim.opt.number = true - vim.opt.wrap = false - vim.opt.signcolumn = 'yes:2' - vim.opt.list = true - vim.opt.listchars = 'tab:▸ ,trail:·' - vim.opt.shiftwidth = 4 - vim.opt.tabstop = 4 - vim.opt.softtabstop = 4 - vim.opt.expandtab = false - vim.opt.autoindent = true - vim.opt.smartindent = true - vim.opt.completeopt = { "menu", "menuone", "noselect" } -end - -function settings.initVimWiki() - vim.g.vimwiki_list = { { path = '~/Documents/Buch/wiki', syntax = 'markdown', ext = '.md' } } -end - function settings.init() - settings.initMisc() - settings.initVimWiki() - require('settings.theme').init() require('settings.lsp').init() require('settings.completion') - require('settings.tree') require('settings.luasnip') end diff --git a/lua/settings/theme.lua b/lua/settings/theme.lua deleted file mode 100644 index fed915e..0000000 --- a/lua/settings/theme.lua +++ /dev/null @@ -1,51 +0,0 @@ --- Theming - -local theme = {} - -function theme.initFont() - vim.opt.guifont = 'Source Code Pro for Powerline' -end - -function theme.lsp_status() - require('fidget').setup {} -end - -function theme.initStatusline() - require('lualine').setup { - options = { - theme = 'kanagawa' - } - } -end - -function theme.initBufferline() - local bufferline = require 'bufferline' - bufferline.setup() -end - -function theme.initColorscheme() - vim.g.limelight_conceal_ctermfg = 'gray' - vim.cmd 'colorscheme kanagawa' - vim.cmd 'set termguicolors' - vim.opt.syntax = 'on' - require('nvim-treesitter.configs').setup { - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - indent = { - enable = true, - disable = { "html" } - } - } -end - -function theme.init() - theme.initFont() - theme.lsp_status() - theme.initStatusline() - theme.initBufferline() - theme.initColorscheme() -end - -return theme diff --git a/lua/settings/tree.lua b/lua/settings/tree.lua deleted file mode 100644 index 5042972..0000000 --- a/lua/settings/tree.lua +++ /dev/null @@ -1,60 +0,0 @@ --- Tree - -local tree = {} - -require('nvim-tree').setup { - disable_netrw = true, - hijack_netrw = true, - open_on_setup = false, - ignore_ft_on_setup = {}, - open_on_tab = false, - hijack_cursor = false, - update_cwd = true, - hijack_directories = { - enable = true, - auto_open = true, - }, - diagnostics = { - enable = false, - icons = { - hint = "", - info = "", - warning = "", - error = "", - } - }, - update_focused_file = { - enable = false, - update_cwd = false, - ignore_list = {} - }, - system_open = { - cmd = nil, - args = {} - }, - filters = { - dotfiles = false, - custom = {} - }, - git = { - enable = true, - ignore = true, - timeout = 500, - }, - view = { - width = 30, - hide_root_folder = false, - side = 'left', - mappings = { - custom_only = false, - list = {} - } - }, - actions = { - open_file = { - resize_window = false - } - } -} - -return tree From aa72c826c0353920fd12edea4c3e9fe0ebbd0f71 Mon Sep 17 00:00:00 2001 From: Fabian Schmidt Date: Sun, 26 Feb 2023 13:20:49 +0100 Subject: [PATCH 2/2] Moved lsp config into plugin file --- init.lua | 1 - lazy-lock.json | 18 ++-- lua/maps.lua | 16 ---- lua/plugins/lsp.lua | 178 ++++++++++++++++++++++++++++++++++-- lua/plugins/navigation.lua | 2 +- lua/plugins/writing.lua | 5 +- lua/settings/completion.lua | 73 --------------- lua/settings/init.lua | 11 --- lua/settings/lsp.lua | 91 ------------------ lua/settings/luasnip.lua | 3 - 10 files changed, 183 insertions(+), 215 deletions(-) delete mode 100644 lua/settings/completion.lua delete mode 100644 lua/settings/init.lua delete mode 100644 lua/settings/lsp.lua delete mode 100644 lua/settings/luasnip.lua diff --git a/init.lua b/init.lua index 70b3702..aaa32a5 100644 --- a/init.lua +++ b/init.lua @@ -15,7 +15,6 @@ vim.g.mapleader = " " require("lazy").setup("plugins") require("maps").init() require("commands") -require("settings").init() vim.opt.backup = false vim.opt.undodir = '/Users/fschmidt/.cache/nvim/undodir' diff --git a/lazy-lock.json b/lazy-lock.json index 94a1c23..b4fe742 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,5 +1,5 @@ { - "LuaSnip": { "branch": "master", "commit": "d33cf7de14eea209b8ed4a7edaed72f0b8cedb30" }, + "LuaSnip": { "branch": "master", "commit": "f7c845749aba6096f041a73a26ba64f3817bab99" }, "bufferline.nvim": { "branch": "main", "commit": "52d6acabb79c8c0942f8873a0ca7848eb2159267" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "8fcc934a52af96120fe26358985c10c035984b53" }, @@ -8,22 +8,20 @@ "cmp-nvim-lua": { "branch": "main", "commit": "f3491638d123cfd2c8048aefaf66d246ff250ca6" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, - "dashboard-nvim": { "branch": "master", "commit": "a6e3536400c79f20d23b904a89d95efc6a6ac717" }, + "dashboard-nvim": { "branch": "master", "commit": "398ba8d9390c13c87a964cbca756319531fffdb7" }, "fidget.nvim": { "branch": "main", "commit": "688b4fec4517650e29c3e63cfbb6e498b3112ba1" }, "gitsigns.nvim": { "branch": "main", "commit": "f388995990aba04cfdc7c3ab870c33e280601109" }, - "goyo.vim": { "branch": "master", "commit": "7f5d35a65510083ea5c2d0941797244b9963d4a9" }, "kanagawa.nvim": { "branch": "master", "commit": "4c8d48726621a7f3998c7ed35b2c2535abc22def" }, "lazy.nvim": { "branch": "main", "commit": "8077428e63feb0f3bf795d53b23ba1695b28ab0e" }, - "limelight.vim": { "branch": "master", "commit": "86aaec1700b27618d33d6182f44691d84d2cb6e5" }, "lspkind-nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" }, "lualine.nvim": { "branch": "master", "commit": "e99d733e0213ceb8f548ae6551b04ae32e590c80" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "93e58e100f37ef4fb0f897deeed20599dae9d128" }, - "mason.nvim": { "branch": "main", "commit": "5b9fd3822d686092c7ee08adfcbd2c764def22c5" }, - "nvim-autopairs": { "branch": "master", "commit": "bde7a1b4534e0a4c2451a738379cd628ba65eba7" }, - "nvim-cmp": { "branch": "main", "commit": "ba7a53478d0726683d1597ad1e814695033dcb4b" }, - "nvim-lspconfig": { "branch": "master", "commit": "91998cef4b1ae3a624901d0f9c894409db24e760" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "3f9c0ea157e88b08e2d11ec65002eeb6e421f0da" }, + "mason.nvim": { "branch": "main", "commit": "63cff223169324a2e633954ac580c7c327182a97" }, + "nvim-autopairs": { "branch": "master", "commit": "6a5faeabdbcc86cfbf1561ae430a451a72126e81" }, + "nvim-cmp": { "branch": "main", "commit": "7a3b1e76f74934b12fda82158237c6ad8bfd3d40" }, + "nvim-lspconfig": { "branch": "master", "commit": "62856b20751b748841b0f3ec5a10b1e2f6a6dbc9" }, "nvim-tree.lua": { "branch": "master", "commit": "9c97e6449b0b0269bd44e1fd4857184dfa57bb4c" }, - "nvim-treesitter": { "branch": "master", "commit": "2277c0c2a7d1aca2979285621ac5c82787b25dd2" }, + "nvim-treesitter": { "branch": "master", "commit": "b4d8b7e5a374b800838a13aa6829ac4d542c6f1c" }, "nvim-web-devicons": { "branch": "master", "commit": "4709a504d2cd2680fb511675e64ef2790d491d36" }, "playground": { "branch": "master", "commit": "4044b53c4d4fcd7a78eae20b8627f78ce7dc6f56" }, "plenary.nvim": { "branch": "master", "commit": "253d34830709d690f013daf2853a9d21ad7accab" }, diff --git a/lua/maps.lua b/lua/maps.lua index 9d12ff5..43aff28 100644 --- a/lua/maps.lua +++ b/lua/maps.lua @@ -42,21 +42,6 @@ function maps.centeredSearch() map('n', 'N', 'Nzzzv') end -function maps.moveToWindow() - map('t', 'ª', 'h') - map('t', 'º', 'j') - map('t', '∆', 'k') - map('t', '@', 'l') - map('i', 'ª', 'h') - map('i', 'º', 'j') - map('i', '∆', 'k') - map('i', '@', 'l') - map('n', 'ª', 'h') - map('n', 'º', 'j') - map('n', '∆', 'k') - map('n', '@', 'l') -end - function maps.init() vim.g.mapleader = " " @@ -69,7 +54,6 @@ function maps.init() maps.fixIndent() maps.moveByRow() maps.centeredSearch() - -- maps.moveToWindow() end return maps diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index ad7537f..e8d22d1 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,14 +1,171 @@ +local opts = { noremap = true, silent = true } +vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) +vim.keymap.set('n', ',d', vim.diagnostic.goto_prev, opts) +vim.keymap.set('n', '.d', vim.diagnostic.goto_next, opts) + +local lsp_attach = function(client, buf) + vim.api.nvim_buf_set_option(buf, "formatexpr", "v:lua.vim.lsp.formatexpr()") + vim.api.nvim_buf_set_option(buf, "omnifunc", "v:lua.vim.lsp.omnifunc") + vim.api.nvim_buf_set_option(buf, "tagfunc", "v:lua.vim.lsp.tagfunc") + + local bufopts = { noremap = true, silent = true, buffer = buf } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) +end + return { -- lsp - { 'williamboman/mason.nvim' }, - { 'williamboman/mason-lspconfig.nvim' }, - { 'neovim/nvim-lspconfig' }, + { + 'williamboman/mason.nvim', + config = true + }, + { + 'williamboman/mason-lspconfig.nvim', + config = true + }, + { + 'neovim/nvim-lspconfig', + config = function() + local capabilities = require('cmp_nvim_lsp').default_capabilities() + local lspconfig = require('lspconfig') + + lspconfig.lua_ls.setup { + capabilities = capabilities, + settings = { + Lua = { + diagnostics = { + globals = { 'vim' } + } + } + }, + on_attach = lsp_attach + } + lspconfig.tsserver.setup { + capabilities = capabilities, + on_attach = lsp_attach + } + lspconfig.gopls.setup { + capabilities = capabilities, + on_attach = lsp_attach + } + --lspconfig.rust_analyzer.setup { + -- capabilities = capabilities, + -- on_attach = lsp_attach + --} + require("rust-tools").setup({ + server = { + capabilities = capabilities, + on_attach = lsp_attach, + standalone = false + } + }) + lspconfig.bashls.setup { + capabilities = capabilities, + on_attach = lsp_attach + } + lspconfig.sqlls.setup({ + capabilities = capabilities, + on_attach = lsp_attach + }) + lspconfig.html.setup({ + capabilities = capabilities, + on_attach = lsp_attach + }) + lspconfig.cssls.setup({ + capabilities = capabilities, + on_attach = lsp_attach + }) + lspconfig.tailwindcss.setup({ + capabilities = capabilities, + on_attach = lsp_attach + }) + capabilities.textDocument.completion.completionItem.snippetSupport = true + lspconfig.emmet_ls.setup({ + capabilities = capabilities, + on_attach = lsp_attach + }) + end + }, { 'simrat39/rust-tools.nvim' }, { 'onsails/lspkind-nvim' }, -- pictograms replace (?) with lspsaga { 'j-hui/fidget.nvim' }, -- show lsp status -- completion { 'hrsh7th/nvim-cmp', + config = function() + local cmp = require('cmp') + local lspkind = require('lspkind') + + vim.opt.shortmess:append 'c' + + cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, + [""] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, + [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true + }), + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [''] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lua' }, + { name = 'nvim_lsp' }, + { name = 'path' }, + { name = 'luasnip' }, + { name = 'nvim_lsp_signature_help' }, + }, { + { name = 'buffer', keyword_length = 5 }, + }), + formatting = { + format = lspkind.cmp_format { + with_text = true, + menu = { + buffer = "[buf]", + nvim_lsp = "[LSP]", + nvim_lua = "[api]", + path = "[path]", + luasnip = "[snip]", + } + } + } + }) + + -- Use buffer source for `/` (basically search words in buffer) + cmp.setup.cmdline('/', { + sources = { + { name = 'buffer' } + } + }) + + -- Use cmdline & path source for ':' + cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) + }) + end, event = 'InsertEnter', dependencies = { 'hrsh7th/cmp-nvim-lsp', @@ -17,12 +174,19 @@ return { 'hrsh7th/cmp-path', 'hrsh7th/cmp-nvim-lua', 'hrsh7th/cmp-cmdline', - -- snippets needed for cmp - 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip', - 'windwp/nvim-autopairs', } - } + }, + { + 'L3MON4D3/LuaSnip', + config = function() + require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets/" }) + end + }, + { + 'windwp/nvim-autopairs', + config = true + }, } -- -- Linting & formtatting -- 'jose-elias-alvarez/null-ls.nvim'; diff --git a/lua/plugins/navigation.lua b/lua/plugins/navigation.lua index 0ebb5da..51d38d1 100644 --- a/lua/plugins/navigation.lua +++ b/lua/plugins/navigation.lua @@ -6,7 +6,7 @@ return { }, { 'nvim-tree/nvim-tree.lua', - config = function () + config = function() require('nvim-tree').setup { disable_netrw = true, hijack_netrw = true, diff --git a/lua/plugins/writing.lua b/lua/plugins/writing.lua index 5c5fb3d..615ad98 100644 --- a/lua/plugins/writing.lua +++ b/lua/plugins/writing.lua @@ -2,10 +2,11 @@ return { -- writing { 'vimwiki/vimwiki', + ft = { 'md', 'wiki', 'tex' }, config = function() vim.g.vimwiki_list = { { path = '~/Documents/Buch/wiki', syntax = 'markdown', ext = '.md' } } end }, - { 'junegunn/goyo.vim' }, -- try raplcing these 2 at some point because they don't work that well anymore - { 'junegunn/limelight.vim' }, + --{ 'junegunn/goyo.vim' }, -- try replacing these 2 at some point because they don't work that well anymore + --{ 'junegunn/limelight.vim' }, } diff --git a/lua/settings/completion.lua b/lua/settings/completion.lua deleted file mode 100644 index 05b4e99..0000000 --- a/lua/settings/completion.lua +++ /dev/null @@ -1,73 +0,0 @@ --- Completion - -local completion = {} -local cmp = require('cmp') -local lspkind = require('lspkind') - -vim.opt.shortmess:append 'c' - -cmp.setup({ - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, - [""] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, - [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true - }), - [''] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - [''] = cmp.mapping.confirm({ select = true }), - }), - sources = cmp.config.sources({ - { name = 'nvim_lua' }, - { name = 'nvim_lsp' }, - { name = 'path' }, - { name = 'luasnip' }, - { name = 'nvim_lsp_signature_help' }, - }, { - { name = 'buffer', keyword_length = 5 }, - }), - formatting = { - format = lspkind.cmp_format { - with_text = true, - menu = { - buffer = "[buf]", - nvim_lsp = "[LSP]", - nvim_lua = "[api]", - path = "[path]", - luasnip = "[snip]", - } - } - } -}) - --- Use buffer source for `/` (basically search words in buffer) -cmp.setup.cmdline('/', { - sources = { - { name = 'buffer' } - } -}) - --- Use cmdline & path source for ':' -cmp.setup.cmdline(':', { - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }) -}) - --- autopair -require('nvim-autopairs').setup {} - -return completion diff --git a/lua/settings/init.lua b/lua/settings/init.lua deleted file mode 100644 index cfdfd3d..0000000 --- a/lua/settings/init.lua +++ /dev/null @@ -1,11 +0,0 @@ --- settings.lua - -local settings = {} - -function settings.init() - require('settings.lsp').init() - require('settings.completion') - require('settings.luasnip') -end - -return settings diff --git a/lua/settings/lsp.lua b/lua/settings/lsp.lua deleted file mode 100644 index 38d778c..0000000 --- a/lua/settings/lsp.lua +++ /dev/null @@ -1,91 +0,0 @@ --- LSP Config - -local lsp = {} - -local opts = { noremap = true, silent = true } -vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) -vim.keymap.set('n', ',d', vim.diagnostic.goto_prev, opts) -vim.keymap.set('n', '.d', vim.diagnostic.goto_next, opts) - -local lsp_attach = function(client, buf) - vim.api.nvim_buf_set_option(buf, "formatexpr", "v:lua.vim.lsp.formatexpr()") - vim.api.nvim_buf_set_option(buf, "omnifunc", "v:lua.vim.lsp.omnifunc") - vim.api.nvim_buf_set_option(buf, "tagfunc", "v:lua.vim.lsp.tagfunc") - - local bufopts = { noremap = true, silent = true, buffer = buf } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) - vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) -end - -function lsp.init() - require('mason').setup() - require('mason-lspconfig').setup() - - local capabilities = require('cmp_nvim_lsp').default_capabilities() - local lspconfig = require('lspconfig') - - lspconfig.sumneko_lua.setup { - capabilities = capabilities, - settings = { - Lua = { - diagnostics = { - globals = { 'vim' } - } - } - }, - on_attach = lsp_attach - } - lspconfig.tsserver.setup { - capabilities = capabilities, - on_attach = lsp_attach - } - lspconfig.gopls.setup { - capabilities = capabilities, - on_attach = lsp_attach - } - --lspconfig.rust_analyzer.setup { - -- capabilities = capabilities, - -- on_attach = lsp_attach - --} - require("rust-tools").setup({ - server = { - capabilities = capabilities, - on_attach = lsp_attach, - standalone = false - } - }) - lspconfig.bashls.setup { - capabilities = capabilities, - on_attach = lsp_attach - } - lspconfig.sqlls.setup({ - capabilities = capabilities, - on_attach = lsp_attach - }) - lspconfig.html.setup({ - capabilities = capabilities, - on_attach = lsp_attach - }) - lspconfig.cssls.setup({ - capabilities = capabilities, - on_attach = lsp_attach - }) - lspconfig.tailwindcss.setup({ - capabilities = capabilities, - on_attach = lsp_attach - }) - capabilities.textDocument.completion.completionItem.snippetSupport = true - lspconfig.emmet_ls.setup({ - capabilities = capabilities, - on_attach = lsp_attach - }) -end - -return lsp diff --git a/lua/settings/luasnip.lua b/lua/settings/luasnip.lua deleted file mode 100644 index 6f5c7ba..0000000 --- a/lua/settings/luasnip.lua +++ /dev/null @@ -1,3 +0,0 @@ -local ls = require("luasnip") - -require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets/" })