diff --git a/init.lua b/init.lua index aff5250e921..505ee68b803 100644 --- a/init.lua +++ b/init.lua @@ -70,7 +70,6 @@ Kickstart Guide: These are hints about where to find more information about the relevant settings, plugins or Neovim features used in Kickstart. - NOTE: Look for lines like this Throughout the file. These are for you, the reader, to help you understand what is happening. Feel free to delete them once you know what you're doing, but they should serve as a guide @@ -99,7 +98,7 @@ do vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal - vim.g.have_nerd_font = false + vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.o` @@ -640,10 +639,45 @@ do -- Most Language Servers support renaming across files, etc. map('grn', vim.lsp.buf.rename, '[R]e[n]ame') - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. - map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) - + -- Enable the following language servers + -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. + -- + -- Add any additional override configuration in the following tables. Available keys are: + -- - cmd (table): Override the default command used to start the server + -- - filetypes (table): Override the default list of associated filetypes for the server + -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. + -- - settings (table): Override the default settings passed when initializing the server. + -- 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 = { ... }, + -- capabilities = {}, + settings = { + Lua = { + completion = { + callSnippet = 'Replace', + }, + -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- diagnostics = { disable = { 'missing-fields' } }, + }, + }, + }, + } -- WARN: This is not Goto Definition, this is Goto Declaration. -- For example, in C this would take you to the header. map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') @@ -966,18 +1000,54 @@ do -- Here are some example plugins that I've included in the Kickstart repository. -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- - -- require 'kickstart.plugins.debug' - -- require 'kickstart.plugins.indent_line' - -- require 'kickstart.plugins.lint' - -- require 'kickstart.plugins.autopairs' - -- require 'kickstart.plugins.neo-tree' - -- require 'kickstart.plugins.gitsigns' -- adds gitsigns recommended keymaps - - -- NOTE: You can add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` + require 'kickstart.plugins.debug', + require 'kickstart.plugins.indent_line', + -- require 'kickstart.plugins.lint', + -- require 'kickstart.plugins.autopairs', + -- require 'kickstart.plugins.neo-tree', + -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + + -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` + -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- require 'custom.plugins' -end + { import = 'custom.plugins' }, + -- + -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` + -- Or use telescope! + -- In normal mode type `sh` then write `lazy.nvim-plugin` + -- you can continue same window with `sr` which resumes last telescope search +}, { + ui = { + -- If you are using a Nerd Font: set icons to an empty table which will use the + -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table + icons = vim.g.have_nerd_font and {} or { + cmd = '⌘', + config = '🛠', + event = '📅', + ft = '📂', + init = '⚙', + keys = '🗝', + plugin = '🔌', + runtime = '💻', + require = '🌙', + source = '📄', + start = '🚀', + task = '📌', + lazy = '💤 ', + }, + }, +}) -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et +vim.api.nvim_create_autocmd('FileType', { + pattern = 'cs', + callback = function() + vim.lsp.start { + name = 'csharp_ls', + cmd = { 'csharp-ls' }, + root_dir = vim.fs.root(0, { '.sln', '.git' }), + } + end, +}) diff --git a/lua/custom/configs/none-ls.lua b/lua/custom/configs/none-ls.lua new file mode 100644 index 00000000000..83f0becaf2f --- /dev/null +++ b/lua/custom/configs/none-ls.lua @@ -0,0 +1,24 @@ +local augroup = vim.api.nvim_create_augroup('LspFormatting', {}) +local none_ls = require 'null-ls' + +local opts = { + sources = { + none_ls.builtins.formatting.clang_format, + }, + on_attach = function(client, bufnr) + if client.supports_method 'textDocument/formatting' then + vim.api.nvim_clear_autocmds { + group = augroup, + buffer = bufnr, + } + vim.api.nvim_create_autocmd('BufWritePre', { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format { bufnr = bufnr } + end, + }) + end + end, +} +return opts diff --git a/lua/custom/keymaps.lua b/lua/custom/keymaps.lua new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/lua/custom/keymaps.lua @@ -0,0 +1 @@ + diff --git a/lua/custom/plugins/lazygit.lua b/lua/custom/plugins/lazygit.lua new file mode 100644 index 00000000000..b2610b00fa7 --- /dev/null +++ b/lua/custom/plugins/lazygit.lua @@ -0,0 +1,10 @@ +return { + 'kdheepak/lazygit.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + }, + -- Lazy-loading: wtyczka ładuje się dopiero, gdy wciśniesz skrót + keys = { + { 'gg', 'LazyGit', desc = 'Otwórz [G]it [G]UI (LazyGit)' }, + }, +} diff --git a/lua/custom/plugins/oil.lua b/lua/custom/plugins/oil.lua new file mode 100644 index 00000000000..a1ce951f911 --- /dev/null +++ b/lua/custom/plugins/oil.lua @@ -0,0 +1,61 @@ +return { + 'stevearc/oil.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + require('oil').setup { + -- Podstawowa konfiguracja + default_file_explorer = true, -- Zastępuje domyślnego Netrw (wbudowany explorer w Vima) + + -- Wygląd i kolumny + columns = { + 'icon', + -- "permissions", + -- "size", + -- "mtime", + }, + + -- Zachowanie buforów + buf_options = { + buflisted = false, + bufhidden = 'hide', + }, + + -- Ukrywanie plików .gitignore + view_options = { + show_hidden = false, -- domyślnie nie pokazuj ukrytych plików (użyj g. aby przełączyć) + is_hidden_file = function(name, bufnr) + return vim.startswith(name, '.') + end, + is_always_hidden = function(name, bufnr) + return name == '..' + end, + }, + + -- Mapowania klawiszy wewnątrz Oil + keymaps = { + ['g?'] = 'actions.show_help', + [''] = 'actions.select', + [''] = 'actions.select_vsplit', -- Otwórz w podziale pionowym + [''] = 'actions.select_split', -- Otwórz w podziale poziomym + [''] = 'actions.select_tab', -- Otwórz w nowej karcie + [''] = 'actions.preview', -- Podgląd + [''] = 'actions.close', -- Zamknij + [''] = 'actions.refresh', -- Odśwież + ['-'] = 'actions.parent', -- Przejdź katalog wyżej + ['_'] = 'actions.open_cwd', -- Otwórz aktualny katalog roboczy + ['`'] = 'actions.cd', -- Zmień aktualny katalog roboczy (CWD) + ['~'] = 'actions.tcd', -- Zmień CWD tylko dla aktualnej karty + ['gs'] = 'actions.change_sort', -- Zmień sortowanie + ['gx'] = 'actions.open_external', -- Otwórz w zewnętrznym programie (np. obrazek w przeglądarce) + ['g.'] = 'actions.toggle_hidden', -- Przełącz ukryte pliki + ['g\\'] = 'actions.toggle_trash', -- Pokaż kosz + }, + + -- Gdzie używać kosza zamiast trwałego usunięcia (wymaga programu 'trash' w systemie) + use_default_keymaps = true, + } + + -- Mapowanie do otwierania Oil z dowolnego miejsca + vim.keymap.set('n', '-', 'Oil', { desc = 'Otwórz folder nadrzędny (Oil)' }) + end, +}