feat: adding keymapping
This commit is contained in:
parent
de4c01a8ef
commit
7f70386437
243
init.lua
243
init.lua
|
@ -64,6 +64,7 @@ vim.opt.rtp:prepend(lazypath)
|
|||
--
|
||||
-- You can also configure plugins after the setup call,
|
||||
-- as they will be available in your neovim runtime.
|
||||
|
||||
require('lazy').setup({
|
||||
-- NOTE: First, some plugins that don't require any configuration
|
||||
|
||||
|
@ -78,7 +79,8 @@ require('lazy').setup({
|
|||
'SirVer/ultisnips',
|
||||
'honza/vim-snippets',
|
||||
'natebosch/dartlang-snippets',
|
||||
|
||||
'dart-lang/dart-vim-plugin',
|
||||
'morhetz/gruvbox',
|
||||
-- NOTE: This is where your plugins related to LSP can be installed.
|
||||
-- The configuration is done below. Search for lspconfig to find it below.
|
||||
{
|
||||
|
@ -97,7 +99,6 @@ require('lazy').setup({
|
|||
'folke/neodev.nvim',
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
-- Autocompletion
|
||||
'hrsh7th/nvim-cmp',
|
||||
|
@ -213,7 +214,16 @@ require('lazy').setup({
|
|||
},
|
||||
build = ':TSUpdate',
|
||||
},
|
||||
|
||||
{
|
||||
'akinsho/flutter-tools.nvim',
|
||||
lazy = false,
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
'stevearc/dressing.nvim', -- optional for vim.ui.select
|
||||
},
|
||||
config = true,
|
||||
},
|
||||
{ 'akinsho/git-conflict.nvim', version = "*", config = true },
|
||||
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
|
||||
-- These are some example plugins that I've included in the kickstart repository.
|
||||
-- Uncomment any of the lines below to enable them.
|
||||
|
@ -229,13 +239,92 @@ require('lazy').setup({
|
|||
{ import = 'custom.plugins' },
|
||||
}, {})
|
||||
|
||||
-- [[ Setting options ]]
|
||||
local flutterConfig = require("flutter-tools")
|
||||
|
||||
flutterConfig.setup {
|
||||
ui = {
|
||||
border = "rounded",
|
||||
notification_style = 'native'
|
||||
},
|
||||
decorations = {
|
||||
statusline = {
|
||||
-- set to true to be able use the 'flutter_tools_decorations.app_version' in your statusline
|
||||
-- this will show the current version of the flutter app from the pubspec.yaml file
|
||||
app_version = true,
|
||||
-- set to true to be able use the 'flutter_tools_decorations.device' in your statusline
|
||||
-- this will show the currently running device if an application was started with a specific
|
||||
-- device
|
||||
device = true,
|
||||
-- set to true to be able use the 'flutter_tools_decorations.project_config' in your statusline
|
||||
-- this will show the currently selected project configuration
|
||||
project_config = true,
|
||||
}
|
||||
},
|
||||
debugger = { -- integrate with nvim dap + install dart code debugger
|
||||
enabled = false,
|
||||
run_via_dap = false, -- use dap instead of a plenary job to run flutter apps
|
||||
-- if empty dap will not stop on any exceptions, otherwise it will stop on those specified
|
||||
-- see |:help dap.set_exception_breakpoints()| for more info
|
||||
exception_breakpoints = {}
|
||||
},
|
||||
root_patterns = { ".git", "pubspec.yaml" }, -- patterns to find the root of your flutter project
|
||||
fvm = true, -- takes priority over path, uses <workspace>/.fvm/flutter_sdk if enabled
|
||||
widget_guides = {
|
||||
enabled = false,
|
||||
},
|
||||
closing_tags = {
|
||||
highlight = "Comment", -- highlight for the closing tag
|
||||
prefix = "//", -- character to use for close tag e.g. > Widget
|
||||
enabled = true -- set to false to disable
|
||||
},
|
||||
dev_log = {
|
||||
enabled = true,
|
||||
notify_errors = false, -- if there is an error whilst running then notify the user
|
||||
open_cmd = "tabedit", -- command to use to open the log buffer
|
||||
},
|
||||
dev_tools = {
|
||||
autostart = false, -- autostart devtools server if not detected
|
||||
auto_open_browser = false, -- Automatically opens devtools in the browser
|
||||
},
|
||||
outline = {
|
||||
open_cmd = "30vnew", -- command to use to open the outline buffer
|
||||
auto_open = false -- if true this will open the outline automatically when it is first populated
|
||||
},
|
||||
lsp = {
|
||||
color = { -- show the derived colours for dart variables
|
||||
enabled = false, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
|
||||
background = false, -- highlight the background
|
||||
background_color = nil, -- required, when background is transparent (i.e. background_color = { r = 19, g = 17, b = 24},)
|
||||
foreground = false, -- highlight the foreground
|
||||
virtual_text = true, -- show the highlight using virtual text
|
||||
virtual_text_str = "■", -- the virtual text character to highlight
|
||||
},
|
||||
--- OR you can specify a function to deactivate or change or control how the config is created
|
||||
capabilities = function(config)
|
||||
config.specificThingIDontWant = false
|
||||
return config
|
||||
end,
|
||||
-- see the link below for details on each option:
|
||||
-- https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/tool/lsp_spec/README.md#client-workspace-configuration
|
||||
settings = {
|
||||
showTodos = true,
|
||||
completeFunctionCalls = true,
|
||||
renameFilesWithClasses = "prompt", -- "always"
|
||||
enableSnippets = true,
|
||||
updateImportsOnRename = true, -- Whether to update imports and other directives when files are renamed. Required for `FlutterRename` command.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
---i [[ Setting options ]]
|
||||
-- See `:help vim.o`
|
||||
-- NOTE: You can change these options as you wish!
|
||||
|
||||
-- Set highlight on search
|
||||
vim.o.hlsearch = false
|
||||
|
||||
vim.o.exrc = true
|
||||
|
||||
-- Make line numbers default
|
||||
vim.wo.number = true
|
||||
|
||||
|
@ -291,6 +380,14 @@ vim.api.nvim_create_autocmd('TextYankPost', {
|
|||
pattern = '*',
|
||||
})
|
||||
|
||||
-- Auto format
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
buffer = buffer,
|
||||
callback = function()
|
||||
vim.lsp.buf.format { async = false }
|
||||
end
|
||||
})
|
||||
|
||||
-- [[ Configure Telescope ]]
|
||||
-- See `:help telescope` and `:help telescope.setup()`
|
||||
require('telescope').setup {
|
||||
|
@ -319,6 +416,7 @@ vim.keymap.set('n', '<leader>/', function()
|
|||
end, { desc = '[/] Fuzzily search in current buffer' })
|
||||
|
||||
vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
|
||||
vim.keymap.set('n', '<leader>gs', require('telescope.builtin').git_status, { desc = 'Search [G]it [S]tatus' })
|
||||
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
|
||||
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
|
||||
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
|
||||
|
@ -326,11 +424,21 @@ vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc
|
|||
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' })
|
||||
|
||||
|
||||
-- [[ Configure Flutter tools]]
|
||||
vim.keymap.set('n', '<leader>r', require('telescope').extensions.flutter.commands, { desc = 'Open command Flutter' })
|
||||
-- fvm flutter pub get && fvm flutter packages pub ru:build_runner build --delete-conflicting-outputs
|
||||
vim.keymap.set('n', '<leader>br', function()
|
||||
vim.api.nvim_command("botright split new")
|
||||
vim.fn.system { 'echo', 'hi' }
|
||||
end, { desc = 'Flutter get pub and build runner' })
|
||||
|
||||
-- [[ Configure Treesitter ]]
|
||||
-- See `:help nvim-treesitter`
|
||||
require('nvim-treesitter.configs').setup {
|
||||
-- Add languages to be installed here that you want installed for treesitter
|
||||
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' },
|
||||
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim',
|
||||
'dart', 'prisma' },
|
||||
|
||||
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
|
||||
auto_install = false,
|
||||
|
@ -358,6 +466,7 @@ require('nvim-treesitter.configs').setup {
|
|||
['if'] = '@function.inner',
|
||||
['ac'] = '@class.outer',
|
||||
['ic'] = '@class.inner',
|
||||
['uc'] = '@comment.outer'
|
||||
},
|
||||
},
|
||||
move = {
|
||||
|
@ -398,12 +507,17 @@ vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnos
|
|||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
|
||||
|
||||
-- Neotree
|
||||
vim.keymap.set('n', '<leader>tt', '<Cmd>Neotree toggle<CR>', { desc = "Neo[T]ree [T]oggle" })
|
||||
vim.keymap.set('n', '<leader>tr', '<Cmd>Neotree reveal<CR>', { desc = "Neo[T]ree [R]eveal" })
|
||||
vim.keymap.set('n', '<leader>ts', '<Cmd>Neotree git_status<CR>', { desc = "Neo[T]ree git [S]tatus" })
|
||||
|
||||
-- [[ Configure LSP ]]
|
||||
-- This function gets run when an LSP connects to a particular buffer.
|
||||
local on_attach = function(_, bufnr)
|
||||
-- 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
|
||||
-- many times.
|
||||
-- many time
|
||||
--
|
||||
-- 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.
|
||||
|
@ -456,9 +570,9 @@ local servers = {
|
|||
-- gopls = {},
|
||||
-- pyright = {},
|
||||
-- rust_analyzer = {},
|
||||
-- tsserver = {},
|
||||
-- html = { filetypes = { 'html', 'twig', 'hbs'} },
|
||||
|
||||
tsserver = {},
|
||||
prismals = {},
|
||||
-- html = { filetypes = { 'html', 'twig', 'hbs'} }
|
||||
lua_ls = {
|
||||
Lua = {
|
||||
workspace = { checkThirdParty = false },
|
||||
|
@ -474,6 +588,70 @@ require('neodev').setup()
|
|||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
||||
|
||||
|
||||
-- Setup language servers.
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
lspconfig.dartls.setup({
|
||||
cmd = { "dart", "language-server", "--protocol=lsp" },
|
||||
filetypes = { "dart" },
|
||||
init_options = {
|
||||
closingLabels = true,
|
||||
flutterOutline = true,
|
||||
onlyAnalyzeProjectsWithOpenFiles = true,
|
||||
outline = true,
|
||||
suggestFromUnimportedLibraries = true,
|
||||
},
|
||||
-- root_dir = root_pattern("pubspec.yaml"),
|
||||
settings = {
|
||||
dart = {
|
||||
completeFunctionCalls = true,
|
||||
showTodos = true,
|
||||
},
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- Global mappings.
|
||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
|
||||
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
|
||||
|
||||
-- Use LspAttach autocommand to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
||||
callback = function(ev)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
||||
|
||||
-- Buffer local mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local opts = { buffer = ev.buf }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
||||
vim.keymap.set('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, opts)
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
||||
vim.keymap.set('n', '<space>f', function()
|
||||
vim.lsp.buf.format { async = true }
|
||||
end, opts)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Ensure the servers above are installed
|
||||
local mason_lspconfig = require 'mason-lspconfig'
|
||||
|
||||
|
@ -492,6 +670,30 @@ mason_lspconfig.setup_handlers {
|
|||
end
|
||||
}
|
||||
|
||||
require("lspconfig").dartls.setup({
|
||||
cmd = { "dart", "language-server", "--protocol=lsp" },
|
||||
filetypes = { "dart" },
|
||||
init_options = {
|
||||
closingLabels = true,
|
||||
flutterOutline = true,
|
||||
onlyAnalyzeProjectsWithOpenFiles = true,
|
||||
outline = true,
|
||||
suggestFromUnimportedLibraries = true,
|
||||
},
|
||||
-- root_dir = root_pattern("pubspec.yaml"),
|
||||
settings = {
|
||||
dart = {
|
||||
completeFunctionCalls = true,
|
||||
showTodos = true,
|
||||
},
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
end,
|
||||
})
|
||||
|
||||
require("telescope").load_extension("flutter")
|
||||
|
||||
|
||||
-- [[ Configure nvim-cmp ]]
|
||||
-- See `:help cmp`
|
||||
local cmp = require 'cmp'
|
||||
|
@ -541,4 +743,25 @@ cmp.setup {
|
|||
}
|
||||
|
||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||
-- vim: ts=2 sts=2 sw=2 et
|
||||
-- vim: ts=2 sts=2 sw=2 etc
|
||||
require('onedark').setup {
|
||||
colors = {
|
||||
bright_orange = "#ff8800", -- define a new color
|
||||
green = '#00ffaa', -- redefine an existing color
|
||||
},
|
||||
highlights = {
|
||||
-- ["@keyword"] = { fg = '$green' },
|
||||
["@string"] = { fmt = 'bold,italic', fg = '$orange' },
|
||||
["@function"] = { sp = '$yellow' },
|
||||
["@function.builtin"] = { fg = '#0059ff' },
|
||||
["@parameter"] = { fg = '$cyan' },
|
||||
["@variable.builtin"] = { fg = '#00ffff' },
|
||||
["@type.builtin"] = { fg = '#00ffff' },
|
||||
-- ["@constant"] = { fg = '$purple' }
|
||||
-- ["@constant"] = { fg = '$purple' }
|
||||
-- ["@constant.builtin"] = { fg = '$purple' }
|
||||
-- ["@type"] = { fg = '$purple' }
|
||||
}
|
||||
}
|
||||
|
||||
require('onedark').load()
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
-- File: lua/custom/plugins/autopairs.lua
|
||||
|
||||
return {
|
||||
"windwp/nvim-autopairs",
|
||||
-- Optional dependency
|
||||
dependencies = { 'hrsh7th/nvim-cmp' },
|
||||
config = function()
|
||||
require("nvim-autopairs").setup {}
|
||||
-- If you want to automatically add `(` after selecting a function or method
|
||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
local cmp = require('cmp')
|
||||
cmp.event:on(
|
||||
'confirm_done',
|
||||
cmp_autopairs.on_confirm_done()
|
||||
)
|
||||
end,
|
||||
}
|
|
@ -184,7 +184,7 @@ return {
|
|||
nesting_rules = {},
|
||||
filesystem = {
|
||||
filtered_items = {
|
||||
visible = false, -- when true, they will just be displayed differently than normal items
|
||||
visible = true, -- when true, they will just be displayed differently than normal items
|
||||
hide_dotfiles = true,
|
||||
hide_gitignored = true,
|
||||
hide_hidden = true, -- only works on Windows for hidden files/directories
|
||||
|
@ -207,7 +207,7 @@ return {
|
|||
},
|
||||
},
|
||||
follow_current_file = {
|
||||
enabled = false, -- This will find and focus the file in the active buffer every time
|
||||
enabled = true, -- This will find and focus the file in the active buffer every time
|
||||
-- -- the current file is changed while the tree is open.
|
||||
leave_dirs_open = false, -- `false` closes auto expanded dirs, such as with `:Neotree reveal`
|
||||
},
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
return {
|
||||
"folke/trouble.nvim",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
opts = {
|
||||
-- your configuration comes here
|
||||
-- or leave it empty to use the default settings
|
||||
-- refer to the configuration section below
|
||||
},
|
||||
}
|
Loading…
Reference in New Issue