diff --git a/init.lua b/init.lua index eb8de56e..2d95f0f3 100644 --- a/init.lua +++ b/init.lua @@ -380,6 +380,7 @@ require('lazy').setup({ vim.keymap.set('n', 'wl', 'l', { desc = '[W]indow Right' }) vim.keymap.set('n', 'wq', 'q', { desc = '[W]indow Quit' }) vim.keymap.set('n', 'w=', '=', { desc = '[W]indow Equalize' }) + vim.keymap.set('n', 'e', ':Neotree toggle', { desc = 'Toggle Neotree' }) -- Slightly advanced example of overriding default behavior and theme vim.keymap.set('n', '/', function() @@ -423,57 +424,18 @@ require('lazy').setup({ -- Main LSP Configuration 'neovim/nvim-lspconfig', dependencies = { - -- Automatically install LSPs and related tools to stdpath for Neovim - -- Mason must be loaded before its dependents so we need to set it up here. - -- NOTE: `opts = {}` is the same as calling `require('mason').setup({})` { 'mason-org/mason.nvim', opts = {} }, 'mason-org/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', - -- Useful status updates for LSP. { 'j-hui/fidget.nvim', opts = {} }, - -- Allows extra capabilities provided by blink.cmp 'saghen/blink.cmp', }, config = function() - -- Brief aside: **What is LSP?** - -- - -- LSP is an initialism you've probably heard, but might not understand what it is. - -- - -- LSP stands for Language Server Protocol. It's a protocol that helps editors - -- and language tooling communicate in a standardized fashion. - -- - -- In general, you have a "server" which is some tool built to understand a particular - -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers - -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone - -- processes that communicate with some "client" - in this case, Neovim! - -- - -- LSP provides Neovim with features like: - -- - Go to definition - -- - Find references - -- - Autocompletion - -- - Symbol Search - -- - and more! - -- - -- Thus, Language Servers are external tools that must be installed separately from - -- Neovim. This is where `mason` and related plugins come into play. - -- - -- If you're wondering about lsp vs treesitter, you can check out the wonderfully - -- and elegantly composed help section, `:help lsp-vs-treesitter` - - -- This function gets run when an LSP attaches to a particular buffer. - -- That is to say, every time a new file is opened that is associated with - -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this - -- function will be executed to configure the current buffer vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), callback = function(event) - -- NOTE: Remember that Lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. local map = function(keys, func, desc, mode) mode = mode or 'n' vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) @@ -543,12 +505,24 @@ require('lazy').setup({ callback = vim.lsp.buf.document_highlight, }) + vim.api.nvim_create_autocmd('BufWritePre', { + pattern = '*.go', + callback = function() + vim.cmd 'silent! !gofmt -w %' + end, + }) vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { buffer = event.buf, group = highlight_augroup, callback = vim.lsp.buf.clear_references, }) + vim.api.nvim_create_autocmd('CursorHold', { + callback = function() + vim.diagnostic.open_float(nil, { focusable = false }) + end, + }) + vim.api.nvim_create_autocmd('LspDetach', { group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), callback = function(event2) @@ -616,18 +590,6 @@ require('lazy').setup({ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, - -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs - -- - -- Some languages (like typescript) have entire language plugins that can be useful: - -- https://github.com/pmizio/typescript-tools.nvim - -- - -- But for many setups, the LSP (`ts_ls`) will work just fine - -- ts_ls = {}, - -- - lua_ls = { -- cmd = { ... }, -- filetypes = { ... }, @@ -828,11 +790,11 @@ require('lazy').setup({ -- change the command in the config to whatever the name of that colorscheme is. -- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', + 'thesimonho/kanagawa-paper.nvim', priority = 1000, -- Make sure to load this before all the other start plugins. config = function() ---@diagnostic disable-next-line: missing-fields - require('tokyonight').setup { + require('kanagawa-paper').setup { styles = { comments = { italic = false }, -- Disable italics in comments }, @@ -841,7 +803,14 @@ require('lazy').setup({ -- Load the colorscheme here. -- Like many other themes, this one has different styles, and you could load -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' + vim.cmd.colorscheme 'kanagawa-paper' + + vim.api.nvim_set_hl(0, 'Normal', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'NormalNC', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'NormalFloat', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'FloatBorder', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'SignColumn', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'VertSplit', { bg = 'none' }) end, }, diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 375bef48..0bfe66c6 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -5,38 +5,46 @@ -- Bootstrap lazy.nvim return { { - { - 'ray-x/go.nvim', - dependencies = { - 'ray-x/guihua.lua', -- required UI library - 'nvim-treesitter/nvim-treesitter', - 'neovim/nvim-lspconfig', - }, - ft = { 'go', 'gomod' }, - config = function() - require('go').setup { - lsp_cfg = true, -- auto-setup gopls - lsp_on_attach = function(client, bufnr) - -- Auto format on save - if client.server_capabilities.documentFormattingProvider then - vim.api.nvim_create_autocmd('BufWritePre', { - group = vim.api.nvim_create_augroup('GoFormat', { clear = true }), - buffer = bufnr, - callback = function() - vim.lsp.buf.format { async = false } - end, - }) - end - end, - } - end, + 'nvim-neo-tree/neo-tree.nvim', + branch = 'v3.x', + dependencies = { + 'nvim-lua/plenary.nvim', + 'MunifTanjim/nui.nvim', + 'nvim-tree/nvim-web-devicons', -- optional, but recommended }, - { - 'windwp/nvim-autopairs', - event = 'InsertEnter', - config = true, - -- use opts = {} for passing setup options - -- this is equivalent to setup({}) function + lazy = false, -- neo-tree will lazily load itself + }, + { + 'ray-x/go.nvim', + dependencies = { + 'ray-x/guihua.lua', -- required UI library + 'nvim-treesitter/nvim-treesitter', + 'neovim/nvim-lspconfig', }, + ft = { 'go', 'gomod' }, + config = function() + require('go').setup { + lsp_cfg = true, -- auto-setup gopls + lsp_on_attach = function(client, bufnr) + -- Auto format on save + if client.server_capabilities.documentFormattingProvider then + vim.api.nvim_create_autocmd('BufWritePre', { + group = vim.api.nvim_create_augroup('GoFormat', { clear = true }), + buffer = bufnr, + callback = function() + vim.lsp.buf.format { async = false } + end, + }) + end + end, + } + end, + }, + { + 'windwp/nvim-autopairs', + event = 'InsertEnter', + config = true, + -- use opts = {} for passing setup options + -- this is equivalent to setup({}) function }, } diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua new file mode 100644 index 00000000..4a3a4ca2 --- /dev/null +++ b/lua/kickstart/plugins/lsp.lua @@ -0,0 +1,13 @@ +lspconfig.gopls.setup { + capabilities = capabilities, + on_attach = on_attach, + settings = { + gopls = { + completeUnimported = true, + usePlaceholders = true, + analyses = { + unusedparams = true, + }, + }, + }, +}