diff --git a/config/colorschemes/colorscheme.nix b/config/colorschemes/colorscheme.nix index fd7fa8be..a61cbb28 100644 --- a/config/colorschemes/colorscheme.nix +++ b/config/colorschemes/colorscheme.nix @@ -2,7 +2,7 @@ colorschemes = { rose-pine = { enable = false; - style = "main"; # "main", "moon", "dawn" or raw lua code + style = "moon"; # "main", "moon", "dawn" or raw lua code disableItalics = false; transparentFloat = true; transparentBackground = true; @@ -19,18 +19,33 @@ disableUnderline = false; transparentBackground = true; integrations = { + cmp = true; noice = true; notify = true; - treesitter = true; - which_key = true; - cmp = true; - gitsigns = true; - harpoon = true; neotree = true; - mini.enabled = true; - indent_blankline.enabled = true; - native_lsp.enabled = true; + harpoon = true; + gitsigns = true; + which_key = true; + illuminate = { + enabled = true; + }; + treesitter = true; + treesitter_context = true; telescope.enabled = true; + indent_blankline.enabled = true; + mini.enabled = true; + native_lsp = { + enabled = true; + inlay_hints = { + background = true; + }; + underlines = { + errors = [ "underline" ]; + hints = [ "underline" ]; + information = [ "underline" ]; + warnings = [ "underline" ]; + }; + }; }; }; }; diff --git a/config/completion/cmp.nix b/config/completion/cmp.nix index f2c921ce..7a251cf2 100644 --- a/config/completion/cmp.nix +++ b/config/completion/cmp.nix @@ -3,6 +3,9 @@ nvim-cmp = { enable = true; autoEnableSources = true; + experimental = { + ghost_text = true; + }; performance = { debounce = 60; fetchingTimeout = 200; @@ -13,37 +16,25 @@ }; formatting = { fields = [ "kind" "abbr" "menu" ]; - format = '' - function(entry, vim_item) - vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) - vim_item.menu = ({ - path = "[Path]", - nvim_lua = "[NVIM_LUA]", - nvim_lsp = "[LSP]", - luasnip = "[Snippet]", - buffer = "[Buffer]", - })[entry.source.name] - return vim_item - end - ''; }; sources = [ { - name = "nvim_lsp"; - keywordLength = 1; + name = "nvim_lsp"; # lsp } { - name = "luasnip"; - keywordLength = 1; + name = "buffer"; # text within current buffer + option.get_bufnrs.__raw = "vim.api.nvim_list_bufs"; + keywordLength = 3; } { - name = "buffer"; - # Words from other open buffers can also be suggested. - option.get_bufnrs.__raw = "vim.api.nvim_list_bufs"; + name = "copilot"; # copilot suggestions + } + { + name = "path"; # file system paths keywordLength = 3; } { - name = "path"; + name = "luasnip"; # snippets keywordLength = 3; } ]; @@ -87,10 +78,10 @@ end ''; }; - "" = { + "" = { action = "cmp.mapping.select_next_item()"; }; - "" = { + "" = { action = "cmp.mapping.select_prev_item()"; }; "" = { @@ -113,18 +104,12 @@ }; }; }; - cmp-buffer = { - enable = true; - }; - cmp_luasnip = { - enable = true; - }; - cmp-nvim-lsp = { - enable = true; - }; - cmp-path = { - enable = true; - }; + cmp-nvim-lsp = { enable = true; }; # lsp + cmp-buffer = { enable = true; }; + copilot-cmp = { enable = true; }; # copilot suggestions + cmp-path = { enable = true; }; # file system paths + cmp_luasnip = { enable = true; }; # snippets + cmp-cmdline = { enable = false; }; # autocomplete for cmdline }; extraConfigLua = '' luasnip = require("luasnip") @@ -181,11 +166,11 @@ }, { { name = 'cmdline' } }), - formatting = { - format = function(_, vim_item) - vim_item.kind = cmdIcons[vim_item.kind] or "FOO" - return vim_item - end - } + -- formatting = { + -- format = function(_, vim_item) + -- vim_item.kind = cmdIcons[vim_item.kind] or "FOO" + -- return vim_item + -- end + -- } }) ''; } diff --git a/config/completion/copilot.nix b/config/completion/copilot.nix index f6830a73..39c5d086 100644 --- a/config/completion/copilot.nix +++ b/config/completion/copilot.nix @@ -3,31 +3,38 @@ enable = true; }; - keymaps = [ - { - mode = "n"; - key = "to"; - action = ":Copilot panel"; - options = { - silent = true; - desc = "Open Copilot"; - }; - } - { - mode = "n"; - key = "tc"; - action = ":lua require('copilot.suggestion').toggle_auto_trigger()"; - options = { - silent = true; - desc = "Toggle Copilot"; - }; - } - ]; + # keymaps = [ + # { + # mode = "n"; + # key = "t"; + # action = "+copilot"; + # } + # + # { + # mode = "n"; + # key = "to"; + # action = ":Copilot panel"; + # options = { + # silent = true; + # desc = "Open Copilot"; + # }; + # } + # + # { + # mode = "n"; + # key = "tc"; + # action = ":lua require('copilot.suggestion').toggle_auto_trigger()"; + # options = { + # silent = true; + # desc = "Toggle Copilot"; + # }; + # } + # ]; extraConfigLua = '' require('copilot').setup({ panel = { - enabled = true, + enabled = false, auto_refresh = true, keymap = { jump_prev = "[[", @@ -42,7 +49,7 @@ }, }, suggestion = { - enabled = true, + enabled = false, auto_trigger = true, debounce = 75, keymap = { diff --git a/config/completion/lspkind.nix b/config/completion/lspkind.nix new file mode 100644 index 00000000..69e8f78c --- /dev/null +++ b/config/completion/lspkind.nix @@ -0,0 +1,12 @@ +{ + plugins.lspkind = { + enable = true; + symbolMap = { + Copilot = ""; + }; + extraOptions = { + maxwidth = 50; + ellipsis_char = "..."; + }; + }; +} diff --git a/config/dap/dap.nix b/config/dap/dap.nix index db5a243a..a38713d0 100644 --- a/config/dap/dap.nix +++ b/config/dap/dap.nix @@ -2,6 +2,7 @@ plugins.dap = { enable = true; adapters = { }; + signs = { dapBreakpoint = { text = "●"; diff --git a/config/default.nix b/config/default.nix index 46617379..e76ce06c 100644 --- a/config/default.nix +++ b/config/default.nix @@ -3,8 +3,6 @@ , pkgs , ... }: { - # TODO: Implement code actions + more keybinds - # Import all your configuration modules here imports = [ ./sets.nix @@ -16,6 +14,7 @@ ./completion/cmp.nix ./completion/copilot.nix + ./completion/lspkind.nix ./dap/dap.nix @@ -25,15 +24,17 @@ ./git/lazygit.nix ./git/neogit.nix + ./languages/nvim-jdtls.nix ./languages/nvim-lint.nix ./languages/typescript-tools-nvim.nix ./languages/treesitter/treesitter.nix + ./languages/treesitter/treesitter-context.nix ./languages/treesitter/treesitter-textobjects.nix ./languages/treesitter/ts-autotag.nix ./languages/treesitter/ts-context-commentstring.nix - ./lsp/lsp.nix ./lsp/conform.nix + ./lsp/lsp.nix ./lsp/trouble.nix ./none-ls/none-ls.nix @@ -67,7 +68,9 @@ ./utils/todo-comments.nix ./utils/toggleterm.nix ./utils/undotree.nix + ./utils/vim-be-good.nix ./utils/wakatime.nix ./utils/whichkey.nix + ./utils/wilder.nix ]; } diff --git a/config/keymaps.nix b/config/keymaps.nix index 1982dcb5..7ee65b19 100644 --- a/config/keymaps.nix +++ b/config/keymaps.nix @@ -58,12 +58,6 @@ action = "+code"; } - { - mode = "n"; - key = "t"; - action = "+copilot"; - } - # Tabs { mode = "n"; diff --git a/config/languages/nvim-jdtls.nix b/config/languages/nvim-jdtls.nix new file mode 100644 index 00000000..4e3081d9 --- /dev/null +++ b/config/languages/nvim-jdtls.nix @@ -0,0 +1,73 @@ +{ pkgs, ... }: { + plugins.nvim-jdtls = { + enable = true; + cmd = [ + "/nix/store/20h2hjjm94gbskqhbwikbgxbblv1xpf2-jdt-language-server-1.31.0/bin/jdtls" + ]; + data = "~/.cache/jdtls/workspace"; + # configuration = "/path/to/configuration"; + # rootDir = "require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'})"; + + # settings = { + # java = { }; + # }; + # + # initOptions = { + # bundles = { }; + # }; + }; + # extraConfigLua = '' + # local jdtls = require("jdtls") + # local cmp_nvim_lsp = require("cmp_nvim_lsp") + # + # local root_dir = require("jdtls.setup").find_root({ "packageInfo" }, "Config") + # local home = os.getenv("HOME") + # local eclipse_workspace = home .. "/.local/share/eclipse/" .. vim.fn.fnamemodify(root_dir, ":p:h:t") + # + # local ws_folders_jdtls = {} + # if root_dir then + # local file = io.open(root_dir .. "/.bemol/ws_root_folders") + # if file then + # for line in file:lines() do + # table.insert(ws_folders_jdtls, "file://" .. line) + # end + # file:close() + # end + # end + # + # -- for completions + # local client_capabilities = vim.lsp.protocol.make_client_capabilities() + # local capabilities = cmp_nvim_lsp.default_capabilities(client_capabilities) + # + # local config = { + # capabilities = capabilities, + # cmd = { + # "${pkgs.jdt-language-server}/bin/jdt-language-server", + # "--jvm-arg=-javaagent:" .. home .. "/Developer/lombok.jar", + # "-data", + # eclipse_workspace, + # "--add-modules=ALL-SYSTEM", + # }, + # root_dir = root_dir, + # init_options = { + # workspaceFolders = ws_folders_jdtls, + # }, + # settings = { + # java = { + # signatureHelp = { enabled = true}, + # completion = { enabled = true }, + # }, + # }, + # on_attach = function(client, bufnr) + # local opts = { silent = true, buffer = bufnr } + # vim.keymap.set('n', "lo", jdtls.organize_imports, { desc = 'Organize imports', buffer = bufnr }) + # vim.keymap.set('n', "df", jdtls.test_class, opts) + # vim.keymap.set('n', "dn", jdtls.test_nearest_method, opts) + # vim.keymap.set('n', 'rv', jdtls.extract_variable_all, { desc = 'Extract variable', buffer = bufnr }) + # vim.keymap.set('n', 'rc', jdtls.extract_constant, { desc = 'Extract constant', buffer = bufnr }) + # end + # } + # + # jdtls.start_or_attach(config) + # ''; +} diff --git a/config/languages/nvim-lint.nix b/config/languages/nvim-lint.nix index 797cd67a..03fa0eb7 100644 --- a/config/languages/nvim-lint.nix +++ b/config/languages/nvim-lint.nix @@ -10,6 +10,7 @@ typescript = [ "eslint_d" ]; typescriptreact = [ "eslint_d" ]; json = [ "jsonlint" ]; + java = [ "checkstyle" ]; }; }; } diff --git a/config/languages/treesitter/treesitter-context.nix b/config/languages/treesitter/treesitter-context.nix new file mode 100644 index 00000000..b588c8fb --- /dev/null +++ b/config/languages/treesitter/treesitter-context.nix @@ -0,0 +1,5 @@ +{ + plugins.treesitter-context = { + enable = true; + }; +} diff --git a/config/languages/treesitter/treesitter-textobjects.nix b/config/languages/treesitter/treesitter-textobjects.nix index d550e9ee..29820cf5 100644 --- a/config/languages/treesitter/treesitter-textobjects.nix +++ b/config/languages/treesitter/treesitter-textobjects.nix @@ -1,6 +1,6 @@ { plugins.treesitter-textobjects = { - enable = true; + enable = false; select = { enable = true; lookahead = true; diff --git a/config/lsp/conform.nix b/config/lsp/conform.nix index 36b0f35d..90c170f6 100644 --- a/config/lsp/conform.nix +++ b/config/lsp/conform.nix @@ -7,15 +7,16 @@ }; notifyOnError = true; formattersByFt = { - lua = [ "stylua" ]; - python = [ "black" ]; - nix = [ "nixpkgs_fmt" ]; html = [ [ "prettierd" "prettier" ] ]; css = [ [ "prettierd" "prettier" ] ]; javascript = [ [ "prettierd" "prettier" ] ]; javascriptreact = [ [ "prettierd" "prettier" ] ]; typescript = [ [ "prettierd" "prettier" ] ]; typescriptreact = [ [ "prettierd" "prettier" ] ]; + java = [ "google-java-format" ]; + python = [ "black" ]; + lua = [ "stylua" ]; + nix = [ "nixpkgs_fmt" ]; markdown = [ [ "prettierd" "prettier" ] ]; rust = [ "rustfmt" ]; }; diff --git a/config/lsp/lsp.nix b/config/lsp/lsp.nix index a1cccf0a..efe886d4 100644 --- a/config/lsp/lsp.nix +++ b/config/lsp/lsp.nix @@ -67,10 +67,10 @@ action = "code_action"; desc = "Code Action"; }; - "" = { - action = "signature_help"; - desc = "Signature Help"; - }; + # "" = { + # action = "signature_help"; + # desc = "Signature Help"; + # }; }; diagnostic = { "cd" = { @@ -89,4 +89,7 @@ }; }; }; + # extraConfigLua = '' + # require('lspconfig').jdtls.setup({}) + # ''; } diff --git a/config/sets.nix b/config/sets.nix index 06336ddc..6180d98b 100644 --- a/config/sets.nix +++ b/config/sets.nix @@ -5,56 +5,106 @@ }: { config = { options = { - cmdheight = 2; # more space in the neovim command line for displaying messages - completeopt = [ "menuone" "noselect" "noinsert" ]; # mostly just for cmp - showmode = false; # we don't need to see things like INSERT anymore - # Block cursor - guicursor = "n-v-c-sm-i-ci-ve:block,r-cr-o:hor20,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor"; - cursorline = true; # Highlight the line where the cursor is located - # Enable relative line numbers number = true; relativenumber = true; - # Tab spacing - tabstop = 2; # insert 4 spaces for a tab + # Set tabs to 2 spaces + tabstop = 2; softtabstop = 2; - shiftwidth = 2; # insert 4 spaces for each indentation showtabline = 2; expandtab = true; + # Enable auto indenting and set it to spaces smartindent = true; + shiftwidth = 2; - wrap = true; - - # Undo stuff from days ago - swapfile = false; - backup = false; - undofile = true; + # Enable smart indenting (see https://stackoverflow.com/questions/1204149/smart-wrap-in-vim) + breakindent = true; - # Search + # Enable incremental searching hlsearch = true; incsearch = true; + + # Enable text wrap + wrap = true; + + # Better splitting + splitbelow = true; + splitright = true; + + # Enable mouse mode + mouse = "a"; # Mouse + + # Enable ignorecase + smartcase for better searching ignorecase = true; smartcase = true; # Don't ignore case with capitals grepprg = "rg --vimgrep"; grepformat = "%f:%l:%c:%m"; - # Better colors + # Decrease updatetime + updatetime = 50; # faster completion (4000ms default) + + # Set completeopt to have a better completion experience + completeopt = [ "menuone" "noselect" "noinsert" ]; # mostly just for cmp + + # Enable persistent undo history + swapfile = false; + backup = false; + undofile = true; + + # Enable 24-bit colors termguicolors = true; - scrolloff = 8; # Will never have less than 8 characters as you scroll down + # Enable the sign column to prevent the screen from jumping signcolumn = "yes"; - updatetime = 50; # faster completion (4000ms default) + + # Enable cursor line highlight + cursorline = true; # Highlight the line where the cursor is located + + # Set fold settings + # These options were reccommended by nvim-ufo + # See: https://github.com/kevinhwang91/nvim-ufo#minimal-configuration + foldcolumn = "0"; + foldlevel = 99; + foldlevelstart = 99; + foldenable = true; + + # Always keep 8 lines above/below cursor unless at start/end of file + scrolloff = 8; + + # Place a column line colorcolumn = "80"; - mouse = "a"; # Mouse + + # Reduce which-key timeout to 10ms timeoutlen = 10; + + # Set encoding type encoding = "utf-8"; fileencoding = "utf-8"; + + # Change cursor options + guicursor = [ + "n-v-c:block" # Normal, visual, command-line: block cursor + "i-ci-ve:block" # Insert, command-line insert, visual-exclude: vertical bar cursor with block cursor, use "ver25" for 25% width + "r-cr:hor20" # Replace, command-line replace: horizontal bar cursor with 20% height + "o:hor50" # Operator-pending: horizontal bar cursor with 50% height + "a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor" # All modes: blinking settings + "sm:block-blinkwait175-blinkoff150-blinkon175" # Showmatch: block cursor with specific blinking settings + ]; + # Enable chars list list = true; # Show invisible characters (tabs, eol, ...) listchars = "eol:↲,tab:|->,lead:·,space: ,trail:•,extends:→,precedes:←,nbsp:␣"; + + # More space in the neovim command line for displaying messages + cmdheight = 2; + + # We don't need to see things like INSERT anymore + showmode = false; + }; + extraConfigLua = '' local opt = vim.opt local g = vim.g diff --git a/config/statusline/lualine.nix b/config/statusline/lualine.nix index 39bd3e27..7f0d4604 100644 --- a/config/statusline/lualine.nix +++ b/config/statusline/lualine.nix @@ -1,7 +1,11 @@ +let + icon = ""; +in { plugins.lualine = { enable = true; alwaysDivideMiddle = true; + globalstatus = true; ignoreFocus = [ "neo-tree" ]; extensions = [ "fzf" ]; theme = "auto"; @@ -15,7 +19,11 @@ }; sections = { lualine_a = [ "mode" ]; - lualine_b = [ "branch" "diff" "diagnostics" ]; + lualine_b = [ + { name = "branch"; icon = ""; } + "diff" + "diagnostics" + ]; lualine_c = [ "filename" ]; lualine_x = [ "filetype" ]; lualine_y = [ "progress" ]; diff --git a/config/telescope/telescope.nix b/config/telescope/telescope.nix index 856de417..3d66f19e 100644 --- a/config/telescope/telescope.nix +++ b/config/telescope/telescope.nix @@ -75,7 +75,7 @@ }; "sk" = { action = "keymaps, {}"; - desc = "Key maps"; + desc = "Keymaps"; }; "sM" = { action = "man_pages, {}"; diff --git a/config/utils/harpoon.nix b/config/utils/harpoon.nix index 9e91a05f..1390d932 100644 --- a/config/utils/harpoon.nix +++ b/config/utils/harpoon.nix @@ -1,6 +1,6 @@ { plugins.harpoon = { - enable = false; + enable = true; enableTelescope = true; keymapsSilent = true; keymaps = { diff --git a/config/utils/toggleterm.nix b/config/utils/toggleterm.nix index a7cd42fd..f0874b4e 100644 --- a/config/utils/toggleterm.nix +++ b/config/utils/toggleterm.nix @@ -37,19 +37,19 @@ }; }; - extraConfigLua = '' - function _G.set_terminal_keymaps() - local opts = { buffer = 0 } - vim.keymap.set("t", "", [[]], opts) - vim.keymap.set("t", "jk", [[]], opts) - vim.keymap.set("t", "", [[wincmd h]], opts) - vim.keymap.set("t", "", [[wincmd j]], opts) - vim.keymap.set("t", "", [[wincmd k]], opts) - vim.keymap.set("t", "", [[wincmd l]], opts) - vim.keymap.set("t", "", [[]], opts) - end - - -- if you only want these mappings for toggle term use term://*toggleterm#* instead - -- vim.cmd("autocmd! TermOpen term://*toggleterm#* lua set_terminal_keymaps()") - ''; + # extraConfigLua = '' + # function _G.set_terminal_keymaps() + # local opts = { buffer = 0 } + # vim.keymap.set("t", "", [[]], opts) + # vim.keymap.set("t", "jk", [[]], opts) + # vim.keymap.set("t", "", [[wincmd h]], opts) + # vim.keymap.set("t", "", [[wincmd j]], opts) + # vim.keymap.set("t", "", [[wincmd k]], opts) + # vim.keymap.set("t", "", [[wincmd l]], opts) + # vim.keymap.set("t", "", [[]], opts) + # end + # + # -- if you only want these mappings for toggle term use term://*toggleterm#* instead + # -- vim.cmd("autocmd! TermOpen term://*toggleterm#* lua set_terminal_keymaps()") + # ''; } diff --git a/config/utils/vim-be-good.nix b/config/utils/vim-be-good.nix new file mode 100644 index 00000000..31cf8bac --- /dev/null +++ b/config/utils/vim-be-good.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: { + extraPlugins = with pkgs.vimPlugins; [ + vim-be-good + ]; +} diff --git a/config/utils/wilder.nix b/config/utils/wilder.nix new file mode 100644 index 00000000..e034e3ae --- /dev/null +++ b/config/utils/wilder.nix @@ -0,0 +1,43 @@ +{ + plugins.wilder = { + enable = true; + modes = [ ":" "/" "?" ]; + pipeline = [ + '' + wilder.branch( + wilder.python_file_finder_pipeline({ + file_command = function(ctx, arg) + if string.find(arg, '.') ~= nil then + return {'fd', '-tf', '-H'} + else + return {'fd', '-tf'} + end + end, + dir_command = {'fd', '-td'}, + filters = {'cpsm_filter'}, + }), + wilder.substitute_pipeline({ + pipeline = wilder.python_search_pipeline({ + skip_cmdtype_check = 1, + pattern = wilder.python_fuzzy_pattern({ + start_at_boundary = 0, + }), + }), + }), + wilder.cmdline_pipeline({ + language = 'python', + fuzzy = 1, + }), + { + wilder.check(function(ctx, x) return x == "" end), + wilder.history(), + }, + wilder.python_search_pipeline({ + pattern = wilder.python_fuzzy_pattern({ + start_at_boundary = 0, + }), + }) + ) '' + ]; + }; +} diff --git a/flake.lock b/flake.lock index de31c771..5f7094e9 100644 --- a/flake.lock +++ b/flake.lock @@ -139,11 +139,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1706173671, - "narHash": "sha256-lciR7kQUK2FCAYuszyd7zyRRmTaXVeoZsCyK6QFpGdk=", + "lastModified": 1706487304, + "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "4fddc9be4eaf195d631333908f2a454b03628ee5", + "rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", "type": "github" }, "original": { @@ -176,11 +176,11 @@ "pre-commit-hooks": "pre-commit-hooks" }, "locked": { - "lastModified": 1706373885, - "narHash": "sha256-JI0ds9Krx5n2CwL/JIJuDCYn05/vgCzKiB39o7/uJO0=", + "lastModified": 1706539542, + "narHash": "sha256-Zbd9/0iTDNwf6ePvKkISvSMK6S7kmfsPzyG5f57sVA8=", "owner": "nix-community", "repo": "nixvim", - "rev": "c2ae78344070ca5c7d7edfeeda19d64b7b90aa35", + "rev": "37d124e94603f821b56072794c4800ad10252fd7", "type": "github" }, "original": {