From 70167bf1c8651deddb16b65786620508e3346271 Mon Sep 17 00:00:00 2001 From: Sakamoto Hiroshi Date: Sat, 22 Jun 2024 13:10:22 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20personal=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.lua | 28 +++++++++++ lua/configs/conform.lua | 5 +- lua/configs/lspconfig.lua | 29 +++++++++++ lua/mappings.lua | 3 ++ lua/options.lua | 3 +- lua/plugins/init.lua | 101 +++++++++++++++++++++++++++----------- 6 files changed, 138 insertions(+), 31 deletions(-) diff --git a/init.lua b/init.lua index 1152335..a1c7a1c 100644 --- a/init.lua +++ b/init.lua @@ -28,12 +28,40 @@ require("lazy").setup({ { import = "plugins" }, }, lazy_config) +-- load plugins manually +require("neogit").setup{} +require("gitmoji").setup({}) + -- load theme dofile(vim.g.base46_cache .. "defaults") dofile(vim.g.base46_cache .. "statusline") require "nvchad.autocmds" +-- shell +vim.opt.shell = "/bin/fish" + +-- Disable inline diagnostics (virtual text) +vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = false, + } +) + +-- Function to show diagnostics in a floating window on hover +local function show_diagnostics_on_hover() + local opts = { + focusable = false, + close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, + border = 'rounded', + source = 'always', + prefix = ' ', + } + vim.api.nvim_command('autocmd CursorHold * lua vim.diagnostic.open_float(nil, ' .. vim.inspect(opts) .. ')') +end + +-- Call the function to set up the autocmd +show_diagnostics_on_hover() vim.schedule(function() require "mappings" end) diff --git a/lua/configs/conform.lua b/lua/configs/conform.lua index a000447..1df8bea 100644 --- a/lua/configs/conform.lua +++ b/lua/configs/conform.lua @@ -1,8 +1,9 @@ local options = { formatters_by_ft = { lua = { "stylua" }, - -- css = { "prettier" }, - -- html = { "prettier" }, + python = { "black" }, + css = { "prettier" }, + html = { "prettier" }, }, -- format_on_save = { diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index a73657a..c6b8731 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -21,3 +21,32 @@ lspconfig.tsserver.setup { on_init = on_init, capabilities = capabilities, } + +-- python +lspconfig.basedpyright.setup{ + on_attach = on_attach, + on_init = on_init, + capabilities = capabilities, + filetypes = { "python" }, + settings = { + basedpyright = { + typeCheckingMode = "standard", + } + } +} + +---- ruff_lsp and pyright compatibility +local on_attach = function(client, bufnr) + if client.name == 'ruff_lsp' then + -- hover in favor of Pyright + client.server_capabilities.hoverProvider = false + end +end + +lspconfig.ruff_lsp.setup{ + on_attach = on_attach, + on_init = on_init, + capabilities = capabilities, +} + + diff --git a/lua/mappings.lua b/lua/mappings.lua index 783b78f..9916f6d 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -6,5 +6,8 @@ local map = vim.keymap.set map("n", ";", ":", { desc = "CMD enter command mode" }) map("i", "jk", "") +map("n", "gh", ":Neogit ") +map("n", "gm", ":Gitmoji ") + -- map({ "n", "i", "v" }, "", " w ") diff --git a/lua/options.lua b/lua/options.lua index 738f20b..9e2de55 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -1,6 +1,7 @@ require "nvchad.options" -- add yours here! - +vim.opt.foldmethod = "expr" +vim.opt.foldexpr = "nvim_treesitter#foldexpr()" -- local o = vim.o -- o.cursorlineopt ='both' -- to enable cursorline! diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index e62d896..a24816b 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -7,32 +7,77 @@ return { end, }, - -- These are some examples, uncomment them if you want to see them work! - -- { - -- "neovim/nvim-lspconfig", - -- config = function() - -- require("nvchad.configs.lspconfig").defaults() - -- require "configs.lspconfig" - -- end, - -- }, - -- - -- { - -- "williamboman/mason.nvim", - -- opts = { - -- ensure_installed = { - -- "lua-language-server", "stylua", - -- "html-lsp", "css-lsp" , "prettier" - -- }, - -- }, - -- }, - -- - -- { - -- "nvim-treesitter/nvim-treesitter", - -- opts = { - -- ensure_installed = { - -- "vim", "lua", "vimdoc", - -- "html", "css" - -- }, - -- }, - -- }, + { + "neovim/nvim-lspconfig", + config = function() + require("nvchad.configs.lspconfig").defaults() + require "configs.lspconfig" + end, + }, + + { + "williamboman/mason.nvim", + opts = { + ensure_installed = { + "lua-language-server", + "stylua", + "html-lsp", + "css-lsp", + "prettier", + "basedpyright", + "mypy", + "black", + "ruff-lsp", + }, + }, + }, + + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { + "vim", + "lua", + "vimdoc", + "html", + "css", + "python", + }, + }, + }, + + { + "NeogitOrg/neogit", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope.nvim", + }, + config = true, + }, + + { + "kylechui/nvim-surround", + version = "*", -- Use for stability; omit to use `main` branch for the latest features + event = "VeryLazy", + config = function() + require("nvim-surround").setup { + -- Configuration here, or leave empty to use defaults + } + end, + }, + + { + "Dynge/gitmoji.nvim", + dependencies = { + "hrsh7th/nvim-cmp", + }, + opts = { + filetypes = { "gitcommit" }, + completion = { + append_space = false, + complete_as = "emoji", + }, + }, + ft = "gitcommit", + }, }