From 0411f4b928155d43573f2ebb2a51057eea6acba6 Mon Sep 17 00:00:00 2001 From: Nigel Barink Date: Thu, 26 Sep 2024 16:05:29 +0200 Subject: [PATCH] Moved snippets folder, Added Oil and conform to windows config, improved lsp and telescope config --- lazy-lock.json | 2 ++ lua/barink/plugins/Oil.lua | 14 ++++++++ lua/barink/plugins/conform.lua | 21 ++++++++++++ lua/barink/plugins/lsp.lua | 51 ++++++++++++++++++++++++------ lua/barink/plugins/telescope.lua | 11 +++++-- lua/{ => barink}/snippets/all.lua | 0 lua/{ => barink}/snippets/java.lua | 0 lua/{ => barink}/snippets/lua.lua | 0 8 files changed, 87 insertions(+), 12 deletions(-) create mode 100644 lua/barink/plugins/Oil.lua create mode 100644 lua/barink/plugins/conform.lua rename lua/{ => barink}/snippets/all.lua (100%) rename lua/{ => barink}/snippets/java.lua (100%) rename lua/{ => barink}/snippets/lua.lua (100%) diff --git a/lazy-lock.json b/lazy-lock.json index cec8a7b..4cebdce 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -5,6 +5,7 @@ "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "conform.nvim": { "branch": "master", "commit": "797de8f79055334104cf77893cd93fe3fc2ac154" }, "edgy.nvim": { "branch": "main", "commit": "0e8bbab4eba9dab6c237e4a2e146dc0466897be6" }, "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, "gitsigns.nvim": { "branch": "main", "commit": "356df59308d8b87486644d2324d7558ac0f3db36" }, @@ -25,6 +26,7 @@ "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-treesitter": { "branch": "master", "commit": "733fa85db27079ec2757183c5c840ba15a303e1f" }, "nvim-web-devicons": { "branch": "master", "commit": "e612de3d3a41a6b7be47f51e956dddabcbf419d9" }, + "oil.nvim": { "branch": "master", "commit": "9e5eb2fcd1dfee2ff30c89273ffff179e42034b9" }, "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, diff --git a/lua/barink/plugins/Oil.lua b/lua/barink/plugins/Oil.lua new file mode 100644 index 0000000..a9acfc0 --- /dev/null +++ b/lua/barink/plugins/Oil.lua @@ -0,0 +1,14 @@ +return { + { + "stevearc/oil.nvim", + opt = { + default_file_explorer = false + }, + dependencies = { + 'nvim-tree/nvim-web-devicons' + }, + config = function () + vim.keymap.set("n", "-", "Oil", { desc= "Open parent directory"}) + end + } +} diff --git a/lua/barink/plugins/conform.lua b/lua/barink/plugins/conform.lua new file mode 100644 index 0000000..1b4fa8b --- /dev/null +++ b/lua/barink/plugins/conform.lua @@ -0,0 +1,21 @@ +return { + "stevearc/conform.nvim", + event = { "BufWritePre"}, + cmd = { "ConformInfo"}, + opts = { + formatters_by_ft = { + php = { "pint"}, + lua = { "stylua"}, + javascript = { "prettierd", "prettier", stop_after_first = true }, + typescript = { "prettierd", "prettier", stop_after_first = true }, + }, + format_on_save = { timeout_ms = 500 }, + default_format_ops = { + lsp_format = "fallback" + }, + }, + config = function () + require("conform").setup() + end +} + diff --git a/lua/barink/plugins/lsp.lua b/lua/barink/plugins/lsp.lua index 9212a5a..db41a56 100644 --- a/lua/barink/plugins/lsp.lua +++ b/lua/barink/plugins/lsp.lua @@ -96,14 +96,14 @@ return end end, {silent = true}) - require("luasnip.loaders.from_lua").load({paths= "C:\\Users\\nigel\\AppData\\Local\\nvim\\lua\\snippets"}) + require("luasnip.loaders.from_lua").load({paths= "C:\\Users\\nigel\\AppData\\Local\\nvim\\lua\\barink\\snippets"}) -- Set up lspconfig. local capabilities = require("cmp_nvim_lsp").default_capabilities() local lsp = require("lspconfig") - local language_server = { + local language_server = { asm_lsp= true, zls = true, rust_analyzer = true, @@ -111,28 +111,59 @@ return pylsp = true, clangd = { capabilities = capabilities, - root_dir = require('lspconfig').util.root_pattern("compile_commands.json", "compile_flags.txt", ".git"), + root_dir = require('lspconfig').util.root_pattern("compile_commands.json", "compile_flags.txt", ".git"), cmd = {"clangd"}, filetypes = { "c", "cpp", "objc", "objcpp"}, - settings = { - clangd = { + settings = { + clangd = { compilationDatabasePath = "compile-commands.json", }, } }, tsserver = true, - gopls = true + gopls = true, + lua_ls = { + settings = { + Lua = { + diagnostics = { + globals = { 'vim'} + } + } + } + }, } for name, config in pairs(language_server) do if config == true then config = {} end - config = vim.tbl_deep_extend("force", {}, { - capabilities = capabilities, - }, config) - lsp[name].setup({}) + config = vim.tbl_deep_extend("force", {}, { capabilities = capabilities }, config) + lsp[name].setup({}) end + vim.api.nvim_create_autocmd("LspAttach", { + callback = function (args) + local client = assert(vim.lsp.get_client_by_id(args.data.client_id), "must have valid client") + local settings = language_server[client.name] + if type(settings) ~= "table" then + settings = {} + end + + local builtin = require "telescope.builtin" + + vim.opt_local.omnifunc = "v:lua.vim.lsp.omnifunc" + vim.keymap.set("n", "gd", builtin.lsp_definitions, {buffer = -1}) + vim.keymap.set("n", "gr", builtin.lsp_references, {buffer = -1}) + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, {buffer = -1}) + vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, {buffer = -1}) + vim.keymap.set("n", "K", vim.lsp.buf.hover, {buffer = -1}) + + vim.keymap.set("n", "cr", vim.lsp.buf.rename, {buffer =-1}) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, {buffer = -1}) + vim.keymap.set("n", "wd", builtin.lsp_document_symbols, {buffer = -1}) + + + end + }) end, } diff --git a/lua/barink/plugins/telescope.lua b/lua/barink/plugins/telescope.lua index 87db0b3..eaa0654 100644 --- a/lua/barink/plugins/telescope.lua +++ b/lua/barink/plugins/telescope.lua @@ -14,8 +14,15 @@ return { require('telescope').load_extension('fzf') local builtin = require('telescope.builtin') - vim.keymap.set('n', 'ff', builtin.find_files, {}) - vim.keymap.set('n', 'fs', builtin.git_files, {}) + vim.keymap.set('n', 'fd', builtin.find_files, {}) + vim.keymap.set('n', 'ft', builtin.git_files, {}) + vim.keymap.set('n', 'fh', builtin.help_tags) + vim.keymap.set('n', 'fb', builtin.buffers) + vim.keymap.set('n', '/', builtin.current_buffer_fuzzy_find) + vim.keymap.set('n', 'gw', builtin.grep_string) + vim.keymap.set('n', 'fp',function () + builtin.find_files { cwd = "~/AppData/Local/nvim/lua/barink/"} + end) end } } diff --git a/lua/snippets/all.lua b/lua/barink/snippets/all.lua similarity index 100% rename from lua/snippets/all.lua rename to lua/barink/snippets/all.lua diff --git a/lua/snippets/java.lua b/lua/barink/snippets/java.lua similarity index 100% rename from lua/snippets/java.lua rename to lua/barink/snippets/java.lua diff --git a/lua/snippets/lua.lua b/lua/barink/snippets/lua.lua similarity index 100% rename from lua/snippets/lua.lua rename to lua/barink/snippets/lua.lua