diff --git a/nvim/after/plugin/behavior.lua b/nvim/after/plugin/behavior.lua index 0f75efb..ddfcc5a 100644 --- a/nvim/after/plugin/behavior.lua +++ b/nvim/after/plugin/behavior.lua @@ -4,11 +4,32 @@ require 'better_escape' .setup() require 'Comment' .setup() +local conform = require 'conform' +conform.setup { + formatters_by_ft = { + objc = { + 'clang_format', + }, + go = { + 'goimports', 'gopls', + } + } +} - -vim.keymap.set('n', 'f', vim.lsp.buf.format) - +vim.keymap.set('n', '', vim.cmd.so) +vim.keymap.set('n', 'w', vim.cmd.write) +vim.keymap.set('n', 'q', vim.cmd.quit) +vim.keymap.set('n', 'b', vim.cmd.Buffers) +vim.keymap.set('n', 'f', conform.format) +vim.keymap.set('n', 'F', vim.lsp.buf.format) +vim.keymap.set('n', 'r', vim.lsp.buf.rename) vim.keymap.set('n', 'e', vim.cmd.Neotree) +vim.keymap.set('n', 'h', vim.cmd.History) vim.keymap.set('n', 'g', vim.cmd.Rg) -vim.keymap.set('n', 'G', vim.cmd.FZF) -vim.keymap.set('n', 'u', vim.cmd.UndotreeToggle) +vim.keymap.set('n', 'j', vim.cmd.FZF) +vim.keymap.set('n', 'u', vim.cmd.UndotreeToggle) +vim.keymap.set('n', '5', ':vsplit:Files') +vim.keymap.set('v', 'y', '"+y') +vim.keymap.set('n', 'y', '"+y') +vim.keymap.set('n', 'p', '"+p') +vim.keymap.set('v', 'p', '"+p') diff --git a/nvim/after/plugin/lsp.lua b/nvim/after/plugin/lsp.lua index 3abd46f..f25c665 100644 --- a/nvim/after/plugin/lsp.lua +++ b/nvim/after/plugin/lsp.lua @@ -11,7 +11,7 @@ vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } -- ) -require('luasnip.loaders.from_vscode').lazy_load() +require 'luasnip.loaders.from_vscode'.lazy_load() local cmp = require('cmp') local lspkind = require('lspkind') @@ -76,8 +76,37 @@ lsp_defaults.capabilities = vim.tbl_deep_extend( require 'cmp_nvim_lsp'.default_capabilities() ) +lsp_config.lua_ls.setup { + on_init = function(client) + local path = client.workspace_folders[1].name + if vim.loop.fs_stat(path .. '/.luarc.json') or vim.loop.fs_stat(path .. '/.luarc.jsonc') then + return + end -lsp_config.lua_ls.setup({}) + client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { + runtime = { + -- Tell the language server which version of Lua you're using + -- (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT' + }, + -- Make the server aware of Neovim runtime files + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME + -- Depending on the usage, you might want to add additional paths here. + -- "${3rd}/luv/library" + -- "${3rd}/busted/library", + } + -- or pull in all of 'runtimepath'. NOTE: this is a lot slower + -- library = vim.api.nvim_get_runtime_file("", true) + } + }) + end, + settings = { + Lua = {} + } +} lsp_config.jsonls.setup { settings = { @@ -93,3 +122,5 @@ lsp_config.rust_analyzer.setup {} lsp_config.clangd.setup {} lsp_config.eslint.setup {} lsp_config.tsserver.setup {} +lsp_config.gopls.setup {} +lsp_config.ols.setup {} diff --git a/nvim/after/plugin/neo-tree.lua b/nvim/after/plugin/neo-tree.lua index 2a34d17..76305f6 100644 --- a/nvim/after/plugin/neo-tree.lua +++ b/nvim/after/plugin/neo-tree.lua @@ -3,7 +3,7 @@ require('neo-tree').setup({ "filesystem", "buffers", "git_status", - -- "document_symbols", + "document_symbols", }, add_blank_line_at_top = false, -- Add a blank line at the top of the tree. auto_clean_after_session_restore = false, -- Automatically clean up broken neo-tree buffers saved in sessions @@ -17,7 +17,6 @@ require('neo-tree').setup({ enable_modified_markers = true, -- Show markers for files with unsaved changes. enable_opened_markers = true, -- Enable tracking of opened files. Required for `components.name.highlight_opened_files` enable_refresh_on_write = true, -- Refresh the tree when a file is written. Only used if `use_libuv_file_watcher` is false. - enable_normal_mode_for_inputs = false, -- Enable normal mode for input dialogs. git_status_async = true, -- These options are for people with VERY large git repos git_status_async_options = { @@ -85,78 +84,86 @@ require('neo-tree').setup({ highlight_separator_active = "NeoTreeTabSeparatorActive", }, -- - --event_handlers = { - -- { - -- event = "before_render", - -- handler = function (state) - -- -- add something to the state that can be used by custom components - -- end - -- }, - -- { - -- event = "file_opened", - -- handler = function(file_path) - -- --auto close - -- require("neo-tree.command").execute({ action = "close" }) - -- end - -- }, - -- { - -- event = "file_opened", - -- handler = function(file_path) - -- --clear search after opening a file - -- require("neo-tree.sources.filesystem").reset_search() - -- end - -- }, - -- { - -- event = "file_renamed", - -- handler = function(args) - -- -- fix references to file - -- print(args.source, " renamed to ", args.destination) - -- end - -- }, - -- { - -- event = "file_moved", - -- handler = function(args) - -- -- fix references to file - -- print(args.source, " moved to ", args.destination) - -- end - -- }, - -- { - -- event = "neo_tree_buffer_enter", - -- handler = function() - -- vim.cmd 'highlight! Cursor blend=100' - -- end - -- }, - -- { - -- event = "neo_tree_buffer_leave", - -- handler = function() - -- vim.cmd 'highlight! Cursor guibg=#5f87af blend=0' - -- end - -- }, - -- { - -- event = "neo_tree_window_before_open", - -- handler = function(args) - -- print("neo_tree_window_before_open", vim.inspect(args)) - -- end - -- }, - -- { - -- event = "neo_tree_window_after_open", - -- handler = function(args) - -- vim.cmd("wincmd =") - -- end - -- }, - -- { - -- event = "neo_tree_window_before_close", - -- handler = function(args) - -- print("neo_tree_window_before_close", vim.inspect(args)) - -- end - -- }, - -- { - -- event = "neo_tree_window_after_close", - -- handler = function(args) - -- vim.cmd("wincmd =") - -- end - -- } - --}, + event_handlers = { + { + event = "neo_tree_popup_input_ready", + ---@param args { bufnr: integer, winid: integer } + handler = function(args) + vim.cmd("stopinsert") + vim.keymap.set("i", "", vim.cmd.stopinsert, { noremap = true, buffer = args.bufnr }) + end, + }, + -- { + -- event = "before_render", + -- handler = function (state) + -- -- add something to the state that can be used by custom components + -- end + -- }, + -- { + -- event = "file_opened", + -- handler = function(file_path) + -- --auto close + -- require("neo-tree.command").execute({ action = "close" }) + -- end + -- }, + -- { + -- event = "file_opened", + -- handler = function(file_path) + -- --clear search after opening a file + -- require("neo-tree.sources.filesystem").reset_search() + -- end + -- }, + -- { + -- event = "file_renamed", + -- handler = function(args) + -- -- fix references to file + -- print(args.source, " renamed to ", args.destination) + -- end + -- }, + -- { + -- event = "file_moved", + -- handler = function(args) + -- -- fix references to file + -- print(args.source, " moved to ", args.destination) + -- end + -- }, + -- { + -- event = "neo_tree_buffer_enter", + -- handler = function() + -- vim.cmd 'highlight! Cursor blend=100' + -- end + -- }, + -- { + -- event = "neo_tree_buffer_leave", + -- handler = function() + -- vim.cmd 'highlight! Cursor guibg=#5f87af blend=0' + -- end + -- }, + -- { + -- event = "neo_tree_window_before_open", + -- handler = function(args) + -- print("neo_tree_window_before_open", vim.inspect(args)) + -- end + -- }, + -- { + -- event = "neo_tree_window_after_open", + -- handler = function(args) + -- vim.cmd("wincmd =") + -- end + -- }, + -- { + -- event = "neo_tree_window_before_close", + -- handler = function(args) + -- print("neo_tree_window_before_close", vim.inspect(args)) + -- end + -- }, + -- { + -- event = "neo_tree_window_after_close", + -- handler = function(args) + -- vim.cmd("wincmd =") + -- end + -- } + }, default_component_configs = { container = { enable_character_fade = true, @@ -331,7 +338,7 @@ require('neo-tree').setup({ window = { -- see https://github.com/MunifTanjim/nui.nvim/tree/main/lua/nui/popup for -- possible options. These can also be functions that return these options. - position = "left", -- left, right, top, bottom, float, current + position = "current", -- left, right, top, bottom, float, current width = 40, -- applies to left and right positions height = 15, -- applies to top and bottom positions auto_expand_width = false, -- expand the window when file exceeds the window width. does not work with position = "float" @@ -344,8 +351,8 @@ require('neo-tree').setup({ -- you can also specify border here, if you want a different setting from -- the global popup_border_style. }, - same_level = false, -- Create and paste/move files/directories on the same level as the directory under cursor (as opposed to within the directory under cursor). - insert_as = "child", -- Affects how nodes get inserted into the tree during creation/pasting/moving of files if the node under the cursor is a directory: + same_level = false, -- Create and paste/move files/directories on the same level as the directory under cursor (as opposed to within the directory under cursor). + insert_as = "sibling", -- Affects how nodes get inserted into the tree during creation/pasting/moving of files if the node under the cursor is a directory: -- "child": Insert nodes as children of the directory under cursor. -- "sibling": Insert nodes as siblings of the directory under cursor. -- Mappings for tree window. See `:h neo-tree-mappings` for a list of built-in commands. diff --git a/nvim/after/plugin/ui.lua b/nvim/after/plugin/ui.lua index 91e5b52..73c6065 100644 --- a/nvim/after/plugin/ui.lua +++ b/nvim/after/plugin/ui.lua @@ -1,35 +1,20 @@ local alpha_dashboard = require 'alpha.themes.dashboard' alpha_dashboard.section.buttons.val = { - alpha_dashboard.button("e", " > New file", ":ene startinsert "), - alpha_dashboard.button("f", " > Find file", ":FZF --reverse --info=inline $HOME/Sync"), - alpha_dashboard.button("r", " > Recent", ":History"), - alpha_dashboard.button("s", " > Settings", ":e $MYVIMRC | :cd %:p:h | split . | wincmd k | pwd"), - alpha_dashboard.button("q", " > Quit NVIM", ":qa"), + alpha_dashboard.button("e", "> New file", ":ene startinsert "), + alpha_dashboard.button("f", "> Find file", ":FZF --reverse --info=inline $HOME/Sync"), + alpha_dashboard.button("r", "> Recent", ":History"), + alpha_dashboard.button("s", "> Settings", ":e $MYVIMRC | :cd %:p:h | :split . | :q "), + alpha_dashboard.button("q", "> Quit NVIM", ":qa!"), } +if (os.getenv('TERM_PROGRAM') == 'Apple_Terminal') then + vim.cmd.colorscheme('slate') +else + require 'monokai' + .setup() +end require 'alpha' .setup(alpha_dashboard.opts) -require 'monokai' - .setup() -require 'noice' - .setup({ - lsp = { - -- override markdown rendering so that **cmp** and other plugins use **Treesitter** - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - ["cmp.entry.get_documentation"] = true, - }, - }, - -- you can enable a preset for easier configuration - presets = { - bottom_search = false, -- use a classic bottom cmdline for search - command_palette = true, -- position the cmdline and popupmenu together - long_message_to_split = true, -- long messages will be sent to a split - inc_rename = false, -- enables an input dialog for inc-rename.nvim - lsp_doc_border = true, -- add a border to hover docs and signature help - }, - }) require 'lualine' .setup({ options = { diff --git a/nvim/lua/lconfig.lua b/nvim/lua/lconfig.lua index a77ca6c..442127f 100644 --- a/nvim/lua/lconfig.lua +++ b/nvim/lua/lconfig.lua @@ -3,10 +3,6 @@ vim.g.mapleader = ' ' vim.keymap.set('v', 'K', ':m \'<-2gv=gv') vim.keymap.set('v', 'J', ':m \'>+1gv=gv') -vim.keymap.set('n', 'b', vim.cmd.Buffers) - -vim.keymap.set('n', '', vim.cmd.so) - vim.keymap.set('n', '', 'zz') vim.keymap.set('n', '', 'zz') @@ -79,6 +75,7 @@ Plug 'rafamadriz/friendly-snippets' Plug('williamboman/mason.nvim', { ['do'] = ':MasonUpdate' }) Plug 'williamboman/mason-lspconfig.nvim' +Plug 'stevearc/conform.nvim' Plug 'folke/trouble.nvim' Plug 'b0o/schemastore.nvim' @@ -99,4 +96,8 @@ Plug 'folke/noice.nvim' Plug 'tpope/vim-fugitive' Plug 'tpope/vim-sensible' + +Plug 'github/copilot.vim' + + vim.call('plug#end')