From 07a49ce2d25cdc388159664d9bfbb460b66e2c50 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sat, 2 Mar 2024 20:21:23 +0100 Subject: [PATCH] update nvim config --- nvim/README.md | 2 +- nvim/lazy-lock.json | 11 ++++-- nvim/lua/config/settings.lua | 10 ++--- nvim/lua/config/telescope.lua | 8 ++++ nvim/lua/plugins/colorscheme.lua | 17 +++++++- nvim/lua/plugins/dashboard.lua | 27 +++++++++++++ nvim/lua/plugins/gitsigns.lua | 8 +++- nvim/lua/plugins/go.lua | 14 +++++++ nvim/lua/plugins/indent.lua | 14 +++++-- nvim/lua/plugins/init.lua | 10 ++++- nvim/lua/plugins/lsp.lua | 46 +++++++++++++++------- nvim/lua/plugins/mini-comment.lua | 7 ++++ nvim/lua/plugins/{cmp.lua => nvim-cmp.lua} | 0 nvim/lua/plugins/nvim-test.lua | 3 ++ nvim/lua/plugins/telescope.lua | 5 +-- nvim/lua/plugins/treesitter.lua | 21 +++++----- 16 files changed, 157 insertions(+), 46 deletions(-) create mode 100644 nvim/lua/config/telescope.lua create mode 100644 nvim/lua/plugins/dashboard.lua create mode 100644 nvim/lua/plugins/go.lua create mode 100644 nvim/lua/plugins/mini-comment.lua rename nvim/lua/plugins/{cmp.lua => nvim-cmp.lua} (100%) create mode 100644 nvim/lua/plugins/nvim-test.lua diff --git a/nvim/README.md b/nvim/README.md index 6653795..d25af65 100644 --- a/nvim/README.md +++ b/nvim/README.md @@ -2,4 +2,4 @@ Just my vim config. -Run `:PlugInstall` to install all plugins. +Run `:Lazy` to install all plugins. diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 721ab23..3924035 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -4,7 +4,10 @@ "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "dashboard": { "branch": "master", "commit": "413442b12d85315fc626c44a0ce4929b213ef604" }, "gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" }, + "go.nvim": { "branch": "master", "commit": "8efd0c89f2305a6840a99d7823c40cc3acea91d6" }, + "guihua.lua": { "branch": "master", "commit": "9fb6795474918b492d9ab01b1ebaf85e8bf6fe0b" }, "indent-blankline.nvim": { "branch": "master", "commit": "821a7acd88587d966f7e464b0b3031dfe7f5680c" }, "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, "lspkind-nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, @@ -12,13 +15,15 @@ "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "21d33d69a81f6351e5a5f49078b2e4f0075c8e73" }, "mason.nvim": { "branch": "main", "commit": "3b5068f0fc565f337d67a2d315d935f574848ee7" }, + "mini.comment": { "branch": "main", "commit": "a4b7e46deb9ad2feb8902cc5dbf087eced112ee5" }, "neo-tree.nvim": { "branch": "main", "commit": "459c60317cc1d251f6eb3b6f010d015d5d24b806" }, "nui.nvim": { "branch": "main", "commit": "c3c7fd618dcb5a89e443a2e1033e7d11fdb0596b" }, "nvim-autopairs": { "branch": "master", "commit": "c6139ca0d5ad7af129ea6c89cb4c56093f2c034a" }, "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, - "nvim-lspconfig": { "branch": "master", "commit": "b1a11b042d015df5b8f7f33aa026e501b639c649" }, - "nvim-treesitter": { "branch": "master", "commit": "db12bd416e2764420047e4a5d6b96fe44e4377d5" }, - "nvim-web-devicons": { "branch": "master", "commit": "0bb67ef952ea3eb7b1bac9c011281471d99a27bc" }, + "nvim-lspconfig": { "branch": "master", "commit": "9553725789be682ecd945a527ec552e489ea8534" }, + "nvim-test": { "branch": "main", "commit": "e06f3d029ee161f3ead6193cf27354d1eb8723c3" }, + "nvim-treesitter": { "branch": "master", "commit": "c2a265156d5799adbd9f9e7d5385735fa5d21776" }, + "nvim-web-devicons": { "branch": "master", "commit": "69fb193abc547c77be089c3e392d5fd6fcd3625a" }, "onedark.nvim": { "branch": "master", "commit": "1230aaf2a427b2c5b73aba6e4a9a5881d3e69429" }, "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, diff --git a/nvim/lua/config/settings.lua b/nvim/lua/config/settings.lua index 3d0c979..195b57a 100644 --- a/nvim/lua/config/settings.lua +++ b/nvim/lua/config/settings.lua @@ -3,20 +3,20 @@ -- vim.opt.showmode = false -- disable mode in the command line, because i use lualine ---vim.opt.guicursor = "a:ver100,c-ci-cr:hor80-blinkon100-blinkwait300" ---vim.opt.scrolloff = 30 ---vim.opt.sidescrolloff = 8 -- -- Editor settings -- -vim.opt.cursorline = true -- highlight line where cursor is. +vim.opt.scrolloff=20 +--vim.opt.sidescrolloff = 8 +vim.opt.cursorline = true -- line numbers vim.opt.number = true vim.opt.relativenumber = true -vim.opt.numberwidth = 6 +vim.opt.numberwidth = 5 +vim.opt.statuscolumn = '%=%{v:relnum?v:relnum:v:lnum} %s ' -- indent vim.opt.smartindent = true diff --git a/nvim/lua/config/telescope.lua b/nvim/lua/config/telescope.lua new file mode 100644 index 0000000..7d21ad2 --- /dev/null +++ b/nvim/lua/config/telescope.lua @@ -0,0 +1,8 @@ +return { + { 'sf', 'Telescope find_files', desc = 'Search files' }, + { 'sg', 'Telescope git_files', desc = 'Search Git files' }, + { 'sw', 'Telescope grep_string', desc = 'Search Word' }, + -- LSP + --{ 'gd', 'Telescope lsp_definitions', desc = 'Goto definition' }, +} + diff --git a/nvim/lua/plugins/colorscheme.lua b/nvim/lua/plugins/colorscheme.lua index 37e4a51..a4e0a86 100644 --- a/nvim/lua/plugins/colorscheme.lua +++ b/nvim/lua/plugins/colorscheme.lua @@ -20,6 +20,7 @@ return { red = '#cc817f', green = '#7ccfaf', yellow = '#ffcc99', + orange = '#ffcc99', blue = '#8ac6f2', cyan = '#8abeb7', purple = '#9999cc' @@ -28,9 +29,23 @@ return { ["@string"] = { fg = "$purple" }, ["@function"] = { fg = "$fg" }, ["@keyword"] = { fg = "$yellow" }, + ["@keyword.import"] = { fg = "$yellow" }, + ["@keyword.function"] = { fg = "$yellow" }, + ["@keyword.conditional"] = { fg = "$yellow" }, + ["@keyword.operator"] = { fg = "$yellow" }, + ["@type"] = { fg = "$blue" }, + ["@type.qualifier"] = { fg = "$yellow" }, + ["@type.definition"] = { fg = "$blue" }, + ["@type.builtin"] = { fg = "$blue" }, + ["@function.method"] = { fg = "$fg" }, + ["@number"] = { fg = "$red" }, + ["@variable"] = { fg = "$green" }, + ["@variable.builtin"] = { fg = "$green" }, ["@variable.parameter"] = { fg = "$fg" }, + ["@property"] = { fg = "$green" }, ["@punctuation.delimiter"] = { fg = "$fg" }, - ["@punctuation.bracket"] = { fg = "$fg" } + ["@punctuation.bracket"] = { fg = "$fg" }, + ["@module"] = { fg = "$fg" }, } }, config = function(_, opts) diff --git a/nvim/lua/plugins/dashboard.lua b/nvim/lua/plugins/dashboard.lua new file mode 100644 index 0000000..08470ad --- /dev/null +++ b/nvim/lua/plugins/dashboard.lua @@ -0,0 +1,27 @@ +return { + 'nvimdev/dashboard-nvim', + name = 'dashboard', + dependencies = { + 'nvim-tree/nvim-web-devicons' + }, + event = 'VimEnter', + opts = { + config = { + header = { + '::::::::: :::: ::: ::: :::', + ':+: :+: :+:+: :+: :+: :+:', + '+:+ +:+ :+:+:+ +:+ +:+ +:+ ', + '+#++:++#+ +#+ +:+ +#+ +#++:+ ', + '+#+ +#+ +#+#+# +#+ +#+ ', + '#+# #+# #+#+# #+# #+#', + '### ### #### ### ###', + '', + }, + shortcut = { + { desc = '󰊳 Update', group = '@property', action = 'Lazy update', key = 'u' } + }, + footer = {} + } + } +} + diff --git a/nvim/lua/plugins/gitsigns.lua b/nvim/lua/plugins/gitsigns.lua index 2c9cb41..78c4156 100644 --- a/nvim/lua/plugins/gitsigns.lua +++ b/nvim/lua/plugins/gitsigns.lua @@ -1,11 +1,15 @@ return { 'lewis6991/gitsigns.nvim', lazy = false, + keys = { + { 'gp', 'Gitsigns preview_hunk', desc = 'Git preview diff' }, + { 'gb', 'Gitsigns blame_line', desc = 'Git blame' } + }, opts = { signs = { - add = { text = '│' }, + add = { text = '▌' }, delete = { text = '' }, - change = { text = '│' }, + change = { text = '▌' }, untracked = { text = '+'} }, }, diff --git a/nvim/lua/plugins/go.lua b/nvim/lua/plugins/go.lua new file mode 100644 index 0000000..62854b8 --- /dev/null +++ b/nvim/lua/plugins/go.lua @@ -0,0 +1,14 @@ +return { + "ray-x/go.nvim", + dependencies = { + "ray-x/guihua.lua", + "neovim/nvim-lspconfig", + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require("go").setup() + end, + event = {"CmdlineEnter"}, + ft = {"go", 'gomod'}, + build = ':lua require("go.install").update_all_sync()' +} diff --git a/nvim/lua/plugins/indent.lua b/nvim/lua/plugins/indent.lua index f73eb17..ca587a4 100644 --- a/nvim/lua/plugins/indent.lua +++ b/nvim/lua/plugins/indent.lua @@ -1,10 +1,16 @@ return { - "lukas-reineke/indent-blankline.nvim", - main = "ibl", + "lukas-reineke/indent-blankline.nvim", + main = "ibl", opts = { scope = { enabled = true, - show_exact_scope = true + show_exact_scope = true, + }, + exclude = { + filetypes = { + 'help', + 'dashboard' + } } - }, + } } diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua index fa06645..39b612f 100644 --- a/nvim/lua/plugins/init.lua +++ b/nvim/lua/plugins/init.lua @@ -13,11 +13,14 @@ vim.opt.rtp:prepend(lazypath) require("lazy").setup({ + { import = "plugins.dashboard" }, + -- Highlight { import = "plugins.colorscheme" }, { import = "plugins.indent" }, { import = "plugins.nvim-autopairs" }, + { import = "plugins.mini-comment" }, -- Filetree { import = "plugins.neo-tree" }, @@ -30,12 +33,17 @@ require("lazy").setup({ -- Keybind helper { import = "plugins.which-key" }, - + -- Treesitter { import = "plugins.treesitter" }, -- LSP { import = "plugins.lsp" }, + { import = "plugins.nvim-cmp" }, + + { import = "plugins.go" }, + + { import = "plugins.nvim-test" }, -- Git changes in gutter { import = "plugins.gitsigns" }, diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index b6ff79e..8911148 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -3,7 +3,6 @@ return { dependencies = { 'williamboman/mason.nvim', 'williamboman/mason-lspconfig.nvim', - require('plugins.cmp') }, config = function() -- Setup Mason to automatically install LSP servers @@ -12,25 +11,19 @@ return { local lspconfig = require('lspconfig') -- local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) - -- PHP - lspconfig.intelephense.setup({ - commands = { - IntelephenseIndex = { - function() vim.lsp.buf.execute_command({ command = 'intelephense.index.workspace' }) end, - }, - }, - on_attach = function(client, bufnr) - client.server_capabilities.documentFormattingProvider = false - client.server_capabilities.documentRangeFormattingProvider = false - end, - -- capabilities = capabilities + -- php - phpactor + lspconfig.phpactor.setup({ + init_options = { + ["language_server_phpstan.enabled"] = true, + ["language_server_psalm.enabled"] = false, + } }) -- GO lspconfig.gopls.setup({}) -- Tailwind CSS --require('lspconfig').tailwindcss.setup({ capabilities = capabilities }) - + -- Format on save. vim.api.nvim_create_autocmd("BufWritePre", { pattern = '*.go', @@ -41,7 +34,30 @@ return { -- Typescript lspconfig.tsserver.setup({}) - + + -- lua + lspconfig.lua_ls.setup({ + on_init = function(client) + local path = client.workspace_folders[1].name + if not vim.loop.fs_stat(path..'/.luarc.json') and not vim.loop.fs_stat(path..'/.luarc.jsonc') then + client.config.settings = vim.tbl_deep_extend('force', client.config.settings, { + Lua = { + runtime = { + version = 'LuaJIT' + }, + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME + } + } + } + }) + end + return true + end + }) + -- Config -- Sign configuration vim.fn.sign_define('DiagnosticSignError', { text = '', texthl = 'DiagnosticSignError' }) diff --git a/nvim/lua/plugins/mini-comment.lua b/nvim/lua/plugins/mini-comment.lua new file mode 100644 index 0000000..5781c88 --- /dev/null +++ b/nvim/lua/plugins/mini-comment.lua @@ -0,0 +1,7 @@ +return { + 'echasnovski/mini.comment', + version = '*', + config = function() + require('mini.comment').setup({}) + end +} diff --git a/nvim/lua/plugins/cmp.lua b/nvim/lua/plugins/nvim-cmp.lua similarity index 100% rename from nvim/lua/plugins/cmp.lua rename to nvim/lua/plugins/nvim-cmp.lua diff --git a/nvim/lua/plugins/nvim-test.lua b/nvim/lua/plugins/nvim-test.lua new file mode 100644 index 0000000..6ad147d --- /dev/null +++ b/nvim/lua/plugins/nvim-test.lua @@ -0,0 +1,3 @@ +return { + "klen/nvim-test", +} diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index 1e7901d..1132d42 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -5,10 +5,7 @@ return { 'nvim-lua/plenary.nvim', 'kyazdani42/nvim-web-devicons' }, - keys = { - { 'f', function() require('telescope.builtin').find_files() end }, - { 'F', function() require('telescope.builtin').git_files() end }, - }, + keys = require('config.telescope'), config = function() require('telescope').setup({ defaults = { diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua index 046b1de..d14a2d5 100644 --- a/nvim/lua/plugins/treesitter.lua +++ b/nvim/lua/plugins/treesitter.lua @@ -10,18 +10,19 @@ return { -- A list of parser names ensure_installed = { "bash", - "c", + "c", "cpp", "ninja", "cmake", - "lua", - "vim", + "make", + "lua", + "vim", "vimdoc", - "query", + "query", "php", "blade", - "go", - "javascript", + "go", + "javascript", "typescript", "css", "scss", @@ -33,7 +34,7 @@ return { "toml", "xml", "glsl", - "hlsl", + "hlsl", "markdown" }, @@ -54,9 +55,9 @@ return { additional_vim_regex_highlighting = false, }, - indent = { - enable = true - } + -- indent = { + -- enable = true + --} }, config = function(_, opts) local parser_config = require('nvim-treesitter.parsers').get_parser_configs()