From fc6be19a2da0614f2a15536fccf06dec9da6f3c2 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sat, 8 Jun 2024 16:50:16 +0200 Subject: [PATCH] more nvim --- nvim/.luarc.json | 7 + nvim/lazy-lock.json | 39 ++-- nvim/lua/config/autocmd.lua | 1 + nvim/lua/config/cmp.lua | 13 +- nvim/lua/config/keymaps.lua | 11 +- nvim/lua/config/lsp.lua | 148 +++++++------- nvim/lua/config/treesitter.lua | 3 +- nvim/lua/plugins/core.lua | 362 +++++++++++++++++---------------- nvim/lua/plugins/lsp.lua | 9 +- nvim/lua/utils/oil.lua | 17 ++ 10 files changed, 337 insertions(+), 273 deletions(-) create mode 100644 nvim/.luarc.json create mode 100644 nvim/lua/utils/oil.lua diff --git a/nvim/.luarc.json b/nvim/.luarc.json new file mode 100644 index 0000000..6b7e08b --- /dev/null +++ b/nvim/.luarc.json @@ -0,0 +1,7 @@ +{ + "runtime.version": "LuaJIT", + "runtime.path": ["lua/?.lua", "lua/?/init.lua"], + "diagnostics.globals": ["vim"], + "workspace.checkThirdParty": false, + "workspace.library": ["$VIMRUNTIME", "./lua"] +} diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 600f13a..65cb71d 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -1,32 +1,33 @@ { - "LuaSnip": { "branch": "master", "commit": "de1a287c9cb525ae52bc846e8f6207e5ef1da5ac" }, - "catppuccin": { "branch": "main", "commit": "d97387aea8264f484bb5d5e74f2182a06c83e0d8" }, + "LuaSnip": { "branch": "master", "commit": "50fcf17db7c75af80e6b6109acfbfb4504768780" }, + "catppuccin": { "branch": "main", "commit": "5215ea59df6d0a7e27da9a5cd1165e06d1b04cbe" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "b8f3ed3903430033f638b17f7455b8fd3d6a85b5" }, - "fd": { "branch": "master", "commit": "29936f0fbae1e52984ab582b2b2c98685d6ad638" }, - "gitsigns.nvim": { "branch": "main", "commit": "805610a9393fa231f2c2b49cb521bfa413fadb3d" }, - "indent-blankline.nvim": { "branch": "master", "commit": "ece00d5fb44d196680a81fd2761062d2fa44663b" }, - "lazy.nvim": { "branch": "main", "commit": "8f19915175395680808de529e4220da8dafc0759" }, - "lsp-zero.nvim": { "branch": "v3.x", "commit": "f12d50716e8e59ea9f5cf484eac6968c33a95917" }, + "conform.nvim": { "branch": "master", "commit": "069e971295a34a810484b7b2ef54b3c735214181" }, + "fd": { "branch": "master", "commit": "be815c261ace9cd0026cff5c8a579cda094e10fd" }, + "gitsigns.nvim": { "branch": "main", "commit": "4a143f13e122ab91abdc88f89eefbe70a4858a56" }, + "indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" }, + "lazy.nvim": { "branch": "main", "commit": "eb4957442e3182f051b0ae11da32e06d22c190e3" }, + "lsp-zero.nvim": { "branch": "v3.x", "commit": "16de3b18c5f7b6230d89b8e64ce9a4801b6f8d08" }, "lspkind-nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, "lualine-lsp-progress": { "branch": "master", "commit": "56842d097245a08d77912edf5f2a69ba29f275d7" }, "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, - "none-ls.nvim": { "branch": "main", "commit": "37671797d6e5f9bd0ee3ab965ab2e6de251e1930" }, + "mini.nvim": { "branch": "main", "commit": "cc2f5b542c38b2af234b62196fa5a8621119fb0c" }, + "none-ls.nvim": { "branch": "main", "commit": "8691504118b252d64fc5023a104aedd100ab754a" }, "nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" }, "nvim-cmp": { "branch": "main", "commit": "5260e5e8ecadaf13e6b82cf867a909f54e15fd07" }, - "nvim-lspconfig": { "branch": "master", "commit": "0b8165cf95806bc4bb8f745bb0c92021b2ed4b98" }, - "nvim-treesitter": { "branch": "master", "commit": "73fb37ed77b18ac357ca8e6e35835a8db6602332" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "5f9bf4b1ead7707e4e74e5319ee56bdc81fb73db" }, - "nvim-ts-autotag": { "branch": "main", "commit": "62db4b3054ec6847e5cb189b4dea452ce0c7ad7f" }, - "nvim-web-devicons": { "branch": "master", "commit": "e37bb1feee9e7320c76050a55443fa843b4b6f83" }, - "oil.nvim": { "branch": "master", "commit": "06a19f77f1a1da37b675635e6f9c5b5d50bcaacd" }, + "nvim-lspconfig": { "branch": "master", "commit": "92166b89ab4b3d60f24e58170cac53b7141fd032" }, + "nvim-treesitter": { "branch": "master", "commit": "c5cbd3ec74f6f5ddbac939e6f24b99fe78262b4c" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, + "nvim-ts-autotag": { "branch": "main", "commit": "6eb4120a1aadef07ac312f1c4bc6456712220007" }, + "nvim-web-devicons": { "branch": "master", "commit": "b4b302d6ae229f67df7a87ef69fa79473fe788a9" }, + "oil.nvim": { "branch": "master", "commit": "e5312c3a801e7274fa14e6a56aa10a618fed80c3" }, "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "master", "commit": "4aed63995a69e343b068c7469491a8d1592c339f" }, - "trouble.nvim": { "branch": "main", "commit": "a8264a65a0b894832ea642844f5b7c30112c458f" }, - "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } + "telescope.nvim": { "branch": "master", "commit": "dfa230be84a044e7f546a6c2b0a403c739732b86" }, + "trouble.nvim": { "branch": "main", "commit": "38915023a777b7f2422e503dc603f6a64b465bf5" }, + "vim-fugitive": { "branch": "master", "commit": "4f59455d2388e113bd510e85b310d15b9228ca0d" }, + "which-key.nvim": { "branch": "main", "commit": "0099511294f16b81c696004fa6a403b0ae61f7a0" } } \ No newline at end of file diff --git a/nvim/lua/config/autocmd.lua b/nvim/lua/config/autocmd.lua index 35de7d9..fd69d39 100644 --- a/nvim/lua/config/autocmd.lua +++ b/nvim/lua/config/autocmd.lua @@ -15,3 +15,4 @@ autocmd('TextYankPost', { autocmd('BufWritePre', { command = [[:exe 'norm m`' | %s/\s\+$//eg | norm ``]] }) + diff --git a/nvim/lua/config/cmp.lua b/nvim/lua/config/cmp.lua index a61900a..4a038ca 100644 --- a/nvim/lua/config/cmp.lua +++ b/nvim/lua/config/cmp.lua @@ -11,8 +11,7 @@ return function() local windowstyle = { border = vim.g.float_border or "none", winhighlight = "Normal:Pmenu,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None", - - } + } return { preselect = false, @@ -21,12 +20,12 @@ return function() }, view = { entries = { name = "custom", selection_order = "near_cursor" }, - }, + }, window = { documentation = windowstyle, completion = vim.tbl_deep_extend("force", windowstyle, { - scrolloff = 4, - }), + scrolloff = 4, + }), }, mapping = { [""] = selectPrev, @@ -52,8 +51,8 @@ return function() }), }, sources = { - { name = "nvim_lsp" }, - { name = "luasnip" }, + { name = "nvim_lsp" }, + -- { name = "luasnip" }, { name = "buffer" }, { name = "path" }, { diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua index 97ace17..c48b41d 100644 --- a/nvim/lua/config/keymaps.lua +++ b/nvim/lua/config/keymaps.lua @@ -113,9 +113,18 @@ return { { 'ff', "Format", desc = 'Format file' }, { 'ff', "Format", mode = 'x', desc = 'Format selection' }, }, + fugitive = { + { 'gB', 'Git blame', desc = 'Git blame' }, + { 'gs', 'Git status', desc = 'Git status' }, + { 'gl', 'Git log', desc = 'Git log' }, + { 'gL', 'Git log %', desc = 'Git log current file' }, + }, gitsigns = { { 'gp', 'Gitsigns preview_hunk', desc = 'Git preview diff' }, - { 'gb', 'Gitsigns blame_line', desc = 'Git blame' } + { 'gb', 'Gitsigns blame_line', desc = 'Git blame line' } + }, + trouble = { + { 'dt', 'Trouble diagnostics toggle', desc = 'Trouble diagnostics' }, }, -- Keybinds for buffers with an LSP client attached lsp = { diff --git a/nvim/lua/config/lsp.lua b/nvim/lua/config/lsp.lua index ab13376..64af92c 100644 --- a/nvim/lua/config/lsp.lua +++ b/nvim/lua/config/lsp.lua @@ -1,69 +1,81 @@ -vim.g.lsp_zero_ui_float_border = vim.g.float_border or 'none' +vim.g.lsp_zero_ui_float_border = vim.g.float_border or "none" return { - document_highlight = true, - nonels = function() - local null_ls = require("null-ls") - return { - --null_ls.builtins.completion.luasnip, - null_ls.builtins.code_actions.impl, - null_ls.builtins.code_actions.gitsigns, - null_ls.builtins.diagnostics.phpstan, - } - end, - servers = { - -- Bash - bashls = {}, - -- PHP - -- intelephense = {}, - phpactor = { - settings = { - init_options = { - ["language_server_phpstan.enabled"] = true, - ["language_server_psalm.enabled"] = false, - } - } - }, - -- - -- - -- JS,TS,VUE - volar = { - filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json' } - }, - -- TailwindCSS - tailwindcss = {}, - -- GO - gopls = { - on_save = function() - local params = vim.lsp.util.make_range_params() - params.context = { only = { "source.organizeImports" } } - local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 1000) - for cid, res in pairs(result or {}) do - for _, r in pairs(res.result or {}) do - if r.edit then - local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or "utf-16" - vim.lsp.util.apply_workspace_edit(r.edit, enc) - end - end - end - vim.lsp.buf.format({ async = false }) - end, - settings = { - gopls = { - analyses = { - unusedvariable = true, - unusedwrite = true, - useany = true - }, - gofumpt = true, - }, - }, - }, - -- Lua - lua_ls = { - cmd = {"/opt/luals/bin/lua-language-server", "--logpath=~/.local/luals/logs"}, - settings = { - Lua = { + document_highlight = true, + nonels = function() + local null_ls = require("null-ls") + return { + --null_ls.builtins.completion.luasnip, + null_ls.builtins.code_actions.impl, + null_ls.builtins.code_actions.gitsigns, + null_ls.builtins.diagnostics.phpstan, + } + end, + servers = { + -- Bash + bashls = {}, + -- PHP + -- intelephense = {}, + phpactor = { + settings = { + init_options = { + ["language_server_phpstan.enabled"] = true, + ["language_server_psalm.enabled"] = false, + }, + }, + }, + -- JS,TS,VUE + tsserver = { + document_highlight = false, + settings = { + tsserver_plugins = { + "@vue/typescript-plugin", + }, + }, + filetypes = { "javascript", "typescript", "vue" }, + }, + volar = { + init_options = { + vue = { + hybridMode = false, + }, + }, + filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue", "json" }, + }, + -- TailwindCSS + tailwindcss = {}, + -- GO + gopls = { + on_save = function() + local params = vim.lsp.util.make_range_params() + params.context = { only = { "source.organizeImports" } } + local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 1000) + for cid, res in pairs(result or {}) do + for _, r in pairs(res.result or {}) do + if r.edit then + local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or "utf-16" + vim.lsp.util.apply_workspace_edit(r.edit, enc) + end + end + end + vim.lsp.buf.format({ async = false }) + end, + settings = { + gopls = { + analyses = { + unusedvariable = true, + unusedwrite = true, + useany = true, + }, + gofumpt = true, + }, + }, + }, + -- Lua + lua_ls = { + cmd = { "/opt/luals/bin/lua-language-server", "--logpath=~/.local/luals/logs" }, + settings = { + Lua = { runtime = { version = 'LuaJIT' }, @@ -73,8 +85,8 @@ return { vim.env.VIMRUNTIME } } - }, - }, - }, - }, + } + } + }, + }, } diff --git a/nvim/lua/config/treesitter.lua b/nvim/lua/config/treesitter.lua index f725696..779c9dc 100644 --- a/nvim/lua/config/treesitter.lua +++ b/nvim/lua/config/treesitter.lua @@ -31,7 +31,8 @@ return { "xml", "glsl", "hlsl", - "markdown" + "markdown", + "markdown_inline" }, -- Install parsers synchronously (only applied to `ensure_installed`) diff --git a/nvim/lua/plugins/core.lua b/nvim/lua/plugins/core.lua index 12de16a..630ce57 100644 --- a/nvim/lua/plugins/core.lua +++ b/nvim/lua/plugins/core.lua @@ -1,183 +1,199 @@ -local keys = require('config.keymaps') +local keys = require("config.keymaps") return { - -- colorscheme - { - "catppuccin/nvim", - name = "catppuccin", - priority = 1000, - config = function() - require("catppuccin").setup(require('config.colorscheme')) - vim.cmd.colorscheme("catppuccin") - end - }, - { - "folke/which-key.nvim", - event = "VeryLazy", - init = function() - vim.o.timeout = true - vim.o.timeoutlen = 300 - end, - opts = function() return { - defaults = keys.whichkey - } end, - config = function(_, opts) - local wk = require("which-key") - wk.setup(opts) - wk.register(opts.defaults or {}) - end - }, - { - 'nvim-treesitter/nvim-treesitter', - build = function() - require('nvim-treesitter.install').update({ with_sync = true }) - end, - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - 'nvim-treesitter/playground' - }, - opts = require('config.treesitter'), - config = function(_, opts) - local parser_config = require('nvim-treesitter.parsers').get_parser_configs() + -- colorscheme + { + "catppuccin/nvim", + name = "catppuccin", + priority = 1000, + config = function() + require("catppuccin").setup(require("config.colorscheme")) + vim.cmd.colorscheme("catppuccin") + end, + }, + { + "folke/which-key.nvim", + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + end, + opts = function() + return { + defaults = keys.whichkey, + } + end, + config = function(_, opts) + local wk = require("which-key") + wk.setup(opts) + wk.register(opts.defaults or {}) + end, + }, + { + "nvim-treesitter/nvim-treesitter", + build = function() + require("nvim-treesitter.install").update({ with_sync = true }) + end, + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + "nvim-treesitter/playground", + }, + opts = require("config.treesitter"), + config = function(_, opts) + local parser_config = require("nvim-treesitter.parsers").get_parser_configs() - parser_config.blade = { - install_info = { - url = 'https://github.com/EmranMR/tree-sitter-blade', - branch = "main", - files = { 'src/parser.c' }, - generate_requires_npm = true, - requires_generate_from_grammar = true, - }, - filetype = 'blade', - } + parser_config.blade = { + install_info = { + url = "https://github.com/EmranMR/tree-sitter-blade", + branch = "main", + files = { "src/parser.c" }, + generate_requires_npm = true, + requires_generate_from_grammar = true, + }, + filetype = "blade", + } - require("nvim-treesitter.configs").setup(opts) - end, - }, - { - 'windwp/nvim-autopairs', - event = "InsertEnter", - config = true - }, - { - "windwp/nvim-ts-autotag", - dependencies = { - 'nvim-treesitter/nvim-treesitter' - }, - opts = require('config.autotag') - }, - { - "lukas-reineke/indent-blankline.nvim", - main = "ibl", - opts = { - debounce = 10, - indent = { - char = '▏', - }, - scope = { - enabled = true, - show_start = false, - show_end = false - }, - exclude = { - filetypes = { - 'help', - 'dashboard' - } - } - }, - config = function(_, opts) - require 'ibl'.setup(opts) + require("nvim-treesitter.configs").setup(opts) + end, + }, + { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = true, + }, + { + "windwp/nvim-ts-autotag", + dependencies = { + "nvim-treesitter/nvim-treesitter", + }, + opts = require("config.autotag"), + }, + { + "lukas-reineke/indent-blankline.nvim", + main = "ibl", + opts = { + debounce = 10, + indent = { + char = "▏", + }, + scope = { + enabled = true, + show_start = false, + show_end = false, + }, + exclude = { + filetypes = { + "help", + "dashboard", + }, + }, + }, + config = function(_, opts) + require("ibl").setup(opts) - local hooks = require 'ibl.hooks' - hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_tab_indent_level) - hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_space_indent_level) - end - }, - -- Git stuff - { - 'lewis6991/gitsigns.nvim', - dependencies = { - { - "folke/which-key.nvim", - optional = true, - opts = { - defaults = { - ["g"] = { name = "+git" }, - }, - }, - }, - }, - lazy = false, - keys = keys.gitsigns or {}, - opts = require('config.gitsigns') + local hooks = require("ibl.hooks") + hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_tab_indent_level) + hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_space_indent_level) + end, + }, + { + "echasnovski/mini.nvim", + version = false, + }, + -- Git stuff + { + "tpope/vim-fugitive", + keys = keys.fugitive, + }, + { + "lewis6991/gitsigns.nvim", + dependencies = { + { + "folke/which-key.nvim", + optional = true, + opts = { + defaults = { + ["g"] = { name = "+git" }, + }, + }, + }, + }, + lazy = false, + keys = keys.gitsigns or {}, + opts = require("config.gitsigns"), + }, + { + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + dependencies = { + "arkav/lualine-lsp-progress", + "nvim-tree/nvim-web-devicons", + }, + opts = require("config.lualine"), + }, + { + "nvim-telescope/telescope.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "sharkdp/fd", + "nvim-telescope/telescope-ui-select.nvim", + }, + keys = keys.telescope, + opts = require("config.telescope"), + config = function(_, opts) + local telescope = require("telescope") - }, - { - 'nvim-lualine/lualine.nvim', - event = "VeryLazy", - dependencies = { - 'arkav/lualine-lsp-progress', - 'nvim-tree/nvim-web-devicons', - }, - opts = require("config.lualine") - }, - { - 'nvim-telescope/telescope.nvim', - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-tree/nvim-web-devicons', - 'sharkdp/fd', - 'nvim-telescope/telescope-ui-select.nvim', - }, - keys = keys.telescope, - opts = require('config.telescope'), - config = function (_, opts) - local telescope = require("telescope") + telescope.setup(opts) + for name, _ in pairs(opts.extensions or {}) do + telescope.load_extension(name) + end + end, + }, + { + "stevearc/conform.nvim", + keys = keys.conform or {}, + opts = require("config.conform"), + config = function(_, opts) + vim.api.nvim_create_user_command("Format", function(args) + local range = nil + if args.count ~= -1 then + local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1] + range = { + start = { args.line1, 0 }, + ["end"] = { args.line2, end_line:len() }, + } + end + require("conform").format({ async = true, lsp_fallback = true, range = range }) + end, { range = true }) - telescope.setup(opts) - for name, _ in pairs(opts.extensions or {}) do - telescope.load_extension(name) - end - end, - }, - { - 'stevearc/conform.nvim', - keys = keys.conform or {}, - opts = require('config.conform'), - config = function(_, opts) - vim.api.nvim_create_user_command("Format", function(args) - local range = nil - if args.count ~= -1 then - local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1] - range = { - start = { args.line1, 0 }, - ["end"] = { args.line2, end_line:len() }, - } - end - require("conform").format({ async = true, lsp_fallback = true, range = range }) - end, { range = true }) + require("conform").setup(opts) + end, + }, + { + "stevearc/oil.nvim", + keys = keys.oil or {}, + opts = require("config.oil"), + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function(_, opts) + require('oil').setup(opts) - require('conform').setup(opts) - end, - }, - { - 'stevearc/oil.nvim', - keys = keys.oil or {}, - opts = require('config.oil'), - dependencies = { "nvim-tree/nvim-web-devicons" }, - }, - { - "folke/trouble.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, + -- Don't touch my CWD! + require('utils.oil').RegisterCWDHackHook() + end, + }, + { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + keys = keys.trouble or {}, opts = {}, - }, - { - 'L3MON4D3/LuaSnip', - opts = {}, - config = function (_, opts) - require("luasnip.loaders.from_lua").load({paths = "~/.config/nvim/snippets"}) - require("luasnip").setup(opts) - end - }, + }, + { + "L3MON4D3/LuaSnip", + opts = {}, + config = function(_, opts) + require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" }) + require("luasnip").setup(opts) + end, + }, } diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index 0326ae2..5933dab 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -5,7 +5,7 @@ return { "neovim/nvim-lspconfig", "hrsh7th/cmp-nvim-lsp", { - "nvimtools/none-ls.nvim", + "nvimtools/none-ls.nvim", opts = require("config.lsp").nonels, config = function(_, opts) require("null-ls").setup({sources = opts}) @@ -20,8 +20,8 @@ return { "hrsh7th/cmp-buffer", -- autocomplete from buffer "hrsh7th/cmp-path", -- autocomplete from filesystem "hrsh7th/cmp-nvim-lsp", -- autocomplete from lsp - "saadparwaiz1/cmp_luasnip", -- autocomplete from snippet engine - "L3MON4D3/LuaSnip", -- snippet engine + -- "saadparwaiz1/cmp_luasnip", -- autocomplete from snippet engine + -- "L3MON4D3/LuaSnip", -- snippet engine "onsails/lspkind-nvim", -- icons for kind }, opts = require("config.cmp"), @@ -48,6 +48,7 @@ return { end) for name, server_opt in pairs(opts.servers) do + local on_attach = function(client, bufnr) vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) @@ -59,7 +60,7 @@ return { }) end - if (opts.document_highlight or false) and client.supports_method('textDocument/documentHighlight')then + if (opts.document_hightlight or server_opt.document_highlight or false) and client.supports_method('textDocument/documentHighlight')then require("utils.lsp").document_highlight(bufnr) end end diff --git a/nvim/lua/utils/oil.lua b/nvim/lua/utils/oil.lua new file mode 100644 index 0000000..393e5fb --- /dev/null +++ b/nvim/lua/utils/oil.lua @@ -0,0 +1,17 @@ + +local M = {} + +-- Hack for making oil.nvim return to +-- the initial cwd on save. +function M.RegisterCWDHackHook() + local cwd = vim.fn.getcwd() + local group = vim.api.nvim_create_augroup("OilCWDHack", {}) + vim.api.nvim_create_autocmd("BufWritePost", { + group = group, + pattern = "oil:///*", + callback = function() vim.cmd("cd " .. cwd) end, + }) +end + + +return M